Commit 32a2d71c authored by Eric Auger's avatar Eric Auger Committed by Alex Williamson

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: default avatarEric Auger <eric.auger@linaro.org>
Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 1b4bb2ea
vfio-platform-base-y := vfio_platform_common.o vfio_platform_irq.o
vfio-platform-y := vfio_platform.o vfio_platform_common.o vfio_platform_irq.o vfio-platform-y := vfio_platform.o
obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform.o
obj-$(CONFIG_VFIO_PLATFORM) += vfio-platform-base.o
obj-$(CONFIG_VFIO_PLATFORM) += reset/ obj-$(CONFIG_VFIO_PLATFORM) += reset/
vfio-amba-y := vfio_amba.o vfio-amba-y := vfio_amba.o
obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o
obj-$(CONFIG_VFIO_AMBA) += vfio-platform-base.o
obj-$(CONFIG_VFIO_AMBA) += reset/ obj-$(CONFIG_VFIO_AMBA) += reset/
...@@ -67,6 +67,7 @@ static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -67,6 +67,7 @@ static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id)
vdev->flags = VFIO_DEVICE_FLAGS_AMBA; vdev->flags = VFIO_DEVICE_FLAGS_AMBA;
vdev->get_resource = get_amba_resource; vdev->get_resource = get_amba_resource;
vdev->get_irq = get_amba_irq; vdev->get_irq = get_amba_irq;
vdev->parent_module = THIS_MODULE;
ret = vfio_platform_probe_common(vdev, &adev->dev); ret = vfio_platform_probe_common(vdev, &adev->dev);
if (ret) { if (ret) {
......
...@@ -65,6 +65,7 @@ static int vfio_platform_probe(struct platform_device *pdev) ...@@ -65,6 +65,7 @@ static int vfio_platform_probe(struct platform_device *pdev)
vdev->flags = VFIO_DEVICE_FLAGS_PLATFORM; vdev->flags = VFIO_DEVICE_FLAGS_PLATFORM;
vdev->get_resource = get_platform_resource; vdev->get_resource = get_platform_resource;
vdev->get_irq = get_platform_irq; vdev->get_irq = get_platform_irq;
vdev->parent_module = THIS_MODULE;
ret = vfio_platform_probe_common(vdev, &pdev->dev); ret = vfio_platform_probe_common(vdev, &pdev->dev);
if (ret) if (ret)
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
#include "vfio_platform_private.h" #include "vfio_platform_private.h"
#define DRIVER_VERSION "0.10"
#define DRIVER_AUTHOR "Antonios Motakis <a.motakis@virtualopensystems.com>"
#define DRIVER_DESC "VFIO platform base module"
static DEFINE_MUTEX(driver_lock); static DEFINE_MUTEX(driver_lock);
static const struct vfio_platform_reset_combo reset_lookup_table[] = { static const struct vfio_platform_reset_combo reset_lookup_table[] = {
...@@ -146,7 +150,7 @@ static void vfio_platform_release(void *device_data) ...@@ -146,7 +150,7 @@ static void vfio_platform_release(void *device_data)
mutex_unlock(&driver_lock); mutex_unlock(&driver_lock);
module_put(THIS_MODULE); module_put(vdev->parent_module);
} }
static int vfio_platform_open(void *device_data) static int vfio_platform_open(void *device_data)
...@@ -154,7 +158,7 @@ static int vfio_platform_open(void *device_data) ...@@ -154,7 +158,7 @@ static int vfio_platform_open(void *device_data)
struct vfio_platform_device *vdev = device_data; struct vfio_platform_device *vdev = device_data;
int ret; int ret;
if (!try_module_get(THIS_MODULE)) if (!try_module_get(vdev->parent_module))
return -ENODEV; return -ENODEV;
mutex_lock(&driver_lock); mutex_lock(&driver_lock);
...@@ -573,3 +577,8 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev) ...@@ -573,3 +577,8 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
return vdev; return vdev;
} }
EXPORT_SYMBOL_GPL(vfio_platform_remove_common); EXPORT_SYMBOL_GPL(vfio_platform_remove_common);
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
...@@ -56,6 +56,7 @@ struct vfio_platform_device { ...@@ -56,6 +56,7 @@ struct vfio_platform_device {
u32 num_irqs; u32 num_irqs;
int refcnt; int refcnt;
struct mutex igate; struct mutex igate;
struct module *parent_module;
/* /*
* These fields should be filled by the bus specific binder * These fields should be filled by the bus specific binder
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment