Skip to contentSkip to conversation

vfio/cdx: add interrupt support

PATCH Superseded Nipun Gupta 1 participant 1 message Sep 20, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nipun Gupta

author maintainer
#0 lore raw

PATCH 1/1 vfio/cdx: add interrupt support

Support the following ioctls for CDX devices:
- VFIO_DEVICE_GET_IRQ_INFO
- VFIO_DEVICE_SET_IRQS

This allows user to set an eventfd for cdx device interrupts and trigger this interrupt eventfd from userspace.
All CDX device interrupts are MSIs. The MSIs are allocated from the CDX-MSI domain.

---

This patch depends on CDX MSI support patch:
https://lore.kernel.org/all/[email protected]/

 drivers/vfio/cdx/Makefile  |   2 +-
 drivers/vfio/cdx/intr.c    | 211 +++++++++++++++++++++++++++++++++++++
 drivers/vfio/cdx/main.c    |  60 ++++++++++-
 drivers/vfio/cdx/private.h |  18 ++++
 4 files changed, 289 insertions(+), 2 deletions(-)
 create mode 100644 drivers/vfio/cdx/intr.c
drivers/vfio/cdx/Makefile +1 -1
index cd4a2e6fe609..df92b320122a 100644
@@ -5,4 +5,4 @@
 
 obj-$(CONFIG_VFIO_CDX) += vfio-cdx.o
 
-vfio-cdx-objs := main.o
+vfio-cdx-objs := main.o intr.o
drivers/vfio/cdx/intr.c new file +211 -0

211 lines not on this page · raw message

drivers/vfio/cdx/main.c +59 -1

84 lines not on this page · raw message

drivers/vfio/cdx/private.h +18 -0
index 8bdc117ea88e..e813db37df5b 100644
@@ -13,6 +13,14 @@ static inline u64 vfio_cdx_index_to_offset(u32 index)
 	return ((u64)(index) << VFIO_CDX_OFFSET_SHIFT);
 }
 
+struct vfio_cdx_irq {
+	u32			flags;
+	u32			count;
+	int			irq_no;
+	struct eventfd_ctx	*trigger;
+	char			*name;
+};
+
 struct vfio_cdx_region {
 	u32			flags;
 	u32			type;
@@ -23,6 +31,16 @@ struct vfio_cdx_region {
 struct vfio_cdx_device {
 	struct vfio_device	vdev;
 	struct vfio_cdx_region	*regions;
+	struct vfio_cdx_irq	*cdx_irqs;
+	u32			irq_count;
+	u32			config_msi;
 };
 
+int vfio_cdx_set_irqs_ioctl(struct vfio_cdx_device *vdev,
+			    u32 flags, unsigned int index,
+			    unsigned int start, unsigned int count,
+			    void *data);
+
+void vfio_cdx_irqs_cleanup(struct vfio_cdx_device *vdev);
+
 #endif /* VFIO_CDX_PRIVATE_H */
Signature · 1 line
2.17.1