* [PATCH 2/9] iommu: rockchip: make it explicitly non-modular
2018-11-26 22:31 [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules Paul Gortmaker
@ 2018-11-26 22:31 ` Paul Gortmaker
2018-11-26 23:37 ` Heiko Stuebner
2018-11-26 22:31 ` [PATCH 8/9] iommu: arm-smmu: " Paul Gortmaker
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Paul Gortmaker @ 2018-11-26 22:31 UTC (permalink / raw)
To: linux-arm-kernel
The Kconfig currently controlling compilation of this code is:
drivers/iommu/Kconfig:config ROCKCHIP_IOMMU
drivers/iommu/Kconfig: bool "Rockchip IOMMU Support"
...meaning that it currently is not being built as a module by anyone.
The bind/unbind/remove was already explicitly disabled in commit
98b72b94def9 ("iommu/rockchip: Prohibit unbind and remove").
Lets remove the remaining traces of modular infrastructure, so that
when reading the driver there is no doubt it is builtin-only.
Since module_init was not in use by this code, the init ordering
remains unchanged with this commit.
Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
We also delete the MODULE_LICENSE tag etc. since all that information
was (or is now) contained at the top of the file in the comments.
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Simon Xue <xxm@rock-chips.com>
Cc: Daniel Kurtz <djkurtz@chromium.org>
Cc: Jeffy Chen <jeffy.chen@rock-chips.com>
Cc: iommu at lists.linux-foundation.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
drivers/iommu/rockchip-iommu.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index ad3e2b97469e..c9ba9f377f63 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -1,4 +1,9 @@
/*
+ * IOMMU API for Rockchip
+ *
+ * Module Authors: Simon Xue <xxm@rock-chips.com>
+ * Daniel Kurtz <djkurtz@chromium.org>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
@@ -17,7 +22,7 @@
#include <linux/iopoll.h>
#include <linux/list.h>
#include <linux/mm.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_iommu.h>
#include <linux/of_platform.h>
@@ -1281,7 +1286,6 @@ static const struct of_device_id rk_iommu_dt_ids[] = {
{ .compatible = "rockchip,iommu" },
{ /* sentinel */ }
};
-MODULE_DEVICE_TABLE(of, rk_iommu_dt_ids);
static struct platform_driver rk_iommu_driver = {
.probe = rk_iommu_probe,
@@ -1299,8 +1303,3 @@ static int __init rk_iommu_init(void)
return platform_driver_register(&rk_iommu_driver);
}
subsys_initcall(rk_iommu_init);
-
-MODULE_DESCRIPTION("IOMMU API for Rockchip");
-MODULE_AUTHOR("Simon Xue <xxm@rock-chips.com> and Daniel Kurtz <djkurtz@chromium.org>");
-MODULE_ALIAS("platform:rockchip-iommu");
-MODULE_LICENSE("GPL v2");
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/9] iommu: rockchip: make it explicitly non-modular
2018-11-26 22:31 ` [PATCH 2/9] iommu: rockchip: make it explicitly non-modular Paul Gortmaker
@ 2018-11-26 23:37 ` Heiko Stuebner
0 siblings, 0 replies; 11+ messages in thread
From: Heiko Stuebner @ 2018-11-26 23:37 UTC (permalink / raw)
To: linux-arm-kernel
Am Montag, 26. November 2018, 23:31:31 CET schrieb Paul Gortmaker:
> The Kconfig currently controlling compilation of this code is:
>
> drivers/iommu/Kconfig:config ROCKCHIP_IOMMU
> drivers/iommu/Kconfig: bool "Rockchip IOMMU Support"
>
> ...meaning that it currently is not being built as a module by anyone.
>
> The bind/unbind/remove was already explicitly disabled in commit
> 98b72b94def9 ("iommu/rockchip: Prohibit unbind and remove").
>
> Lets remove the remaining traces of modular infrastructure, so that
> when reading the driver there is no doubt it is builtin-only.
>
> Since module_init was not in use by this code, the init ordering
> remains unchanged with this commit.
>
> Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
>
> We also delete the MODULE_LICENSE tag etc. since all that information
> was (or is now) contained at the top of the file in the comments.
>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Heiko Stuebner <heiko@sntech.de>
> Cc: Simon Xue <xxm@rock-chips.com>
> Cc: Daniel Kurtz <djkurtz@chromium.org>
> Cc: Jeffy Chen <jeffy.chen@rock-chips.com>
> Cc: iommu at lists.linux-foundation.org
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: linux-rockchip at lists.infradead.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 8/9] iommu: arm-smmu: make it explicitly non-modular
2018-11-26 22:31 [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules Paul Gortmaker
2018-11-26 22:31 ` [PATCH 2/9] iommu: rockchip: make it explicitly non-modular Paul Gortmaker
@ 2018-11-26 22:31 ` Paul Gortmaker
2018-11-28 12:42 ` Robin Murphy
2018-11-26 22:31 ` [PATCH 9/9] iommu: arm-smmu-v3: " Paul Gortmaker
2018-11-27 10:11 ` [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules Joerg Roedel
3 siblings, 1 reply; 11+ messages in thread
From: Paul Gortmaker @ 2018-11-26 22:31 UTC (permalink / raw)
To: linux-arm-kernel
The Kconfig currently controlling compilation of this code is:
drivers/iommu/Kconfig:config ARM_SMMU
drivers/iommu/Kconfig: bool "ARM Ltd. System MMU (SMMU) Support"
...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.
Since module_platform_driver() uses the same init level priority as
builtin_platform_driver() the init ordering remains unchanged with
this commit.
We explicitly disallow a driver unbind, since that doesn't have a
sensible use case anyway, but unlike most drivers, we can't delete the
function tied to the ".remove" field. This is because as of commit
7aa8619a66ae ("iommu/arm-smmu-v3: Implement shutdown method") the
.remove function was given a one line wrapper and re-used to provide a
.shutdown service. So we delete the wrapper and re-name the function
from remove to shutdown.
We add a moduleparam.h include since the file does actually declare
some module parameters, and leaving them as such is the easiest way
currently to remain backwards compatible with existing use cases.
We also delete the MODULE_LICENSE tag etc. since all that information
is already contained at the top of the file in the comments.
Cc: Will Deacon <will.deacon@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Nate Watterson <nwatters@codeaurora.org>
Cc: linux-arm-kernel at lists.infradead.org
Cc: iommu at lists.linux-foundation.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
drivers/iommu/arm-smmu.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 5a28ae892504..4a2e143fdf52 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -41,7 +41,8 @@
#include <linux/io-64-nonatomic-hi-lo.h>
#include <linux/iommu.h>
#include <linux/iopoll.h>
-#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/moduleparam.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
@@ -101,6 +102,10 @@
#define MSI_IOVA_LENGTH 0x100000
static int force_stage;
+/*
+ * not really modular, but the easiest way to keep compat with existing
+ * bootargs behaviour is to continue using module_param() here.
+ */
module_param(force_stage, int, S_IRUGO);
MODULE_PARM_DESC(force_stage,
"Force SMMU mappings to be installed at a particular stage of translation. A value of '1' or '2' forces the corresponding stage. All other values are ignored (i.e. no stage is forced). Note that selecting a specific stage will disable support for nested translation.");
@@ -1964,7 +1969,6 @@ static const struct of_device_id arm_smmu_of_match[] = {
{ .compatible = "cavium,smmu-v2", .data = &cavium_smmuv2 },
{ },
};
-MODULE_DEVICE_TABLE(of, arm_smmu_of_match);
#ifdef CONFIG_ACPI
static int acpi_smmu_get_data(u32 model, struct arm_smmu_device *smmu)
@@ -2224,24 +2228,18 @@ static int arm_smmu_legacy_bus_init(void)
}
device_initcall_sync(arm_smmu_legacy_bus_init);
-static int arm_smmu_device_remove(struct platform_device *pdev)
+static void arm_smmu_device_shutdown(struct platform_device *pdev)
{
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
if (!smmu)
- return -ENODEV;
+ return;
if (!bitmap_empty(smmu->context_map, ARM_SMMU_MAX_CBS))
dev_err(&pdev->dev, "removing device with active domains!\n");
/* Turn the thing off */
writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0);
- return 0;
-}
-
-static void arm_smmu_device_shutdown(struct platform_device *pdev)
-{
- arm_smmu_device_remove(pdev);
}
static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
@@ -2256,16 +2254,12 @@ static SIMPLE_DEV_PM_OPS(arm_smmu_pm_ops, NULL, arm_smmu_pm_resume);
static struct platform_driver arm_smmu_driver = {
.driver = {
- .name = "arm-smmu",
- .of_match_table = of_match_ptr(arm_smmu_of_match),
- .pm = &arm_smmu_pm_ops,
+ .name = "arm-smmu",
+ .of_match_table = of_match_ptr(arm_smmu_of_match),
+ .pm = &arm_smmu_pm_ops,
+ .suppress_bind_attrs = true,
},
.probe = arm_smmu_device_probe,
- .remove = arm_smmu_device_remove,
.shutdown = arm_smmu_device_shutdown,
};
-module_platform_driver(arm_smmu_driver);
-
-MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations");
-MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");
-MODULE_LICENSE("GPL v2");
+builtin_platform_driver(arm_smmu_driver);
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 8/9] iommu: arm-smmu: make it explicitly non-modular
2018-11-26 22:31 ` [PATCH 8/9] iommu: arm-smmu: " Paul Gortmaker
@ 2018-11-28 12:42 ` Robin Murphy
2018-11-28 15:24 ` Paul Gortmaker
0 siblings, 1 reply; 11+ messages in thread
From: Robin Murphy @ 2018-11-28 12:42 UTC (permalink / raw)
To: linux-arm-kernel
Hi Paul,
On 26/11/2018 22:31, Paul Gortmaker wrote:
> The Kconfig currently controlling compilation of this code is:
>
> drivers/iommu/Kconfig:config ARM_SMMU
> drivers/iommu/Kconfig: bool "ARM Ltd. System MMU (SMMU) Support"
>
> ...meaning that it currently is not being built as a module by anyone.
>
> Lets remove the modular code that is essentially orphaned, so that
> when reading the driver there is no doubt it is builtin-only.
>
> Since module_platform_driver() uses the same init level priority as
> builtin_platform_driver() the init ordering remains unchanged with
> this commit.
>
> We explicitly disallow a driver unbind, since that doesn't have a
> sensible use case anyway, but unlike most drivers, we can't delete the
> function tied to the ".remove" field. This is because as of commit
> 7aa8619a66ae ("iommu/arm-smmu-v3: Implement shutdown method") the
> .remove function was given a one line wrapper and re-used to provide a
> .shutdown service. So we delete the wrapper and re-name the function
> from remove to shutdown.
>
> We add a moduleparam.h include since the file does actually declare
> some module parameters, and leaving them as such is the easiest way
> currently to remain backwards compatible with existing use cases.
>
> We also delete the MODULE_LICENSE tag etc. since all that information
> is already contained at the top of the file in the comments.
>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Nate Watterson <nwatters@codeaurora.org>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: iommu at lists.linux-foundation.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> ---
> drivers/iommu/arm-smmu.c | 32 +++++++++++++-------------------
> 1 file changed, 13 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
> index 5a28ae892504..4a2e143fdf52 100644
> --- a/drivers/iommu/arm-smmu.c
> +++ b/drivers/iommu/arm-smmu.c
> @@ -41,7 +41,8 @@
> #include <linux/io-64-nonatomic-hi-lo.h>
> #include <linux/iommu.h>
> #include <linux/iopoll.h>
> -#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/moduleparam.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/of_device.h>
> @@ -101,6 +102,10 @@
> #define MSI_IOVA_LENGTH 0x100000
>
> static int force_stage;
> +/*
> + * not really modular, but the easiest way to keep compat with existing
> + * bootargs behaviour is to continue using module_param() here.
> + */
Is it worth introducing builtin_param() and friends for this sort of
thing, to echo the *_platform_driver() helpers? It seems like that could
be justifiable under the motivation described in the cover letter.
Otherwise, the changes look reasonable. I still hold out hope that one
day we'll be able to make IOMMU drivers modular (it can work with
minimal hacks today, but it's far from robust in general), but for now I
agree this makes sense (and it'll be easy enough to revert for playing
with further hacks). With the title fixed up as Joerg asked,
Acked-by: Robin Murphy <robin.murphy@arm.com>
> module_param(force_stage, int, S_IRUGO);
> MODULE_PARM_DESC(force_stage,
> "Force SMMU mappings to be installed at a particular stage of translation. A value of '1' or '2' forces the corresponding stage. All other values are ignored (i.e. no stage is forced). Note that selecting a specific stage will disable support for nested translation.");
> @@ -1964,7 +1969,6 @@ static const struct of_device_id arm_smmu_of_match[] = {
> { .compatible = "cavium,smmu-v2", .data = &cavium_smmuv2 },
> { },
> };
> -MODULE_DEVICE_TABLE(of, arm_smmu_of_match);
>
> #ifdef CONFIG_ACPI
> static int acpi_smmu_get_data(u32 model, struct arm_smmu_device *smmu)
> @@ -2224,24 +2228,18 @@ static int arm_smmu_legacy_bus_init(void)
> }
> device_initcall_sync(arm_smmu_legacy_bus_init);
>
> -static int arm_smmu_device_remove(struct platform_device *pdev)
> +static void arm_smmu_device_shutdown(struct platform_device *pdev)
> {
> struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
>
> if (!smmu)
> - return -ENODEV;
> + return;
>
> if (!bitmap_empty(smmu->context_map, ARM_SMMU_MAX_CBS))
> dev_err(&pdev->dev, "removing device with active domains!\n");
>
> /* Turn the thing off */
> writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0);
> - return 0;
> -}
> -
> -static void arm_smmu_device_shutdown(struct platform_device *pdev)
> -{
> - arm_smmu_device_remove(pdev);
> }
>
> static int __maybe_unused arm_smmu_pm_resume(struct device *dev)
> @@ -2256,16 +2254,12 @@ static SIMPLE_DEV_PM_OPS(arm_smmu_pm_ops, NULL, arm_smmu_pm_resume);
>
> static struct platform_driver arm_smmu_driver = {
> .driver = {
> - .name = "arm-smmu",
> - .of_match_table = of_match_ptr(arm_smmu_of_match),
> - .pm = &arm_smmu_pm_ops,
> + .name = "arm-smmu",
> + .of_match_table = of_match_ptr(arm_smmu_of_match),
> + .pm = &arm_smmu_pm_ops,
> + .suppress_bind_attrs = true,
> },
> .probe = arm_smmu_device_probe,
> - .remove = arm_smmu_device_remove,
> .shutdown = arm_smmu_device_shutdown,
> };
> -module_platform_driver(arm_smmu_driver);
> -
> -MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations");
> -MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");
> -MODULE_LICENSE("GPL v2");
> +builtin_platform_driver(arm_smmu_driver);
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 8/9] iommu: arm-smmu: make it explicitly non-modular
2018-11-28 12:42 ` Robin Murphy
@ 2018-11-28 15:24 ` Paul Gortmaker
2018-11-28 17:28 ` Robin Murphy
0 siblings, 1 reply; 11+ messages in thread
From: Paul Gortmaker @ 2018-11-28 15:24 UTC (permalink / raw)
To: linux-arm-kernel
[Re: [PATCH 8/9] iommu: arm-smmu: make it explicitly non-modular] On 28/11/2018 (Wed 12:42) Robin Murphy wrote:
> Hi Paul,
>
> On 26/11/2018 22:31, Paul Gortmaker wrote:
[...]
> >We add a moduleparam.h include since the file does actually declare
> >some module parameters, and leaving them as such is the easiest way
> >currently to remain backwards compatible with existing use cases.
[...]
> Is it worth introducing builtin_param() and friends for this sort of thing,
> to echo the *_platform_driver() helpers? It seems like that could be
> justifiable under the motivation described in the cover letter.
I've definitely gone back and looked at this a few times when coming
across the few corner cases like these, to remind myself why I didn't do
it already.
We'd not want to replicate all the module_param stuff as an instance of
builtin_param() because we already have setup() and setup_param() in
init.h -- however they don't do the file name in the param - hence the
reason it isn't a direct swap in replacement.
So, it would become some more complex refactoring of moduleparam.h into
say bootparam.h - to reduce code/macro duplication, while at the same
time being aware of existing setup_param stuff and making something like
a new setup_param_named() that is consistent with existing setup fcns.
And based on past experience, there will be reviewers who don't see the
value in the distinction and simply reply with two words "why bother?".
Not impossible, but not as simple as the builtin_platform_driver and
similar wrappers that I've already added to mainline. You've made we
want to go have another look at it again, but in the meantime we can do
what I've done here, and circle around later to update the few instances
of moduleparam in non-modules once/if the refactoring I describe above
works out and is accepted in mainline.
>
> Otherwise, the changes look reasonable. I still hold out hope that one day
> we'll be able to make IOMMU drivers modular (it can work with minimal hacks
> today, but it's far from robust in general), but for now I agree this makes
> sense (and it'll be easy enough to revert for playing with further hacks).
I totally agree - I've had similar discussions with the DMA maintainers,
and if being modular can be made to work and has a use case - great!
But it should be a conscious decision, since nobody writes a new driver
from scratch; they copy one that is "close" as a template and then go
from there. Which leads to a good percentage of drivers having hints
of modular stuff when there is no intent of them ever being modular.
> With the title fixed up as Joerg asked,
>
> Acked-by: Robin Murphy <robin.murphy@arm.com>
Thanks for the feedback/review. Will re-send with updated titles before
the week is finished and a good chance for additional feedback has elapsed.
Paul.
--
>
> > module_param(force_stage, int, S_IRUGO);
> > MODULE_PARM_DESC(force_stage,
> > "Force SMMU mappings to be installed at a particular stage of translation. A value of '1' or '2' forces the corresponding stage. All other values are ignored (i.e. no stage is forced). Note that selecting a specific stage will disable support for nested translation.");
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 8/9] iommu: arm-smmu: make it explicitly non-modular
2018-11-28 15:24 ` Paul Gortmaker
@ 2018-11-28 17:28 ` Robin Murphy
0 siblings, 0 replies; 11+ messages in thread
From: Robin Murphy @ 2018-11-28 17:28 UTC (permalink / raw)
To: linux-arm-kernel
On 28/11/2018 15:24, Paul Gortmaker wrote:
> [Re: [PATCH 8/9] iommu: arm-smmu: make it explicitly non-modular] On 28/11/2018 (Wed 12:42) Robin Murphy wrote:
>
>> Hi Paul,
>>
>> On 26/11/2018 22:31, Paul Gortmaker wrote:
>
> [...]
>
>>> We add a moduleparam.h include since the file does actually declare
>>> some module parameters, and leaving them as such is the easiest way
>>> currently to remain backwards compatible with existing use cases.
>
> [...]
>
>
>> Is it worth introducing builtin_param() and friends for this sort of thing,
>> to echo the *_platform_driver() helpers? It seems like that could be
>> justifiable under the motivation described in the cover letter.
>
> I've definitely gone back and looked at this a few times when coming
> across the few corner cases like these, to remind myself why I didn't do
> it already.
>
> We'd not want to replicate all the module_param stuff as an instance of
> builtin_param() because we already have setup() and setup_param() in
> init.h -- however they don't do the file name in the param - hence the
> reason it isn't a direct swap in replacement.
>
> So, it would become some more complex refactoring of moduleparam.h into
> say bootparam.h - to reduce code/macro duplication, while at the same
> time being aware of existing setup_param stuff and making something like
> a new setup_param_named() that is consistent with existing setup fcns.
>
> And based on past experience, there will be reviewers who don't see the
> value in the distinction and simply reply with two words "why bother?".
>
> Not impossible, but not as simple as the builtin_platform_driver and
> similar wrappers that I've already added to mainline. You've made we
> want to go have another look at it again, but in the meantime we can do
> what I've done here, and circle around later to update the few instances
> of moduleparam in non-modules once/if the refactoring I describe above
> works out and is accepted in mainline.
Sure, I definitely agree with doing a first pass like this to sweep up
all the cruft and audit the module_param users at the same time, then
considering a robust refactoring once we've got a clear idea of how many
users actually need it.
TBH, at this point I was thinking along the lines of a simple:
#ifndef MODULE
#define builtin_param(name, type, perm) \
module_param(name, type, perm)
#define builtin_param_named(name, name, type, perrm) \
module_param_named(name, name, type, perm)
#endif
still in moduleparam.h, purely so that the intent can be made really
clear in driver code and it's more searchable than just comments. But
yeah, even that would probably be objectionable to many.
>> Otherwise, the changes look reasonable. I still hold out hope that one day
>> we'll be able to make IOMMU drivers modular (it can work with minimal hacks
>> today, but it's far from robust in general), but for now I agree this makes
>> sense (and it'll be easy enough to revert for playing with further hacks).
>
> I totally agree - I've had similar discussions with the DMA maintainers,
> and if being modular can be made to work and has a use case - great!
>
> But it should be a conscious decision, since nobody writes a new driver
> from scratch; they copy one that is "close" as a template and then go
> from there. Which leads to a good percentage of drivers having hints
> of modular stuff when there is no intent of them ever being modular.
>
>> With the title fixed up as Joerg asked,
>>
>> Acked-by: Robin Murphy <robin.murphy@arm.com>
>
> Thanks for the feedback/review. Will re-send with updated titles before
> the week is finished and a good chance for additional feedback has elapsed.
Great! There's probably some more subtleties that could be tidied up
when the driver is truly non-removable, but I can take a look at that
myself once this patch has gone in.
Cheers,
Robin.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 9/9] iommu: arm-smmu-v3: make it explicitly non-modular
2018-11-26 22:31 [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules Paul Gortmaker
2018-11-26 22:31 ` [PATCH 2/9] iommu: rockchip: make it explicitly non-modular Paul Gortmaker
2018-11-26 22:31 ` [PATCH 8/9] iommu: arm-smmu: " Paul Gortmaker
@ 2018-11-26 22:31 ` Paul Gortmaker
2018-11-28 12:44 ` Robin Murphy
2018-11-27 10:11 ` [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules Joerg Roedel
3 siblings, 1 reply; 11+ messages in thread
From: Paul Gortmaker @ 2018-11-26 22:31 UTC (permalink / raw)
To: linux-arm-kernel
The Kconfig currently controlling compilation of this code is:
drivers/iommu/Kconfig:config ARM_SMMU_V3
drivers/iommu/Kconfig: bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support"
...meaning that it currently is not being built as a module by anyone.
Lets remove the modular code that is essentially orphaned, so that
when reading the driver there is no doubt it is builtin-only.
Since module_platform_driver() uses the same init level priority as
builtin_platform_driver() the init ordering remains unchanged with
this commit.
We explicitly disallow a driver unbind, since that doesn't have a
sensible use case anyway, but unlike most drivers, we can't delete the
function tied to the ".remove" field. This is because as of commit
7aa8619a66ae ("iommu/arm-smmu-v3: Implement shutdown method") the
.remove function was given a one line wrapper and re-used to provide a
.shutdown service. So we delete the wrapper and re-name the function
from remove to shutdown.
We add a moduleparam.h include since the file does actually declare
some module parameters, and leaving them as such is the easiest way
currently to remain backwards compatible with existing use cases.
Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
We also delete the MODULE_LICENSE tag etc. since all that information
is already contained at the top of the file in the comments.
Cc: Will Deacon <will.deacon@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Nate Watterson <nwatters@codeaurora.org>
Cc: linux-arm-kernel at lists.infradead.org
Cc: iommu at lists.linux-foundation.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
drivers/iommu/arm-smmu-v3.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
index 6947ccf26512..1189c06079d4 100644
--- a/drivers/iommu/arm-smmu-v3.c
+++ b/drivers/iommu/arm-smmu-v3.c
@@ -20,7 +20,8 @@
#include <linux/interrupt.h>
#include <linux/iommu.h>
#include <linux/iopoll.h>
-#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/moduleparam.h>
#include <linux/msi.h>
#include <linux/of.h>
#include <linux/of_address.h>
@@ -356,6 +357,10 @@
#define MSI_IOVA_BASE 0x8000000
#define MSI_IOVA_LENGTH 0x100000
+/*
+ * not really modular, but the easiest way to keep compat with existing
+ * bootargs behaviour is to continue using module_param_named here.
+ */
static bool disable_bypass = 1;
module_param_named(disable_bypass, disable_bypass, bool, S_IRUGO);
MODULE_PARM_DESC(disable_bypass,
@@ -2928,37 +2933,25 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
return 0;
}
-static int arm_smmu_device_remove(struct platform_device *pdev)
+static void arm_smmu_device_shutdown(struct platform_device *pdev)
{
struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
arm_smmu_device_disable(smmu);
-
- return 0;
-}
-
-static void arm_smmu_device_shutdown(struct platform_device *pdev)
-{
- arm_smmu_device_remove(pdev);
}
static const struct of_device_id arm_smmu_of_match[] = {
{ .compatible = "arm,smmu-v3", },
{ },
};
-MODULE_DEVICE_TABLE(of, arm_smmu_of_match);
static struct platform_driver arm_smmu_driver = {
.driver = {
.name = "arm-smmu-v3",
.of_match_table = of_match_ptr(arm_smmu_of_match),
+ .suppress_bind_attrs = true,
},
.probe = arm_smmu_device_probe,
- .remove = arm_smmu_device_remove,
.shutdown = arm_smmu_device_shutdown,
};
-module_platform_driver(arm_smmu_driver);
-
-MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations");
-MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");
-MODULE_LICENSE("GPL v2");
+builtin_platform_driver(arm_smmu_driver);
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 9/9] iommu: arm-smmu-v3: make it explicitly non-modular
2018-11-26 22:31 ` [PATCH 9/9] iommu: arm-smmu-v3: " Paul Gortmaker
@ 2018-11-28 12:44 ` Robin Murphy
0 siblings, 0 replies; 11+ messages in thread
From: Robin Murphy @ 2018-11-28 12:44 UTC (permalink / raw)
To: linux-arm-kernel
On 26/11/2018 22:31, Paul Gortmaker wrote:
> The Kconfig currently controlling compilation of this code is:
>
> drivers/iommu/Kconfig:config ARM_SMMU_V3
> drivers/iommu/Kconfig: bool "ARM Ltd. System MMU Version 3 (SMMUv3) Support"
>
> ...meaning that it currently is not being built as a module by anyone.
>
> Lets remove the modular code that is essentially orphaned, so that
> when reading the driver there is no doubt it is builtin-only.
>
> Since module_platform_driver() uses the same init level priority as
> builtin_platform_driver() the init ordering remains unchanged with
> this commit.
>
> We explicitly disallow a driver unbind, since that doesn't have a
> sensible use case anyway, but unlike most drivers, we can't delete the
> function tied to the ".remove" field. This is because as of commit
> 7aa8619a66ae ("iommu/arm-smmu-v3: Implement shutdown method") the
> .remove function was given a one line wrapper and re-used to provide a
> .shutdown service. So we delete the wrapper and re-name the function
> from remove to shutdown.
>
> We add a moduleparam.h include since the file does actually declare
> some module parameters, and leaving them as such is the easiest way
> currently to remain backwards compatible with existing use cases.
>
> Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
>
> We also delete the MODULE_LICENSE tag etc. since all that information
> is already contained at the top of the file in the comments.
With the title fixed up,
Acked-by: Robin Murphy <robin.murphy@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Nate Watterson <nwatters@codeaurora.org>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: iommu at lists.linux-foundation.org
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> ---
> drivers/iommu/arm-smmu-v3.c | 25 +++++++++----------------
> 1 file changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
> index 6947ccf26512..1189c06079d4 100644
> --- a/drivers/iommu/arm-smmu-v3.c
> +++ b/drivers/iommu/arm-smmu-v3.c
> @@ -20,7 +20,8 @@
> #include <linux/interrupt.h>
> #include <linux/iommu.h>
> #include <linux/iopoll.h>
> -#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/moduleparam.h>
> #include <linux/msi.h>
> #include <linux/of.h>
> #include <linux/of_address.h>
> @@ -356,6 +357,10 @@
> #define MSI_IOVA_BASE 0x8000000
> #define MSI_IOVA_LENGTH 0x100000
>
> +/*
> + * not really modular, but the easiest way to keep compat with existing
> + * bootargs behaviour is to continue using module_param_named here.
> + */
> static bool disable_bypass = 1;
> module_param_named(disable_bypass, disable_bypass, bool, S_IRUGO);
> MODULE_PARM_DESC(disable_bypass,
> @@ -2928,37 +2933,25 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> return 0;
> }
>
> -static int arm_smmu_device_remove(struct platform_device *pdev)
> +static void arm_smmu_device_shutdown(struct platform_device *pdev)
> {
> struct arm_smmu_device *smmu = platform_get_drvdata(pdev);
>
> arm_smmu_device_disable(smmu);
> -
> - return 0;
> -}
> -
> -static void arm_smmu_device_shutdown(struct platform_device *pdev)
> -{
> - arm_smmu_device_remove(pdev);
> }
>
> static const struct of_device_id arm_smmu_of_match[] = {
> { .compatible = "arm,smmu-v3", },
> { },
> };
> -MODULE_DEVICE_TABLE(of, arm_smmu_of_match);
>
> static struct platform_driver arm_smmu_driver = {
> .driver = {
> .name = "arm-smmu-v3",
> .of_match_table = of_match_ptr(arm_smmu_of_match),
> + .suppress_bind_attrs = true,
> },
> .probe = arm_smmu_device_probe,
> - .remove = arm_smmu_device_remove,
> .shutdown = arm_smmu_device_shutdown,
> };
> -module_platform_driver(arm_smmu_driver);
> -
> -MODULE_DESCRIPTION("IOMMU API for ARM architected SMMUv3 implementations");
> -MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");
> -MODULE_LICENSE("GPL v2");
> +builtin_platform_driver(arm_smmu_driver);
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules.
2018-11-26 22:31 [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules Paul Gortmaker
` (2 preceding siblings ...)
2018-11-26 22:31 ` [PATCH 9/9] iommu: arm-smmu-v3: " Paul Gortmaker
@ 2018-11-27 10:11 ` Joerg Roedel
2018-11-27 14:39 ` Paul Gortmaker
3 siblings, 1 reply; 11+ messages in thread
From: Joerg Roedel @ 2018-11-27 10:11 UTC (permalink / raw)
To: linux-arm-kernel
Hi Paul,
thanks for your cleanup!
The iommu-tree uses another rule for the subject line of patches. Can
you please resend with correct subject lines? See below for what is
used.
The general format is:
iommu/<driver>: _C_apital letter starting subject
Please also collect the Acks you get and add them to the patches before
the resend.
On Mon, Nov 26, 2018 at 05:31:29PM -0500, Paul Gortmaker wrote:
> Paul Gortmaker (9):
> iommu: audit and remove any unnecessary uses of module.h
Fine.
> iommu: rockchip: make it explicitly non-modular
iommu/rockchip: Make it explicitly non-modular
> iommu: msm_iommu: make it explicitly non-modular
iommu/msm: Make it explicitly non-modular
> iommu: mtk_iommu: make it explicitly non-modular
iommu/mediatek: Make it explicitly non-modular
> iommu: ipmmu-vmsa: make it explicitly non-modular
iommu/ipmmu-vmsa: Make it explicitly non-modular
> iommu: qcom_iommu: make it explicitly non-modular
iommu/qcom: Make it explicitly non-modular
> iommu: tegra-gart: make it explicitly non-modular
iommu/tegra: Make it explicitly non-modular
> iommu: arm-smmu: make it explicitly non-modular
iommu/arm-smmu: Make arm-smmu explicitly non-modular
> iommu: arm-smmu-v3: make it explicitly non-modular
iommu/arm-smmu: Make arm-smmu-v3 explicitly non-modular
Thanks a lot,
Joerg
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules.
2018-11-27 10:11 ` [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules Joerg Roedel
@ 2018-11-27 14:39 ` Paul Gortmaker
0 siblings, 0 replies; 11+ messages in thread
From: Paul Gortmaker @ 2018-11-27 14:39 UTC (permalink / raw)
To: linux-arm-kernel
[Re: [PATCH 0/9] iommu: clean up/remove modular stuff from non-modules.] On 27/11/2018 (Tue 11:11) Joerg Roedel wrote:
> Hi Paul,
>
> thanks for your cleanup!
>
> The iommu-tree uses another rule for the subject line of patches. Can
> you please resend with correct subject lines? See below for what is
> used.
Sure - I'll wait another day or two in case anyone on the Cc sends in
some additional Acks.
Thanks,
Paul.
--
>
> The general format is:
>
> iommu/<driver>: _C_apital letter starting subject
>
> Please also collect the Acks you get and add them to the patches before
> the resend.
>
> On Mon, Nov 26, 2018 at 05:31:29PM -0500, Paul Gortmaker wrote:
> > Paul Gortmaker (9):
> > iommu: audit and remove any unnecessary uses of module.h
> Fine.
> > iommu: rockchip: make it explicitly non-modular
> iommu/rockchip: Make it explicitly non-modular
> > iommu: msm_iommu: make it explicitly non-modular
> iommu/msm: Make it explicitly non-modular
> > iommu: mtk_iommu: make it explicitly non-modular
> iommu/mediatek: Make it explicitly non-modular
> > iommu: ipmmu-vmsa: make it explicitly non-modular
> iommu/ipmmu-vmsa: Make it explicitly non-modular
> > iommu: qcom_iommu: make it explicitly non-modular
> iommu/qcom: Make it explicitly non-modular
> > iommu: tegra-gart: make it explicitly non-modular
> iommu/tegra: Make it explicitly non-modular
> > iommu: arm-smmu: make it explicitly non-modular
> iommu/arm-smmu: Make arm-smmu explicitly non-modular
> > iommu: arm-smmu-v3: make it explicitly non-modular
> iommu/arm-smmu: Make arm-smmu-v3 explicitly non-modular
>
> Thanks a lot,
>
> Joerg
^ permalink raw reply [flat|nested] 11+ messages in thread