[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1495656803-28011-6-git-send-email-eric.auger@redhat.com>
Date: Wed, 24 May 2017 22:13:18 +0200
From: Eric Auger <eric.auger@...hat.com>
To: eric.auger.pro@...il.com, eric.auger@...hat.com,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
kvmarm@...ts.cs.columbia.edu, alex.williamson@...hat.com,
pbonzini@...hat.com, marc.zyngier@....com,
christoffer.dall@...aro.org
Cc: drjones@...hat.com, wei@...hat.com
Subject: [PATCH 05/10] VFIO: pci: Introduce direct EOI INTx interrupt handler
We add two new fields in vfio_pci_irq_ctx struct: deoi and handler.
If deoi is set, this means the physical IRQ attached to the virtual
IRQ is directly deactivated by the guest and the VFIO driver does
not need to disable the physical IRQ and mask it at VFIO level.
The handler pointer is set accordingly and a wrapper handler is
introduced that calls the chosen handler function.
Signed-off-by: Eric Auger <eric.auger@...hat.com>
---
---
drivers/vfio/pci/vfio_pci_intrs.c | 32 ++++++++++++++++++++++++++------
drivers/vfio/pci/vfio_pci_private.h | 2 ++
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index d4d377b..06aa713 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -121,11 +121,8 @@ void vfio_pci_intx_unmask(struct vfio_pci_device *vdev)
static irqreturn_t vfio_intx_handler(int irq, void *dev_id)
{
struct vfio_pci_device *vdev = dev_id;
- unsigned long flags;
int ret = IRQ_NONE;
- spin_lock_irqsave(&vdev->irqlock, flags);
-
if (!vdev->pci_2_3) {
disable_irq_nosync(vdev->pdev->irq);
vdev->ctx[0].automasked = true;
@@ -137,14 +134,33 @@ static irqreturn_t vfio_intx_handler(int irq, void *dev_id)
ret = IRQ_HANDLED;
}
- spin_unlock_irqrestore(&vdev->irqlock, flags);
-
if (ret == IRQ_HANDLED)
vfio_send_intx_eventfd(vdev, NULL);
return ret;
}
+static irqreturn_t vfio_intx_handler_deoi(int irq, void *dev_id)
+{
+ struct vfio_pci_device *vdev = dev_id;
+
+ vfio_send_intx_eventfd(vdev, NULL);
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t vfio_intx_wrapper_handler(int irq, void *dev_id)
+{
+ struct vfio_pci_device *vdev = dev_id;
+ unsigned long flags;
+ irqreturn_t ret;
+
+ spin_lock_irqsave(&vdev->irqlock, flags);
+ ret = vdev->ctx[0].handler(irq, dev_id);
+ spin_unlock_irqrestore(&vdev->irqlock, flags);
+
+ return ret;
+}
+
static int vfio_intx_enable(struct vfio_pci_device *vdev)
{
if (!is_irq_none(vdev))
@@ -208,7 +224,11 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd)
if (!vdev->pci_2_3)
irqflags = 0;
- ret = request_irq(pdev->irq, vfio_intx_handler,
+ if (vdev->ctx[0].deoi)
+ vdev->ctx[0].handler = vfio_intx_handler_deoi;
+ else
+ vdev->ctx[0].handler = vfio_intx_handler;
+ ret = request_irq(pdev->irq, vfio_intx_wrapper_handler,
irqflags, vdev->ctx[0].name, vdev);
if (ret) {
vdev->ctx[0].trigger = NULL;
diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h
index f7f1101..5cfe59a 100644
--- a/drivers/vfio/pci/vfio_pci_private.h
+++ b/drivers/vfio/pci/vfio_pci_private.h
@@ -36,6 +36,8 @@ struct vfio_pci_irq_ctx {
char *name;
bool masked;
bool automasked;
+ bool deoi;
+ irqreturn_t (*handler)(int irq, void *dev_id);
struct irq_bypass_producer producer;
};
--
2.5.5
Powered by blists - more mailing lists