[PATCH v2 7/8] virt: irqbypass: Add a type field to the irqbypass producer

Eric Auger
2017-06-15T12:50:55Z

On ARM, we are about to introduce a vfio-platform producer. The
associated architecture specific consumer only is compatible with
this producer and does not work with the dummy vfio-pci msi producer.

Adding a type to the producer allows to easily discriminate between
producers instead of complexifying things by analyzing the interrupt
type.

Signed-off-by: Eric Auger <eric.auger@redhat.com>

---

v2: new
---
drivers/vfio/pci/vfio_pci_intrs.c | 1 +
drivers/vfio/platform/vfio_platform_irq_bypass.c | 1 +
include/linux/irqbypass.h | 7 +++++++
3 files changed, 9 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 1c46045..40a6b21 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -343,6 +343,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,

vdev->ctx[vector].producer.token = trigger;
vdev->ctx[vector].producer.irq = irq;
+ vdev->ctx[vector].producer.type = IRQ_BYPASS_VFIO_PCI_MSI;
ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
if (unlikely(ret))
dev_info(&pdev->dev,
diff --git a/drivers/vfio/platform/vfio_platform_irq_bypass.c b/drivers/vfio/platform/vfio_platform_irq_bypass.c
index 692b081..603b4b3 100644
--- a/drivers/vfio/platform/vfio_platform_irq_bypass.c
+++ b/drivers/vfio/platform/vfio_platform_irq_bypass.c
@@ -102,6 +102,7 @@ void vfio_platform_register_deoi_producer(struct vfio_platform_device *vdev,

prod->token = trigger;
prod->irq = host_irq;
+ prod->type = IRQ_BYPASS_VFIO_PLATFORM;
prod->add_consumer = irq_bypass_deoi_add_consumer;
prod->del_consumer = irq_bypass_deoi_del_consumer;
prod->stop = irq_bypass_deoi_stop;
diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h
index f0f5d26..331c19a 100644
--- a/include/linux/irqbypass.h
+++ b/include/linux/irqbypass.h
@@ -31,11 +31,17 @@ struct irq_bypass_consumer;
* are not supported.
*/

+enum irq_bypass_producer_type {
+ IRQ_BYPASS_VFIO_PCI_MSI,
+ IRQ_BYPASS_VFIO_PLATFORM,
+};
+
/**
* struct irq_bypass_producer - IRQ bypass producer definition
* @node: IRQ bypass manager private list management
* @token: opaque token to match between producer and consumer (non-NULL)
* @irq: Linux IRQ number for the producer device
+ * @type: type of the producer to easily assess interoperability with consumer
* @add_consumer: Connect the IRQ producer to an IRQ consumer (optional)
* @del_consumer: Disconnect the IRQ producer from an IRQ consumer (optional)
* @stop: Perform any quiesce operations necessary prior to add/del (optional)
@@ -49,6 +55,7 @@ struct irq_bypass_producer {
struct list_head node;
void *token;
int irq;
+ enum irq_bypass_producer_type type;
int (*add_consumer)(struct irq_bypass_producer *,
struct irq_bypass_consumer *);
void (*del_consumer)(struct irq_bypass_producer *,
--
2.5.5