vfio/pci: Add ioeventfd support

The ioeventfd here is actually irqfd handling of an ioeventfd such as
supported in KVM.  A user is able to pre-program a device write to
occur when the eventfd triggers.  This is yet another instance of
eventfd-irqfd triggering between KVM and vfio.  The impetus for this
is high frequency writes to pages which are virtualized in QEMU.
Enabling this near-direct write path for selected registers within
the virtualized page can improve performance and reduce overhead.
Specifically this is initially targeted at NVIDIA graphics cards where
the driver issues a write to an MMIO register within a virtualized
region in order to allow the MSI interrupt to re-trigger.

Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
Alex Williamson
2018-03-21 12:46:21 -06:00
parent 07fd7ef3a1
commit 30656177c4
4 changed files with 192 additions and 0 deletions

View File

@@ -575,6 +575,33 @@ struct vfio_device_gfx_plane_info {
#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
/**
* VFIO_DEVICE_IOEVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 16,
* struct vfio_device_ioeventfd)
*
* Perform a write to the device at the specified device fd offset, with
* the specified data and width when the provided eventfd is triggered.
* vfio bus drivers may not support this for all regions, for all widths,
* or at all. vfio-pci currently only enables support for BAR regions,
* excluding the MSI-X vector table.
*
* Return: 0 on success, -errno on failure.
*/
struct vfio_device_ioeventfd {
__u32 argsz;
__u32 flags;
#define VFIO_DEVICE_IOEVENTFD_8 (1 << 0) /* 1-byte write */
#define VFIO_DEVICE_IOEVENTFD_16 (1 << 1) /* 2-byte write */
#define VFIO_DEVICE_IOEVENTFD_32 (1 << 2) /* 4-byte write */
#define VFIO_DEVICE_IOEVENTFD_64 (1 << 3) /* 8-byte write */
#define VFIO_DEVICE_IOEVENTFD_SIZE_MASK (0xf)
__u64 offset; /* device fd offset of write */
__u64 data; /* data to be written */
__s32 fd; /* -1 for de-assignment */
};
#define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16)
/* -------- API for Type1 VFIO IOMMU -------- */
/**