]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
vfio: Split virqfd into a separate module for vfio bus drivers
authorAlex Williamson <alex.williamson@redhat.com>
Tue, 17 Mar 2015 14:33:38 +0000 (08:33 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 17 Mar 2015 14:33:38 +0000 (08:33 -0600)
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>
drivers/vfio/Kconfig
drivers/vfio/Makefile
drivers/vfio/pci/Kconfig
drivers/vfio/platform/Kconfig
drivers/vfio/vfio.c
drivers/vfio/virqfd.c
include/linux/vfio.h

index d5322a434a7a474da70f544cc1eda2cd1fd39377..7d092ddc81195814ca0409fdcc19770832f35086 100644 (file)
@@ -13,6 +13,11 @@ config VFIO_SPAPR_EEH
        depends on EEH && VFIO_IOMMU_SPAPR_TCE
        default n
 
+config VFIO_VIRQFD
+       tristate
+       depends on VFIO && EVENTFD
+       default n
+
 menuconfig VFIO
        tristate "VFIO Non-Privileged userspace driver framework"
        depends on IOMMU_API
index d798b0959603f0ea1b3eaf05b6d00628a8869c95..7b8a31f63fea81487fed01224d978c0804f02faf 100644 (file)
@@ -1,6 +1,7 @@
-vfio_core-y := vfio.o virqfd.o
+vfio_virqfd-y := virqfd.o
 
-obj-$(CONFIG_VFIO) += vfio_core.o
+obj-$(CONFIG_VFIO) += vfio.o
+obj-$(CONFIG_VFIO_VIRQFD) += vfio_virqfd.o
 obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o
 obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o
 obj-$(CONFIG_VFIO_SPAPR_EEH) += vfio_spapr_eeh.o
index c6bb5da2d2a7183307b62e5a50e18e759ea2ee94..579d83bf53583f53966a01bd299e4f31a08c2bd7 100644 (file)
@@ -1,6 +1,7 @@
 config VFIO_PCI
        tristate "VFIO support for PCI devices"
        depends on VFIO && PCI && EVENTFD
+       select VFIO_VIRQFD
        help
          Support for the PCI VFIO bus driver.  This is required to make
          use of PCI drivers using the VFIO framework.
index c0a3bff8baeef62c9246ffc01e09597ea5e123ae..9a4403e2a36c8164cd56acb1d4bb6f6132fbaea8 100644 (file)
@@ -1,6 +1,7 @@
 config VFIO_PLATFORM
        tristate "VFIO support for platform devices"
        depends on VFIO && EVENTFD && ARM
+       select VFIO_VIRQFD
        help
          Support for platform devices with VFIO. This is required to make
          use of platform devices present on the system using the VFIO
index 86aac7e4a05017c9b2ff8f8b737e2c843073d1e3..0d336625ac7113b0e0cc10d4a9d00283cc673766 100644 (file)
@@ -1552,11 +1552,6 @@ static int __init vfio_init(void)
        if (ret)
                goto err_cdev_add;
 
-       /* Start the virqfd cleanup handler used by some VFIO bus drivers */
-       ret = vfio_virqfd_init();
-       if (ret)
-               goto err_virqfd;
-
        pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
 
        /*
@@ -1569,8 +1564,6 @@ static int __init vfio_init(void)
 
        return 0;
 
-err_virqfd:
-       cdev_del(&vfio.group_cdev);
 err_cdev_add:
        unregister_chrdev_region(vfio.group_devt, MINORMASK);
 err_alloc_chrdev:
@@ -1585,7 +1578,6 @@ static void __exit vfio_cleanup(void)
 {
        WARN_ON(!list_empty(&vfio.group_list));
 
-       vfio_virqfd_exit();
        idr_destroy(&vfio.group_idr);
        cdev_del(&vfio.group_cdev);
        unregister_chrdev_region(vfio.group_devt, MINORMASK);
index 3d19aaf0e6c90447bb3b7500ab614dc4466fb188..27c89cd5d70b3c39ed16f64477009adf7dad70d7 100644 (file)
 #include <linux/vfio.h>
 #include <linux/eventfd.h>
 #include <linux/file.h>
+#include <linux/module.h>
 #include <linux/slab.h>
 
+#define DRIVER_VERSION  "0.1"
+#define DRIVER_AUTHOR   "Alex Williamson <alex.williamson@redhat.com>"
+#define DRIVER_DESC     "IRQFD support for VFIO bus drivers"
+
 static struct workqueue_struct *vfio_irqfd_cleanup_wq;
 static DEFINE_SPINLOCK(virqfd_lock);
 
-int __init vfio_virqfd_init(void)
+static int __init vfio_virqfd_init(void)
 {
        vfio_irqfd_cleanup_wq =
                create_singlethread_workqueue("vfio-irqfd-cleanup");
@@ -28,7 +33,7 @@ int __init vfio_virqfd_init(void)
        return 0;
 }
 
-void vfio_virqfd_exit(void)
+static void __exit vfio_virqfd_exit(void)
 {
        destroy_workqueue(vfio_irqfd_cleanup_wq);
 }
@@ -211,3 +216,11 @@ void vfio_virqfd_disable(struct virqfd **pvirqfd)
        flush_workqueue(vfio_irqfd_cleanup_wq);
 }
 EXPORT_SYMBOL_GPL(vfio_virqfd_disable);
+
+module_init(vfio_virqfd_init);
+module_exit(vfio_virqfd_exit);
+
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
index 683b5146022e10e1623287f68bb8709f4af2db55..cbed15f194e013a275d087235d88932d93376bcb 100644 (file)
@@ -142,8 +142,6 @@ struct virqfd {
        struct virqfd           **pvirqfd;
 };
 
-extern int vfio_virqfd_init(void);
-extern void vfio_virqfd_exit(void);
 extern int vfio_virqfd_enable(void *opaque,
                              int (*handler)(void *, void *),
                              void (*thread)(void *, void *),