From patchwork Tue Nov 3 18:12:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 55946 Delivered-To: patches@linaro.org Received: by 10.112.61.134 with SMTP id p6csp1979479lbr; Tue, 3 Nov 2015 10:12:27 -0800 (PST) X-Received: by 10.194.203.101 with SMTP id kp5mr29659505wjc.64.1446574347389; Tue, 03 Nov 2015 10:12:27 -0800 (PST) Return-Path: Received: from mail-wi0-x235.google.com (mail-wi0-x235.google.com. [2a00:1450:400c:c05::235]) by mx.google.com with ESMTPS id g18si29349691wmd.74.2015.11.03.10.12.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Nov 2015 10:12:27 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c05::235 as permitted sender) client-ip=2a00:1450:400c:c05::235; Authentication-Results: mx.google.com; spf=pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c05::235 as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dkim=pass header.i=@linaro_org.20150623.gappssmtp.com Received: by wicfx6 with SMTP id fx6so74821425wic.1 for ; Tue, 03 Nov 2015 10:12:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+H+BYrdl7R0PMgWQicvCjRT36HEIdMZaZExegW1s4ns=; b=VtTNabzjrdqJX7CEIhWOaNkL6I8CwyCot9wCAKUZtKwRIkhwgd95A70ALwxEJ6sNIw D6eQqVptnLVxb0Ff8a1BJm91HQxaPTkiRMIN2JJ8OlRRK/zov6YdiUORJ8YgoFgQQrV0 VbOt9YlUosMEGXwaD6PvXY7iHsYqPkhDDUZXxgkQ/dtbuI5F6sfqKGqprEseJyOgC0ig e2BtztuwI3rpm+pEZ7NzLozcseG5rWjZUlk1qIWs4ySCG5bpQRxUjjKf1aEFq/UmQZsN +AuMGu/DSpt6+P/AeWnt1t33akfXl5C4CUpZqSOB844kxlnYISKfIp3QROja11ryB4HH c4Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+H+BYrdl7R0PMgWQicvCjRT36HEIdMZaZExegW1s4ns=; b=KNNXEqvlb1FrQrUjX9LGPC6CdBmGO8faAgMpqMynwulvzEF+bbMbBEVYQuWLXleGIC dHu5CF9Uz1/BxAgQk2D4xJCfdGNvZhhaSMcDsDG2XeJd9h0WqkohOJhOjP1TmbsQy+oi WbkRu/TwLG6/H3kIKXjRrJyMJ6/DfQRjMnQhZiZcX1TvfACgi2AJfVw3Q2dFbXfrTsbD VCl8e0YxPaSkldnW5y2/lXIzNEURhJjYJrRNOh1muSxlSmmaf3M8WoGtX3aKeXo4CLU6 m19y0i4PdQaMDPbypdEcaGQ0RFSxIru51DGRi+MnhpfIKmFgqT6GlfwmrEBHRwE4d2c7 ki/g== X-Gm-Message-State: ALoCoQkuBnV9nnF7FcnhbSF3Fr0ZwGmBLI8SFfhszALcsOe/RCYP/2MBOXkd8HpkK7k675I+1/f2 X-Received: by 10.194.209.175 with SMTP id mn15mr31254098wjc.22.1446574347206; Tue, 03 Nov 2015 10:12:27 -0800 (PST) Return-Path: Received: from new-host-3.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id om1sm28830527wjc.2.2015.11.03.10.12.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Nov 2015 10:12:26 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, b.reynal@virtualopensystems.com, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: christoffer.dall@linaro.org, linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v6 1/8] vfio: platform: introduce vfio-platform-base module Date: Tue, 3 Nov 2015 18:12:12 +0000 Message-Id: <1446574339-1843-2-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1446574339-1843-1-git-send-email-eric.auger@linaro.org> References: <1446574339-1843-1-git-send-email-eric.auger@linaro.org> 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 Suggested-by: Arnd Bergmann Reviewed-by: Arnd Bergmann --- v3 -> v4: - add Arnd R-b v3: creation --- drivers/vfio/platform/Makefile | 6 ++++-- drivers/vfio/platform/vfio_amba.c | 1 + drivers/vfio/platform/vfio_platform.c | 1 + drivers/vfio/platform/vfio_platform_common.c | 13 +++++++++++-- drivers/vfio/platform/vfio_platform_private.h | 1 + 5 files changed, 18 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/vfio/platform/Makefile b/drivers/vfio/platform/Makefile index 9ce8afe..41a6224 100644 --- a/drivers/vfio/platform/Makefile +++ b/drivers/vfio/platform/Makefile @@ -1,10 +1,12 @@ - -vfio-platform-y := vfio_platform.o vfio_platform_common.o vfio_platform_irq.o +vfio-platform-base-y := 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-base.o obj-$(CONFIG_VFIO_PLATFORM) += reset/ vfio-amba-y := vfio_amba.o obj-$(CONFIG_VFIO_AMBA) += vfio-amba.o +obj-$(CONFIG_VFIO_AMBA) += vfio-platform-base.o obj-$(CONFIG_VFIO_AMBA) += reset/ diff --git a/drivers/vfio/platform/vfio_amba.c b/drivers/vfio/platform/vfio_amba.c index ff0331f..a66479b 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) vdev->flags = VFIO_DEVICE_FLAGS_AMBA; vdev->get_resource = get_amba_resource; vdev->get_irq = get_amba_irq; + vdev->parent_module = THIS_MODULE; ret = vfio_platform_probe_common(vdev, &adev->dev); if (ret) { diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c index cef645c..f1625dc 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) vdev->flags = VFIO_DEVICE_FLAGS_PLATFORM; vdev->get_resource = get_platform_resource; vdev->get_irq = get_platform_irq; + vdev->parent_module = THIS_MODULE; ret = vfio_platform_probe_common(vdev, &pdev->dev); if (ret) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index e43efb5..184e9d2 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -23,6 +23,10 @@ #include "vfio_platform_private.h" +#define DRIVER_VERSION "0.10" +#define DRIVER_AUTHOR "Antonios Motakis " +#define DRIVER_DESC "VFIO platform base module" + static DEFINE_MUTEX(driver_lock); static const struct vfio_platform_reset_combo reset_lookup_table[] = { @@ -146,7 +150,7 @@ static void vfio_platform_release(void *device_data) mutex_unlock(&driver_lock); - module_put(THIS_MODULE); + module_put(vdev->parent_module); } 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; int ret; - if (!try_module_get(THIS_MODULE)) + if (!try_module_get(vdev->parent_module)) return -ENODEV; mutex_lock(&driver_lock); @@ -573,3 +577,8 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev) return vdev; } EXPORT_SYMBOL_GPL(vfio_platform_remove_common); + +MODULE_VERSION(DRIVER_VERSION); +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR(DRIVER_AUTHOR); +MODULE_DESCRIPTION(DRIVER_DESC); diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index 1c9b3d5..7128690 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 { u32 num_irqs; int refcnt; struct mutex igate; + struct module *parent_module; /* * These fields should be filled by the bus specific binder