Skip to content

Commit 6d7425f

Browse files
Feng Wubonzini
authored andcommitted
vfio: Register/unregister irq_bypass_producer
This patch adds the registration/unregistration of an irq_bypass_producer for MSI/MSIx on vfio pci devices. Acked-by: Alex Williamson <[email protected]> Signed-off-by: Feng Wu <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent d84f1e0 commit 6d7425f

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

drivers/vfio/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ menuconfig VFIO
3333

3434
source "drivers/vfio/pci/Kconfig"
3535
source "drivers/vfio/platform/Kconfig"
36+
source "virt/lib/Kconfig"

drivers/vfio/pci/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ config VFIO_PCI
22
tristate "VFIO support for PCI devices"
33
depends on VFIO && PCI && EVENTFD
44
select VFIO_VIRQFD
5+
select IRQ_BYPASS_MANAGER
56
help
67
Support for the PCI VFIO bus driver. This is required to make
78
use of PCI drivers using the VFIO framework.

drivers/vfio/pci/vfio_pci_intrs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
319319

320320
if (vdev->ctx[vector].trigger) {
321321
free_irq(irq, vdev->ctx[vector].trigger);
322+
irq_bypass_unregister_producer(&vdev->ctx[vector].producer);
322323
kfree(vdev->ctx[vector].name);
323324
eventfd_ctx_put(vdev->ctx[vector].trigger);
324325
vdev->ctx[vector].trigger = NULL;
@@ -360,6 +361,14 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
360361
return ret;
361362
}
362363

364+
vdev->ctx[vector].producer.token = trigger;
365+
vdev->ctx[vector].producer.irq = irq;
366+
ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
367+
if (unlikely(ret))
368+
dev_info(&pdev->dev,
369+
"irq bypass producer (token %p) registration fails: %d\n",
370+
vdev->ctx[vector].producer.token, ret);
371+
363372
vdev->ctx[vector].trigger = trigger;
364373

365374
return 0;

drivers/vfio/pci/vfio_pci_private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include <linux/mutex.h>
1515
#include <linux/pci.h>
16+
#include <linux/irqbypass.h>
1617

1718
#ifndef VFIO_PCI_PRIVATE_H
1819
#define VFIO_PCI_PRIVATE_H
@@ -29,6 +30,7 @@ struct vfio_pci_irq_ctx {
2930
struct virqfd *mask;
3031
char *name;
3132
bool masked;
33+
struct irq_bypass_producer producer;
3234
};
3335

3436
struct vfio_pci_device {

0 commit comments

Comments
 (0)