From: Liviu Dudau <Liviu.Dudau@arm.com>
To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: Magnus Damm <damm+renesas@opensource.se>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Shawn Lin <shawn.lin@rock-chips.com>,
Joerg Roedel <joro@8bytes.org>,
IOMMU ML <iommu@lists.linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init.
Date: Mon, 18 Sep 2017 11:04:44 +0100 [thread overview]
Message-ID: <20170918100444.21878-1-Liviu.Dudau@arm.com> (raw)
If the IPMMU driver is compiled in the kernel it will replace the
platform bus IOMMU ops on running the ipmmu_init() function, regardless
if there is any IPMMU hardware present or not. This screws up systems
that just want to build a generic kernel that runs on multiple platforms
and use a different IOMMU implementation.
Move the bus_set_iommu() call at the end of the ipmmu_probe() function
when we know that hardware is present. With current IOMMU framework it
should be safe (at least for OF case).
Now that the ipmmu_init() and ipmmu_exit() functions are simple calls to
platform_driver_register() and platform_driver_unregister(), replace
them with the module_platform_driver() macro call.
Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
drivers/iommu/ipmmu-vmsa.c | 29 +++++------------------------
1 file changed, 5 insertions(+), 24 deletions(-)
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 2a38aa15be17d..c60569c74678d 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1055,10 +1055,11 @@ static int ipmmu_probe(struct platform_device *pdev)
ipmmu_device_reset(mmu);
/*
- * We can't create the ARM mapping here as it requires the bus to have
- * an IOMMU, which only happens when bus_set_iommu() is called in
- * ipmmu_init() after the probe function returns.
+ * Now that we have validated the presence of the hardware, set
+ * the bus IOMMU ops to enable future domain and device setup.
*/
+ if (!iommu_present(&platform_bus_type))
+ bus_set_iommu(&platform_bus_type, &ipmmu_ops);
spin_lock(&ipmmu_devices_lock);
list_add(&mmu->list, &ipmmu_devices);
@@ -1100,27 +1101,7 @@ static struct platform_driver ipmmu_driver = {
.remove = ipmmu_remove,
};
-static int __init ipmmu_init(void)
-{
- int ret;
-
- ret = platform_driver_register(&ipmmu_driver);
- if (ret < 0)
- return ret;
-
- if (!iommu_present(&platform_bus_type))
- bus_set_iommu(&platform_bus_type, &ipmmu_ops);
-
- return 0;
-}
-
-static void __exit ipmmu_exit(void)
-{
- return platform_driver_unregister(&ipmmu_driver);
-}
-
-subsys_initcall(ipmmu_init);
-module_exit(ipmmu_exit);
+module_platform_driver(ipmmu_driver);
MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
--
2.14.1
next reply other threads:[~2017-09-18 11:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-18 10:04 Liviu Dudau [this message]
2017-09-19 7:07 ` [PATCH] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init Laurent Pinchart
2017-09-19 9:45 ` Liviu Dudau
2017-09-19 10:47 ` Robin Murphy
2017-09-20 14:13 ` [PATCH v2] " Liviu Dudau
2017-10-13 15:48 ` Robin Murphy
2017-11-20 14:25 ` Liviu Dudau
2017-11-20 22:01 ` Alex Williamson
2017-11-21 12:08 ` Liviu Dudau
2017-11-21 14:02 ` [PATCH] iommu/ipmmu-vmsa: Simplify driver probing Liviu Dudau
2017-11-21 17:21 ` [PATCH v2] iommu/ipmmu-vmsa: Do not replace bus IOMMU ops on driver init Alex Williamson
2017-11-21 17:26 ` Liviu Dudau
2017-11-21 12:59 ` Robin Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170918100444.21878-1-Liviu.Dudau@arm.com \
--to=liviu.dudau@arm.com \
--cc=damm+renesas@opensource.se \
--cc=geert+renesas@glider.be \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=shawn.lin@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).