diff options
author | Alex Williamson <alex.williamson@redhat.com> | 2015-03-17 10:33:38 -0400 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2015-03-17 10:33:38 -0400 |
commit | 71be3423a62be548c56bab5b818e1a1383e659d2 (patch) | |
tree | b2896fa415f72111e8c26a42d2ee822ac701ac67 | |
parent | 66fdc052d7dba5bb8386f7a1a38107ba8307a59e (diff) |
vfio: Split virqfd into a separate module for vfio bus drivers
An unintended consequence of commit 42ac9bd18d4f ("vfio: initialize
the virqfd workqueue in VFIO generic code") is that the vfio module
is renamed to vfio_core so that it can include both vfio and virqfd.
That's a user visible change that may break module loading scritps
and it imposes eventfd support as a dependency on the core vfio code,
which it's really not. virqfd is intended to be provided as a service
to vfio bus drivers, so instead of wrapping it into vfio.ko, we can
make it a stand-alone module toggled by vfio bus drivers. This has
the additional benefit of removing initialization and exit from the
core vfio code.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r-- | drivers/vfio/Kconfig | 5 | ||||
-rw-r--r-- | drivers/vfio/Makefile | 5 | ||||
-rw-r--r-- | drivers/vfio/pci/Kconfig | 1 | ||||
-rw-r--r-- | drivers/vfio/platform/Kconfig | 1 | ||||
-rw-r--r-- | drivers/vfio/vfio.c | 8 | ||||
-rw-r--r-- | drivers/vfio/virqfd.c | 17 | ||||
-rw-r--r-- | include/linux/vfio.h | 2 |
7 files changed, 25 insertions, 14 deletions
diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index d5322a434a7a..7d092ddc8119 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig | |||
@@ -13,6 +13,11 @@ config VFIO_SPAPR_EEH | |||
13 | depends on EEH && VFIO_IOMMU_SPAPR_TCE | 13 | depends on EEH && VFIO_IOMMU_SPAPR_TCE |
14 | default n | 14 | default n |
15 | 15 | ||
16 | config VFIO_VIRQFD | ||
17 | tristate | ||
18 | depends on VFIO && EVENTFD | ||
19 | default n | ||
20 | |||
16 | menuconfig VFIO | 21 | menuconfig VFIO |
17 | tristate "VFIO Non-Privileged userspace driver framework" | 22 | tristate "VFIO Non-Privileged userspace driver framework" |
18 | depends on IOMMU_API | 23 | depends on IOMMU_API |
diff --git a/drivers/vfio/Makefile b/drivers/vfio/Makefile index d798b0959603..7b8a31f63fea 100644 --- a/drivers/vfio/Makefile +++ b/drivers/vfio/Makefile | |||
@@ -1,6 +1,7 @@ | |||
1 | vfio_core-y := vfio.o virqfd.o | 1 | vfio_virqfd-y := virqfd.o |
2 | 2 | ||
3 | obj-$(CONFIG_VFIO) += vfio_core.o | 3 | obj-$(CONFIG_VFIO) += vfio.o |
4 | obj-$(CONFIG_VFIO_VIRQFD) += vfio_virqfd.o | ||
4 | obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o | 5 | obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o |
5 | obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o | 6 | obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o |
6 | obj-$(CONFIG_VFIO_SPAPR_EEH) += vfio_spapr_eeh.o | 7 | obj-$(CONFIG_VFIO_SPAPR_EEH) += vfio_spapr_eeh.o |
diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index c6bb5da2d2a7..579d83bf5358 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config VFIO_PCI | 1 | 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 | help | 5 | help |
5 | Support for the PCI VFIO bus driver. This is required to make | 6 | Support for the PCI VFIO bus driver. This is required to make |
6 | use of PCI drivers using the VFIO framework. | 7 | use of PCI drivers using the VFIO framework. |
diff --git a/drivers/vfio/platform/Kconfig b/drivers/vfio/platform/Kconfig index c0a3bff8baee..9a4403e2a36c 100644 --- a/drivers/vfio/platform/Kconfig +++ b/drivers/vfio/platform/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config VFIO_PLATFORM | 1 | config VFIO_PLATFORM |
2 | tristate "VFIO support for platform devices" | 2 | tristate "VFIO support for platform devices" |
3 | depends on VFIO && EVENTFD && ARM | 3 | depends on VFIO && EVENTFD && ARM |
4 | select VFIO_VIRQFD | ||
4 | help | 5 | help |
5 | Support for platform devices with VFIO. This is required to make | 6 | Support for platform devices with VFIO. This is required to make |
6 | use of platform devices present on the system using the VFIO | 7 | use of platform devices present on the system using the VFIO |
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 86aac7e4a050..0d336625ac71 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c | |||
@@ -1552,11 +1552,6 @@ static int __init vfio_init(void) | |||
1552 | if (ret) | 1552 | if (ret) |
1553 | goto err_cdev_add; | 1553 | goto err_cdev_add; |
1554 | 1554 | ||
1555 | /* Start the virqfd cleanup handler used by some VFIO bus drivers */ | ||
1556 | ret = vfio_virqfd_init(); | ||
1557 | if (ret) | ||
1558 | goto err_virqfd; | ||
1559 | |||
1560 | pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); | 1555 | pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); |
1561 | 1556 | ||
1562 | /* | 1557 | /* |
@@ -1569,8 +1564,6 @@ static int __init vfio_init(void) | |||
1569 | 1564 | ||
1570 | return 0; | 1565 | return 0; |
1571 | 1566 | ||
1572 | err_virqfd: | ||
1573 | cdev_del(&vfio.group_cdev); | ||
1574 | err_cdev_add: | 1567 | err_cdev_add: |
1575 | unregister_chrdev_region(vfio.group_devt, MINORMASK); | 1568 | unregister_chrdev_region(vfio.group_devt, MINORMASK); |
1576 | err_alloc_chrdev: | 1569 | err_alloc_chrdev: |
@@ -1585,7 +1578,6 @@ static void __exit vfio_cleanup(void) | |||
1585 | { | 1578 | { |
1586 | WARN_ON(!list_empty(&vfio.group_list)); | 1579 | WARN_ON(!list_empty(&vfio.group_list)); |
1587 | 1580 | ||
1588 | vfio_virqfd_exit(); | ||
1589 | idr_destroy(&vfio.group_idr); | 1581 | idr_destroy(&vfio.group_idr); |
1590 | cdev_del(&vfio.group_cdev); | 1582 | cdev_del(&vfio.group_cdev); |
1591 | unregister_chrdev_region(vfio.group_devt, MINORMASK); | 1583 | unregister_chrdev_region(vfio.group_devt, MINORMASK); |
diff --git a/drivers/vfio/virqfd.c b/drivers/vfio/virqfd.c index 3d19aaf0e6c9..27c89cd5d70b 100644 --- a/drivers/vfio/virqfd.c +++ b/drivers/vfio/virqfd.c | |||
@@ -13,12 +13,17 @@ | |||
13 | #include <linux/vfio.h> | 13 | #include <linux/vfio.h> |
14 | #include <linux/eventfd.h> | 14 | #include <linux/eventfd.h> |
15 | #include <linux/file.h> | 15 | #include <linux/file.h> |
16 | #include <linux/module.h> | ||
16 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
17 | 18 | ||
19 | #define DRIVER_VERSION "0.1" | ||
20 | #define DRIVER_AUTHOR "Alex Williamson <alex.williamson@redhat.com>" | ||
21 | #define DRIVER_DESC "IRQFD support for VFIO bus drivers" | ||
22 | |||
18 | static struct workqueue_struct *vfio_irqfd_cleanup_wq; | 23 | static struct workqueue_struct *vfio_irqfd_cleanup_wq; |
19 | static DEFINE_SPINLOCK(virqfd_lock); | 24 | static DEFINE_SPINLOCK(virqfd_lock); |
20 | 25 | ||
21 | int __init vfio_virqfd_init(void) | 26 | static int __init vfio_virqfd_init(void) |
22 | { | 27 | { |
23 | vfio_irqfd_cleanup_wq = | 28 | vfio_irqfd_cleanup_wq = |
24 | create_singlethread_workqueue("vfio-irqfd-cleanup"); | 29 | create_singlethread_workqueue("vfio-irqfd-cleanup"); |
@@ -28,7 +33,7 @@ int __init vfio_virqfd_init(void) | |||
28 | return 0; | 33 | return 0; |
29 | } | 34 | } |
30 | 35 | ||
31 | void vfio_virqfd_exit(void) | 36 | static void __exit vfio_virqfd_exit(void) |
32 | { | 37 | { |
33 | destroy_workqueue(vfio_irqfd_cleanup_wq); | 38 | destroy_workqueue(vfio_irqfd_cleanup_wq); |
34 | } | 39 | } |
@@ -211,3 +216,11 @@ void vfio_virqfd_disable(struct virqfd **pvirqfd) | |||
211 | flush_workqueue(vfio_irqfd_cleanup_wq); | 216 | flush_workqueue(vfio_irqfd_cleanup_wq); |
212 | } | 217 | } |
213 | EXPORT_SYMBOL_GPL(vfio_virqfd_disable); | 218 | EXPORT_SYMBOL_GPL(vfio_virqfd_disable); |
219 | |||
220 | module_init(vfio_virqfd_init); | ||
221 | module_exit(vfio_virqfd_exit); | ||
222 | |||
223 | MODULE_VERSION(DRIVER_VERSION); | ||
224 | MODULE_LICENSE("GPL v2"); | ||
225 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
226 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
diff --git a/include/linux/vfio.h b/include/linux/vfio.h index 683b5146022e..cbed15f194e0 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h | |||
@@ -142,8 +142,6 @@ struct virqfd { | |||
142 | struct virqfd **pvirqfd; | 142 | struct virqfd **pvirqfd; |
143 | }; | 143 | }; |
144 | 144 | ||
145 | extern int vfio_virqfd_init(void); | ||
146 | extern void vfio_virqfd_exit(void); | ||
147 | extern int vfio_virqfd_enable(void *opaque, | 145 | extern int vfio_virqfd_enable(void *opaque, |
148 | int (*handler)(void *, void *), | 146 | int (*handler)(void *, void *), |
149 | void (*thread)(void *, void *), | 147 | void (*thread)(void *, void *), |