diff options
author | Feng Wu <feng.wu@intel.com> | 2015-09-18 10:29:50 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-10-01 09:06:50 -0400 |
commit | 6d7425f109d2629d1f4b4b146eca8e43701bf966 (patch) | |
tree | d061a775ff497fbb9ca59a577dab070a0c376748 | |
parent | d84f1e0755ba1e87d20d1f90c1e6eb0cbbc0af9d (diff) |
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 <alex.williamson@redhat.com>
Signed-off-by: Feng Wu <feng.wu@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | drivers/vfio/Kconfig | 1 | ||||
-rw-r--r-- | drivers/vfio/pci/Kconfig | 1 | ||||
-rw-r--r-- | drivers/vfio/pci/vfio_pci_intrs.c | 9 | ||||
-rw-r--r-- | drivers/vfio/pci/vfio_pci_private.h | 2 |
4 files changed, 13 insertions, 0 deletions
diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index 454017928ed0..850d86ca685b 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig | |||
@@ -33,3 +33,4 @@ menuconfig VFIO | |||
33 | 33 | ||
34 | source "drivers/vfio/pci/Kconfig" | 34 | source "drivers/vfio/pci/Kconfig" |
35 | source "drivers/vfio/platform/Kconfig" | 35 | source "drivers/vfio/platform/Kconfig" |
36 | source "virt/lib/Kconfig" | ||
diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 579d83bf5358..02912f180c6d 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig | |||
@@ -2,6 +2,7 @@ config VFIO_PCI | |||
2 | tristate "VFIO support for PCI devices" | 2 | tristate "VFIO support for PCI devices" |
3 | depends on VFIO && PCI && EVENTFD | 3 | depends on VFIO && PCI && EVENTFD |
4 | select VFIO_VIRQFD | 4 | select VFIO_VIRQFD |
5 | select IRQ_BYPASS_MANAGER | ||
5 | help | 6 | help |
6 | Support for the PCI VFIO bus driver. This is required to make | 7 | Support for the PCI VFIO bus driver. This is required to make |
7 | use of PCI drivers using the VFIO framework. | 8 | use of PCI drivers using the VFIO framework. |
diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index 1f577b4ac126..3b3ba15558b7 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c | |||
@@ -319,6 +319,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, | |||
319 | 319 | ||
320 | if (vdev->ctx[vector].trigger) { | 320 | if (vdev->ctx[vector].trigger) { |
321 | free_irq(irq, vdev->ctx[vector].trigger); | 321 | free_irq(irq, vdev->ctx[vector].trigger); |
322 | irq_bypass_unregister_producer(&vdev->ctx[vector].producer); | ||
322 | kfree(vdev->ctx[vector].name); | 323 | kfree(vdev->ctx[vector].name); |
323 | eventfd_ctx_put(vdev->ctx[vector].trigger); | 324 | eventfd_ctx_put(vdev->ctx[vector].trigger); |
324 | vdev->ctx[vector].trigger = NULL; | 325 | vdev->ctx[vector].trigger = NULL; |
@@ -360,6 +361,14 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, | |||
360 | return ret; | 361 | return ret; |
361 | } | 362 | } |
362 | 363 | ||
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 | |||
363 | vdev->ctx[vector].trigger = trigger; | 372 | vdev->ctx[vector].trigger = trigger; |
364 | 373 | ||
365 | return 0; | 374 | return 0; |
diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h index ae0e1b4c1711..0e7394f8f69b 100644 --- a/drivers/vfio/pci/vfio_pci_private.h +++ b/drivers/vfio/pci/vfio_pci_private.h | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/mutex.h> | 14 | #include <linux/mutex.h> |
15 | #include <linux/pci.h> | 15 | #include <linux/pci.h> |
16 | #include <linux/irqbypass.h> | ||
16 | 17 | ||
17 | #ifndef VFIO_PCI_PRIVATE_H | 18 | #ifndef VFIO_PCI_PRIVATE_H |
18 | #define VFIO_PCI_PRIVATE_H | 19 | #define VFIO_PCI_PRIVATE_H |
@@ -29,6 +30,7 @@ struct vfio_pci_irq_ctx { | |||
29 | struct virqfd *mask; | 30 | struct virqfd *mask; |
30 | char *name; | 31 | char *name; |
31 | bool masked; | 32 | bool masked; |
33 | struct irq_bypass_producer producer; | ||
32 | }; | 34 | }; |
33 | 35 | ||
34 | struct vfio_pci_device { | 36 | struct vfio_pci_device { |