From d88423f7844ea9941d55bde92716a50c3e131dd7 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Wed, 8 Feb 2017 13:13:25 -0700 Subject: vfio: Fix build break when SPAPR_TCE_IOMMU=n Currently the kconfig logic for VFIO_IOMMU_SPAPR_TCE and VFIO_SPAPR_EEH is broken when SPAPR_TCE_IOMMU=n. Leading to: warning: (VFIO) selects VFIO_IOMMU_SPAPR_TCE which has unmet direct dependencies (VFIO && SPAPR_TCE_IOMMU) warning: (VFIO) selects VFIO_IOMMU_SPAPR_TCE which has unmet direct dependencies (VFIO && SPAPR_TCE_IOMMU) drivers/vfio/vfio_iommu_spapr_tce.c:113:8: error: implicit declaration of function 'mm_iommu_find' This stems from the fact that VFIO selects VFIO_IOMMU_SPAPR_TCE, and although it has an if clause, the condition is not correct. We could fix it by doing select VFIO_IOMMU_SPAPR_TCE if SPAPR_TCE_IOMMU, but the cleaner fix is to drop the selects and tie VFIO_IOMMU_SPAPR_TCE to the value of VFIO, and express the dependencies in only once place. Do the same for VFIO_SPAPR_EEH. The end result is that the values of VFIO_IOMMU_SPAPR_TCE and VFIO_SPAPR_EEH follow the value of VFIO, except when SPAPR_TCE_IOMMU=n and/or EEH=n. Which is exactly what we want to happen. Signed-off-by: Michael Ellerman Signed-off-by: Alex Williamson --- drivers/vfio/Kconfig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/vfio') diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig index 23eced02aaf6..c84333eb5eb5 100644 --- a/drivers/vfio/Kconfig +++ b/drivers/vfio/Kconfig @@ -6,12 +6,12 @@ config VFIO_IOMMU_TYPE1 config VFIO_IOMMU_SPAPR_TCE tristate depends on VFIO && SPAPR_TCE_IOMMU - default n + default VFIO config VFIO_SPAPR_EEH tristate depends on EEH && VFIO_IOMMU_SPAPR_TCE - default n + default VFIO config VFIO_VIRQFD tristate @@ -22,8 +22,6 @@ menuconfig VFIO tristate "VFIO Non-Privileged userspace driver framework" depends on IOMMU_API select VFIO_IOMMU_TYPE1 if (X86 || S390 || ARM_SMMU || ARM_SMMU_V3) - select VFIO_IOMMU_SPAPR_TCE if (PPC_POWERNV || PPC_PSERIES) - select VFIO_SPAPR_EEH if (PPC_POWERNV || PPC_PSERIES) select ANON_INODES help VFIO provides a framework for secure userspace device drivers. -- cgit v1.2.3 From f790eb57e6ec8d77489755cc25a51c4409e2f590 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Wed, 8 Feb 2017 13:13:25 -0700 Subject: vfio/mdev: Use a module softdep for vfio_mdev Use an explicit module softdep rather than a request module call such that the dependency is exposed to userspace. This allows us to more easily support modules loaded at initrd time. Reviewed by: Kirti Wankhede Signed-off-by: Alex Williamson --- drivers/vfio/mdev/mdev_core.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers/vfio') diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index 36d75c367d22..126991046eb7 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c @@ -422,18 +422,7 @@ int mdev_device_remove(struct device *dev, bool force_remove) static int __init mdev_init(void) { - int ret; - - ret = mdev_bus_register(); - - /* - * Attempt to load known vfio_mdev. This gives us a working environment - * without the user needing to explicitly load vfio_mdev driver. - */ - if (!ret) - request_module_nowait("vfio_mdev"); - - return ret; + return mdev_bus_register(); } static void __exit mdev_exit(void) @@ -451,3 +440,4 @@ MODULE_VERSION(DRIVER_VERSION); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_SOFTDEP("post: vfio_mdev"); -- cgit v1.2.3 From 0ca582fd0463106e277e1f723b4554b4d0e5f700 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Wed, 8 Feb 2017 13:13:26 -0700 Subject: vfio: Replace module request with softdep Rather than doing a module request from within the init function, add a soft dependency on the available IOMMU backend drivers. This makes the dependency visible to userspace when picking modules for the ram disk. Signed-off-by: Alex Williamson --- drivers/vfio/vfio.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'drivers/vfio') diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 9901c4671e2f..57052b68f15a 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -2250,14 +2250,6 @@ static int __init vfio_init(void) pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); - /* - * Attempt to load known iommu-drivers. This gives us a working - * environment without the user needing to explicitly load iommu - * drivers. - */ - request_module_nowait("vfio_iommu_type1"); - request_module_nowait("vfio_iommu_spapr_tce"); - #ifdef CONFIG_VFIO_NOIOMMU vfio_register_iommu_driver(&vfio_noiommu_ops); #endif @@ -2297,3 +2289,4 @@ MODULE_AUTHOR(DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_ALIAS_MISCDEV(VFIO_MINOR); MODULE_ALIAS("devname:vfio/vfio"); +MODULE_SOFTDEP("post: vfio_iommu_type1 vfio_iommu_spapr_tce"); -- cgit v1.2.3 From d9d84780f17cd9e25ddde10eb40357b96b7d6874 Mon Sep 17 00:00:00 2001 From: Changbin Du Date: Mon, 6 Feb 2017 15:03:37 +0800 Subject: vfio: fix a typo in comment of function vfio_pin_pages Correct the description that 'unpinned' -> 'pinned'. Signed-off-by: Changbin Du Signed-off-by: Alex Williamson --- drivers/vfio/vfio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/vfio') diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 57052b68f15a..609f4f982c74 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1917,7 +1917,7 @@ EXPORT_SYMBOL(vfio_set_irqs_validate_and_prepare); * Pin a set of guest PFNs and return their associated host PFNs for local * domain only. * @dev [in] : device - * @user_pfn [in]: array of user/guest PFNs to be unpinned. + * @user_pfn [in]: array of user/guest PFNs to be pinned. * @npage [in] : count of elements in user_pfn array. This count should not * be greater VFIO_PIN_PAGES_MAX_ENTRIES. * @prot [in] : protection flags -- cgit v1.2.3