diff options
author | Eric Auger <eric.auger@linaro.org> | 2015-11-03 13:12:12 -0500 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2015-11-03 14:54:56 -0500 |
commit | 32a2d71c4e808b5aa6c414d4422b5e6c594c8805 (patch) | |
tree | 2caaf12628259257867f853f9e0d3c92c51217ad /drivers/vfio | |
parent | 1b4bb2eaa9b2583521611b4aa978f9f499c92cd4 (diff) |
vfio: platform: introduce vfio-platform-base module
To prepare for vfio platform reset rework let's build
vfio_platform_common.c and vfio_platform_irq.c in a separate
module from vfio-platform and vfio-amba. This makes possible
to have separate module inits and works around a race between
platform driver init and vfio reset module init: that way we
make sure symbols exported by base are available when vfio-platform
driver gets probed.
The open/release being implemented in the base module, the ref
count is applied to the parent module instead.
Signed-off-by: Eric Auger <eric.auger@linaro.org>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/platform/Makefile | 6 | ||||
-rw-r--r-- | drivers/vfio/platform/vfio_amba.c | 1 | ||||
-rw-r--r-- | drivers/vfio/platform/vfio_platform.c | 1 | ||||
-rw-r--r-- | drivers/vfio/platform/vfio_platform_common.c | 13 | ||||
-rw-r--r-- | drivers/vfio/platform/vfio_platform_private.h | 1 |
5 files changed, 18 insertions, 4 deletions
diff --git a/drivers/vfio/platform/Makefile b/drivers/vfio/platform/Makefile index 9ce8afe28450..41a6224f5e6b 100644 --- a/drivers/vfio/platform/Makefile +++ b/drivers/vfio/platform/Makefile | |||
@@ -1,10 +1,12 @@ | |||
1 | 1 | vfio-platform-base-y := vfio_platform_common.o vfio_platform_irq.o | |
2 | vfio-platform-y := vfio_platform.o vfio_platform_common.o vfio_platform_irq.o | 2 | vfio-platform-y := vfio_platform.o |
3 | 3 | ||
4 | obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o | 4 | obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o |
5 | obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform-base.o | ||
5 | obj-$(CONFIG_VFIO_PLATFORM) += reset/ | 6 | obj-$(CONFIG_VFIO_PLATFORM) += reset/ |
6 | 7 | ||
7 | vfio-amba-y := vfio_amba.o | 8 | vfio-amba-y := vfio_amba.o |
8 | 9 | ||
9 | obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o | 10 | obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o |
11 | obj-$(CONFIG_VFIO_AMBA) += vfio-platform-base.o | ||
10 | obj-$(CONFIG_VFIO_AMBA) += reset/ | 12 | obj-$(CONFIG_VFIO_AMBA) += reset/ |
diff --git a/drivers/vfio/platform/vfio_amba.c b/drivers/vfio/platform/vfio_amba.c index ff0331f72526..a66479bd0edf 100644 --- a/drivers/vfio/platform/vfio_amba.c +++ b/drivers/vfio/platform/vfio_amba.c | |||
@@ -67,6 +67,7 @@ static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id) | |||
67 | vdev->flags = VFIO_DEVICE_FLAGS_AMBA; | 67 | vdev->flags = VFIO_DEVICE_FLAGS_AMBA; |
68 | vdev->get_resource = get_amba_resource; | 68 | vdev->get_resource = get_amba_resource; |
69 | vdev->get_irq = get_amba_irq; | 69 | vdev->get_irq = get_amba_irq; |
70 | vdev->parent_module = THIS_MODULE; | ||
70 | 71 | ||
71 | ret = vfio_platform_probe_common(vdev, &adev->dev); | 72 | ret = vfio_platform_probe_common(vdev, &adev->dev); |
72 | if (ret) { | 73 | if (ret) { |
diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c index cef645c83996..f1625dcfbb23 100644 --- a/drivers/vfio/platform/vfio_platform.c +++ b/drivers/vfio/platform/vfio_platform.c | |||
@@ -65,6 +65,7 @@ static int vfio_platform_probe(struct platform_device *pdev) | |||
65 | vdev->flags = VFIO_DEVICE_FLAGS_PLATFORM; | 65 | vdev->flags = VFIO_DEVICE_FLAGS_PLATFORM; |
66 | vdev->get_resource = get_platform_resource; | 66 | vdev->get_resource = get_platform_resource; |
67 | vdev->get_irq = get_platform_irq; | 67 | vdev->get_irq = get_platform_irq; |
68 | vdev->parent_module = THIS_MODULE; | ||
68 | 69 | ||
69 | ret = vfio_platform_probe_common(vdev, &pdev->dev); | 70 | ret = vfio_platform_probe_common(vdev, &pdev->dev); |
70 | if (ret) | 71 | if (ret) |
diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 8c216de883e3..7f69b852c7e2 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c | |||
@@ -23,6 +23,10 @@ | |||
23 | 23 | ||
24 | #include "vfio_platform_private.h" | 24 | #include "vfio_platform_private.h" |
25 | 25 | ||
26 | #define DRIVER_VERSION "0.10" | ||
27 | #define DRIVER_AUTHOR "Antonios Motakis <a.motakis@virtualopensystems.com>" | ||
28 | #define DRIVER_DESC "VFIO platform base module" | ||
29 | |||
26 | static DEFINE_MUTEX(driver_lock); | 30 | static DEFINE_MUTEX(driver_lock); |
27 | 31 | ||
28 | static const struct vfio_platform_reset_combo reset_lookup_table[] = { | 32 | static const struct vfio_platform_reset_combo reset_lookup_table[] = { |
@@ -146,7 +150,7 @@ static void vfio_platform_release(void *device_data) | |||
146 | 150 | ||
147 | mutex_unlock(&driver_lock); | 151 | mutex_unlock(&driver_lock); |
148 | 152 | ||
149 | module_put(THIS_MODULE); | 153 | module_put(vdev->parent_module); |
150 | } | 154 | } |
151 | 155 | ||
152 | static int vfio_platform_open(void *device_data) | 156 | static int vfio_platform_open(void *device_data) |
@@ -154,7 +158,7 @@ static int vfio_platform_open(void *device_data) | |||
154 | struct vfio_platform_device *vdev = device_data; | 158 | struct vfio_platform_device *vdev = device_data; |
155 | int ret; | 159 | int ret; |
156 | 160 | ||
157 | if (!try_module_get(THIS_MODULE)) | 161 | if (!try_module_get(vdev->parent_module)) |
158 | return -ENODEV; | 162 | return -ENODEV; |
159 | 163 | ||
160 | mutex_lock(&driver_lock); | 164 | mutex_lock(&driver_lock); |
@@ -573,3 +577,8 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev) | |||
573 | return vdev; | 577 | return vdev; |
574 | } | 578 | } |
575 | EXPORT_SYMBOL_GPL(vfio_platform_remove_common); | 579 | EXPORT_SYMBOL_GPL(vfio_platform_remove_common); |
580 | |||
581 | MODULE_VERSION(DRIVER_VERSION); | ||
582 | MODULE_LICENSE("GPL v2"); | ||
583 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
584 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index 1c9b3d59543c..71286903fb49 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h | |||
@@ -56,6 +56,7 @@ struct vfio_platform_device { | |||
56 | u32 num_irqs; | 56 | u32 num_irqs; |
57 | int refcnt; | 57 | int refcnt; |
58 | struct mutex igate; | 58 | struct mutex igate; |
59 | struct module *parent_module; | ||
59 | 60 | ||
60 | /* | 61 | /* |
61 | * These fields should be filled by the bus specific binder | 62 | * These fields should be filled by the bus specific binder |