The work here represents a scan over the iommu dir, looking for files/drivers
that have nothing to do with a modular use case, but are using modular
infrastructure regardless.
We are trying to make driver code consistent with the Makefiles/Kconfigs that
control them. This means not using modular functions/macros for drivers that
can never be built as a module. I've done this in other subsystem dirs
already, and some of this has already happened in drivers/iommu by others;
such as 98b72b94def9 ("iommu/rockchip: Prohibit unbind and remove").
Using modular infrastructure in non-modules might seem harmless, but some
of the downfalls this leads to are:
(1) it is easy to accidentally write unused module_exit and remove code
(2) it can be misleading when reading the source, thinking it can be
modular when the Makefile and/or Kconfig prohibit it
(3) it requires the include of the module.h header file which in turn
includes nearly everything else, thus adding to CPP overhead.
(4) it gets copied/replicated into other drivers and spreads quickly.
The last two commits (arm-smmu related ones) deserve an extra mention,
and I put them at the end in case they want to be deferred for later or
altered. Normally a "module-ectomy" allows us to delete the ".remove"
function, as per the rockchip commit above, but ...
A kexec commit (7aa8619a66ae) tried to improve reliability by trying to
shutdown the iommu in the compromised/crashing kernel, but of course the
better solution is to have the recovery kernel be able to handle all of
the possible initial conditions. It appears this was done later in the
commit b63b3439b856 - but I don't know if that means relying on an
orderly shutdown is no longer required - I don't have the platform and
am only going on what is in git history.
So, as the kexec commit recycled the ".remove" handle to also be the
".shutdown" handle, in this series the remove function was renamed to
shutdown, and the ".remove" handle was deleted. This was IMHO the most
back compatible way to make this update. If the reliance on the
compromised kernel to run ".shutdown" is no longer necessary, then it
can be removed in a future change.
Patches were build tested on top of next-20181122 for ARM, ARM64, x86-64
on an allyesconfig.
Paul.
---
Cc: Alexandre Courbot <[email protected]>
Cc: Daniel Kurtz <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: Hiroshi Doyu <[email protected]>
Cc: Honghui Zhang <[email protected]>
Cc: Jeffy Chen <[email protected]>
Cc: Joerg Roedel <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: Nate Watterson <[email protected]>
Cc: Rob Clark <[email protected]>
Cc: Robin Murphy <[email protected]>
Cc: Simon Xue <[email protected]>
Cc: Stepan Moskovchenko <[email protected]>
Cc: Stephen Warren <[email protected]>
Cc: Thierry Reding <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Paul Gortmaker (9):
iommu: audit and remove any unnecessary uses of module.h
iommu: rockchip: make it explicitly non-modular
iommu: msm_iommu: make it explicitly non-modular
iommu: mtk_iommu: make it explicitly non-modular
iommu: ipmmu-vmsa: make it explicitly non-modular
iommu: qcom_iommu: make it explicitly non-modular
iommu: tegra-gart: make it explicitly non-modular
iommu: arm-smmu: make it explicitly non-modular
iommu: arm-smmu-v3: make it explicitly non-modular
drivers/iommu/arm-smmu-v3.c | 25 +++++++++----------------
drivers/iommu/arm-smmu.c | 32 +++++++++++++-------------------
drivers/iommu/iommu-sysfs.c | 2 +-
drivers/iommu/iommu.c | 3 ++-
drivers/iommu/ipmmu-vmsa.c | 16 +++-------------
drivers/iommu/msm_iommu.c | 13 +++----------
drivers/iommu/mtk_iommu_v1.c | 15 +++------------
drivers/iommu/qcom_iommu.c | 16 ++--------------
drivers/iommu/rockchip-iommu.c | 13 ++++++-------
drivers/iommu/tegra-gart.c | 37 +++++++------------------------------
10 files changed, 49 insertions(+), 123 deletions(-)
--
2.7.4
The Kconfig currently controlling compilation of this code is:
drivers/iommu/Kconfig:config IPMMU_VMSA
drivers/iommu/Kconfig: bool "Renesas VMSA-compatible IPMMU"
...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_init was not even used by this driver, the init ordering
remains unchanged with this commit.
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.
Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
Cc: Joerg Roedel <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
drivers/iommu/ipmmu-vmsa.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 9e2655f1c1bf..de39ef992d8a 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
/*
* IPMMU VMSA
+ * IOMMU API for Renesas VMSA-compatible IPMMU
+ * Author: Laurent Pinchart <[email protected]>
*
* Copyright (C) 2014 Renesas Electronics Corporation
*/
@@ -14,7 +16,7 @@
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iommu.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/of_iommu.h>
@@ -968,7 +970,6 @@ static const struct of_device_id ipmmu_of_ids[] = {
},
};
-MODULE_DEVICE_TABLE(of, ipmmu_of_ids);
static int ipmmu_probe(struct platform_device *pdev)
{
@@ -1140,15 +1141,4 @@ static int __init ipmmu_init(void)
setup_done = true;
return 0;
}
-
-static void __exit ipmmu_exit(void)
-{
- return platform_driver_unregister(&ipmmu_driver);
-}
-
subsys_initcall(ipmmu_init);
-module_exit(ipmmu_exit);
-
-MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
-MODULE_AUTHOR("Laurent Pinchart <[email protected]>");
-MODULE_LICENSE("GPL v2");
--
2.7.4
The Kconfig currently controlling compilation of this code is:
drivers/iommu/Kconfig:config MSM_IOMMU
drivers/iommu/Kconfig: bool "MSM IOMMU 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_init was not even used by this driver, the init ordering
remains unchanged with this commit.
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 <[email protected]>
Cc: Stepan Moskovchenko <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
drivers/iommu/msm_iommu.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index fc5f0b53adaf..fc4270733f11 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -1,5 +1,7 @@
/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
*
+ * Author: Stepan Moskovchenko <[email protected]>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
@@ -17,7 +19,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/errno.h>
#include <linux/io.h>
@@ -861,14 +863,5 @@ static int __init msm_iommu_driver_init(void)
return ret;
}
-
-static void __exit msm_iommu_driver_exit(void)
-{
- platform_driver_unregister(&msm_iommu_driver);
-}
-
subsys_initcall(msm_iommu_driver_init);
-module_exit(msm_iommu_driver_exit);
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("Stepan Moskovchenko <[email protected]>");
--
2.7.4
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 <[email protected]>
Cc: Joerg Roedel <[email protected]>
Cc: Robin Murphy <[email protected]>
Cc: Nate Watterson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
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 <[email protected]>");
-MODULE_LICENSE("GPL v2");
+builtin_platform_driver(arm_smmu_driver);
--
2.7.4
The Kconfig currently controlling compilation of this code is:
drivers/iommu/Kconfig:config MTK_IOMMU_V1
drivers/iommu/Kconfig: bool "MTK IOMMU Version 1 (M4U gen1) 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_init was not even used by this driver, the init ordering
remains unchanged with this commit.
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 <[email protected]>
Cc: Matthias Brugger <[email protected]>
Cc: Honghui Zhang <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
drivers/iommu/mtk_iommu_v1.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index 27867b862d7a..5fbf3cecb87f 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -1,4 +1,6 @@
/*
+ * IOMMU API for MTK architected m4u v1 implementations
+ *
* Copyright (c) 2015-2016 MediaTek Inc.
* Author: Honghui Zhang <[email protected]>
*
@@ -35,7 +37,7 @@
#include <linux/spinlock.h>
#include <asm/barrier.h>
#include <asm/dma-iommu.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <dt-bindings/memory/mt2701-larb-port.h>
#include <soc/mediatek/smi.h>
#include "mtk_iommu.h"
@@ -704,15 +706,4 @@ static int __init m4u_init(void)
{
return platform_driver_register(&mtk_iommu_driver);
}
-
-static void __exit m4u_exit(void)
-{
- return platform_driver_unregister(&mtk_iommu_driver);
-}
-
subsys_initcall(m4u_init);
-module_exit(m4u_exit);
-
-MODULE_DESCRIPTION("IOMMU API for MTK architected m4u v1 implementations");
-MODULE_AUTHOR("Honghui Zhang <[email protected]>");
-MODULE_LICENSE("GPL v2");
--
2.7.4
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 <[email protected]>
Cc: Heiko Stuebner <[email protected]>
Cc: Simon Xue <[email protected]>
Cc: Daniel Kurtz <[email protected]>
Cc: Jeffy Chen <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
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 <[email protected]>
+ * Daniel Kurtz <[email protected]>
+ *
* 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 <[email protected]> and Daniel Kurtz <[email protected]>");
-MODULE_ALIAS("platform:rockchip-iommu");
-MODULE_LICENSE("GPL v2");
--
2.7.4
Historically a lot of these existed because we did not have
a distinction between what was modular code and what was providing
support to modules via EXPORT_SYMBOL and friends. That changed
when we forked out support for the latter into the export.h file.
This means we should be able to reduce the usage of module.h
in code that is obj-y Makefile or bool Kconfig.
The advantage in removing such instances is that module.h itself
sources about 15 other headers; adding significantly to what we feed
cpp, and it can obscure what headers we are effectively using.
Since module.h might have been the implicit source for init.h
(for __init) and for export.h (for EXPORT_SYMBOL) we consider each
instance for the presence of either and replace as needed.
Cc: Joerg Roedel <[email protected]>
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
drivers/iommu/iommu-sysfs.c | 2 +-
drivers/iommu/iommu.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iommu-sysfs.c b/drivers/iommu/iommu-sysfs.c
index 36d1a7ce7fc4..c298330ba2b7 100644
--- a/drivers/iommu/iommu-sysfs.c
+++ b/drivers/iommu/iommu-sysfs.c
@@ -11,7 +11,7 @@
#include <linux/device.h>
#include <linux/iommu.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/slab.h>
/*
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index f8ec49e0f6c6..cc25ec6d4c06 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -22,7 +22,8 @@
#include <linux/kernel.h>
#include <linux/bug.h>
#include <linux/types.h>
-#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/export.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/iommu.h>
--
2.7.4
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 <[email protected]>
Cc: Joerg Roedel <[email protected]>
Cc: Robin Murphy <[email protected]>
Cc: Nate Watterson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
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 <[email protected]>");
-MODULE_LICENSE("GPL v2");
+builtin_platform_driver(arm_smmu_driver);
--
2.7.4
The Kconfig currently controlling compilation of this code is:
drivers/iommu/Kconfig:config TEGRA_IOMMU_GART
drivers/iommu/Kconfig: bool "Tegra GART IOMMU 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.
We explicitly disallow a driver unbind, since that doesn't have a
sensible use case anyway, and it allows us to drop the ".remove"
code for non-modular drivers.
Since module_init was not in use by this code, the init ordering
remains unchanged with this commit.
We replace module.h with moduleparam.h since the file does actually
declare some module_param() and the easiest way to keep back
compatibility with existing use cases is to leave it as-is for now.
The init function was missing an __init annotation, so it was added.
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: Hiroshi Doyu <[email protected]>
Cc: Joerg Roedel <[email protected]>
Cc: Stephen Warren <[email protected]>
Cc: Thierry Reding <[email protected]>
Cc: Alexandre Courbot <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
drivers/iommu/tegra-gart.c | 37 +++++++------------------------------
1 file changed, 7 insertions(+), 30 deletions(-)
diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 7b1361d57a17..da6a4e357b2b 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -3,6 +3,8 @@
*
* Copyright (c) 2010-2012, NVIDIA CORPORATION. All rights reserved.
*
+ * Author: Hiroshi DOYU <[email protected]>
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
@@ -19,7 +21,8 @@
#define pr_fmt(fmt) "%s(): " fmt, __func__
-#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/moduleparam.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
@@ -478,20 +481,6 @@ static int tegra_gart_probe(struct platform_device *pdev)
return 0;
}
-static int tegra_gart_remove(struct platform_device *pdev)
-{
- struct gart_device *gart = platform_get_drvdata(pdev);
-
- iommu_device_unregister(&gart->iommu);
- iommu_device_sysfs_remove(&gart->iommu);
-
- writel(0, gart->regs + GART_CONFIG);
- if (gart->savedata)
- vfree(gart->savedata);
- gart_handle = NULL;
- return 0;
-}
-
static const struct dev_pm_ops tegra_gart_pm_ops = {
.suspend = tegra_gart_suspend,
.resume = tegra_gart_resume,
@@ -501,34 +490,22 @@ static const struct of_device_id tegra_gart_of_match[] = {
{ .compatible = "nvidia,tegra20-gart", },
{ },
};
-MODULE_DEVICE_TABLE(of, tegra_gart_of_match);
static struct platform_driver tegra_gart_driver = {
.probe = tegra_gart_probe,
- .remove = tegra_gart_remove,
.driver = {
.name = "tegra-gart",
.pm = &tegra_gart_pm_ops,
.of_match_table = tegra_gart_of_match,
+ .suppress_bind_attrs = true,
},
};
-static int tegra_gart_init(void)
+static int __init tegra_gart_init(void)
{
return platform_driver_register(&tegra_gart_driver);
}
-
-static void __exit tegra_gart_exit(void)
-{
- platform_driver_unregister(&tegra_gart_driver);
-}
-
subsys_initcall(tegra_gart_init);
-module_exit(tegra_gart_exit);
-module_param(gart_debug, bool, 0644);
+module_param(gart_debug, bool, 0644);
MODULE_PARM_DESC(gart_debug, "Enable GART debugging");
-MODULE_DESCRIPTION("IOMMU API for GART in Tegra20");
-MODULE_AUTHOR("Hiroshi DOYU <[email protected]>");
-MODULE_ALIAS("platform:tegra-gart");
-MODULE_LICENSE("GPL v2");
--
2.7.4
The Kconfig currently controlling compilation of this code is:
drivers/iommu/Kconfig:config MTK_IOMMU_V1
drivers/iommu/Kconfig: bool "MTK IOMMU Version 1 (M4U gen1) 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_init just becomes device_initcall for non-modules, 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: Rob Clark <[email protected]>
Cc: Joerg Roedel <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Paul Gortmaker <[email protected]>
---
drivers/iommu/qcom_iommu.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/drivers/iommu/qcom_iommu.c b/drivers/iommu/qcom_iommu.c
index ee70e9921cf1..4c8f4fc54106 100644
--- a/drivers/iommu/qcom_iommu.c
+++ b/drivers/iommu/qcom_iommu.c
@@ -29,7 +29,7 @@
#include <linux/iommu.h>
#include <linux/iopoll.h>
#include <linux/kconfig.h>
-#include <linux/module.h>
+#include <linux/init.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_address.h>
@@ -908,7 +908,6 @@ static const struct of_device_id qcom_iommu_of_match[] = {
{ .compatible = "qcom,msm-iommu-v1" },
{ /* sentinel */ }
};
-MODULE_DEVICE_TABLE(of, qcom_iommu_of_match);
static struct platform_driver qcom_iommu_driver = {
.driver = {
@@ -934,15 +933,4 @@ static int __init qcom_iommu_init(void)
return ret;
}
-
-static void __exit qcom_iommu_exit(void)
-{
- platform_driver_unregister(&qcom_iommu_driver);
- platform_driver_unregister(&qcom_iommu_ctx_driver);
-}
-
-module_init(qcom_iommu_init);
-module_exit(qcom_iommu_exit);
-
-MODULE_DESCRIPTION("IOMMU API for QCOM IOMMU v1 implementations");
-MODULE_LICENSE("GPL v2");
+device_initcall(qcom_iommu_init);
--
2.7.4
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 <[email protected]>
> Cc: Heiko Stuebner <[email protected]>
> Cc: Simon Xue <[email protected]>
> Cc: Daniel Kurtz <[email protected]>
> Cc: Jeffy Chen <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Paul Gortmaker <[email protected]>
Acked-by: Heiko Stuebner <[email protected]>
On Mon, 2018-11-26 at 17:31 -0500, Paul Gortmaker wrote:
> The Kconfig currently controlling compilation of this code is:
>
> drivers/iommu/Kconfig:config MTK_IOMMU_V1
> drivers/iommu/Kconfig: bool "MTK IOMMU Version 1 (M4U gen1) 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_init was not even used by this driver, the init ordering
> remains unchanged with this commit.
>
> 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 <[email protected]>
> Cc: Matthias Brugger <[email protected]>
> Cc: Honghui Zhang <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Paul Gortmaker <[email protected]>
> ---
> drivers/iommu/mtk_iommu_v1.c | 15 +++------------
> 1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
> index 27867b862d7a..5fbf3cecb87f 100644
> --- a/drivers/iommu/mtk_iommu_v1.c
> +++ b/drivers/iommu/mtk_iommu_v1.c
> @@ -1,4 +1,6 @@
> /*
> + * IOMMU API for MTK architected m4u v1 implementations
> + *
> * Copyright (c) 2015-2016 MediaTek Inc.
> * Author: Honghui Zhang <[email protected]>
> *
> @@ -35,7 +37,7 @@
> #include <linux/spinlock.h>
> #include <asm/barrier.h>
> #include <asm/dma-iommu.h>
> -#include <linux/module.h>
> +#include <linux/init.h>
> #include <dt-bindings/memory/mt2701-larb-port.h>
> #include <soc/mediatek/smi.h>
> #include "mtk_iommu.h"
> @@ -704,15 +706,4 @@ static int __init m4u_init(void)
> {
> return platform_driver_register(&mtk_iommu_driver);
> }
> -
> -static void __exit m4u_exit(void)
> -{
> - return platform_driver_unregister(&mtk_iommu_driver);
> -}
> -
> subsys_initcall(m4u_init);
> -module_exit(m4u_exit);
> -
> -MODULE_DESCRIPTION("IOMMU API for MTK architected m4u v1 implementations");
> -MODULE_AUTHOR("Honghui Zhang <[email protected]>");
> -MODULE_LICENSE("GPL v2");
Hi, Paul,
Thanks for your patch.
I would like the patch tile be:
iommu/mediatek: make it explicitly non-modular
except that,
Acked-by: Honghui Zhang <[email protected]>
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
On Mon, Nov 26, 2018 at 05:31:36PM -0500, Paul Gortmaker wrote:
> The Kconfig currently controlling compilation of this code is:
>
> drivers/iommu/Kconfig:config TEGRA_IOMMU_GART
> drivers/iommu/Kconfig: bool "Tegra GART IOMMU 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.
>
> We explicitly disallow a driver unbind, since that doesn't have a
> sensible use case anyway, and it allows us to drop the ".remove"
> code for non-modular drivers.
>
> Since module_init was not in use by this code, the init ordering
> remains unchanged with this commit.
>
> We replace module.h with moduleparam.h since the file does actually
> declare some module_param() and the easiest way to keep back
> compatibility with existing use cases is to leave it as-is for now.
>
> The init function was missing an __init annotation, so it was added.
>
> 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: Hiroshi Doyu <[email protected]>
> Cc: Joerg Roedel <[email protected]>
> Cc: Stephen Warren <[email protected]>
> Cc: Thierry Reding <[email protected]>
> Cc: Alexandre Courbot <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Paul Gortmaker <[email protected]>
> ---
> drivers/iommu/tegra-gart.c | 37 +++++++------------------------------
> 1 file changed, 7 insertions(+), 30 deletions(-)
Acked-by: Thierry Reding <[email protected]>
[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
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 <[email protected]>
> Cc: Joerg Roedel <[email protected]>
> Cc: Robin Murphy <[email protected]>
> Cc: Nate Watterson <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Paul Gortmaker <[email protected]>
> ---
> 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 <[email protected]>
> 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 <[email protected]>");
> -MODULE_LICENSE("GPL v2");
> +builtin_platform_driver(arm_smmu_driver);
>
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 <[email protected]>
> Cc: Will Deacon <[email protected]>
> Cc: Joerg Roedel <[email protected]>
> Cc: Robin Murphy <[email protected]>
> Cc: Nate Watterson <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Signed-off-by: Paul Gortmaker <[email protected]>
> ---
> 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 <[email protected]>");
> -MODULE_LICENSE("GPL v2");
> +builtin_platform_driver(arm_smmu_driver);
>
On 26/11/2018 22:31, Paul Gortmaker wrote:
> The Kconfig currently controlling compilation of this code is:
>
> drivers/iommu/Kconfig:config IPMMU_VMSA
> drivers/iommu/Kconfig: bool "Renesas VMSA-compatible IPMMU"
>
> ...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_init was not even used by this driver, the init ordering
> remains unchanged with this commit.
>
> 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.
>
> Also note that MODULE_DEVICE_TABLE is a no-op for non-modular code.
>
> Cc: Joerg Roedel <[email protected]>
> Cc: Laurent Pinchart <[email protected]>
> Cc: [email protected]
> Signed-off-by: Paul Gortmaker <[email protected]>
> ---
> drivers/iommu/ipmmu-vmsa.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index 9e2655f1c1bf..de39ef992d8a 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -1,6 +1,8 @@
> // SPDX-License-Identifier: GPL-2.0
> /*
> * IPMMU VMSA
Nit: this line doesn't convey any information that the module
description below doesn't also say far more clearly, so you may as well
just replace it entirely.
Robin.
> + * IOMMU API for Renesas VMSA-compatible IPMMU
> + * Author: Laurent Pinchart <[email protected]>
> *
> * Copyright (C) 2014 Renesas Electronics Corporation
> */
> @@ -14,7 +16,7 @@
> #include <linux/interrupt.h>
> #include <linux/io.h>
> #include <linux/iommu.h>
> -#include <linux/module.h>
> +#include <linux/init.h>
> #include <linux/of.h>
> #include <linux/of_device.h>
> #include <linux/of_iommu.h>
> @@ -968,7 +970,6 @@ static const struct of_device_id ipmmu_of_ids[] = {
> },
> };
>
> -MODULE_DEVICE_TABLE(of, ipmmu_of_ids);
>
> static int ipmmu_probe(struct platform_device *pdev)
> {
> @@ -1140,15 +1141,4 @@ static int __init ipmmu_init(void)
> setup_done = true;
> return 0;
> }
> -
> -static void __exit ipmmu_exit(void)
> -{
> - return platform_driver_unregister(&ipmmu_driver);
> -}
> -
> subsys_initcall(ipmmu_init);
> -module_exit(ipmmu_exit);
> -
> -MODULE_DESCRIPTION("IOMMU API for Renesas VMSA-compatible IPMMU");
> -MODULE_AUTHOR("Laurent Pinchart <[email protected]>");
> -MODULE_LICENSE("GPL v2");
>
[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 <[email protected]>
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.");
[Re: [PATCH 5/9] iommu: ipmmu-vmsa: make it explicitly non-modular] On 28/11/2018 (Wed 12:50) Robin Murphy wrote:
> On 26/11/2018 22:31, Paul Gortmaker wrote:
[...]
> >diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> >index 9e2655f1c1bf..de39ef992d8a 100644
> >--- a/drivers/iommu/ipmmu-vmsa.c
> >+++ b/drivers/iommu/ipmmu-vmsa.c
> >@@ -1,6 +1,8 @@
> > // SPDX-License-Identifier: GPL-2.0
> > /*
> > * IPMMU VMSA
>
> Nit: this line doesn't convey any information that the module description
> below doesn't also say far more clearly, so you may as well just replace it
> entirely.
No problem. Will do in v2.
P.
--
>
> Robin.
>
> >+ * IOMMU API for Renesas VMSA-compatible IPMMU
> >+ * Author: Laurent Pinchart <[email protected]>
[...]
Hi Paul,
On Wednesday, 28 November 2018 17:32:05 EET Paul Gortmaker wrote:
> [Re: [PATCH 5/9] iommu: ipmmu-vmsa: make it explicitly non-modular] On
28/11/2018 (Wed 12:50) Robin Murphy wrote:
> > On 26/11/2018 22:31, Paul Gortmaker wrote:
> [...]
>
> >> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> >> index 9e2655f1c1bf..de39ef992d8a 100644
> >> --- a/drivers/iommu/ipmmu-vmsa.c
> >> +++ b/drivers/iommu/ipmmu-vmsa.c
> >> @@ -1,6 +1,8 @@
> >>
> >> // SPDX-License-Identifier: GPL-2.0
> >> /*
> >> * IPMMU VMSA
> >
> > Nit: this line doesn't convey any information that the module description
> > below doesn't also say far more clearly, so you may as well just replace
> > it entirely.
>
> No problem. Will do in v2.
With that change, the blank line after MODULE_DEVICE_TABLE() removed, and
<linux/init.h> moved to keep alphabetical order sorting of the includes,
please add
Reviewed-by: Laurent Pinchart <[email protected]>
to v2. Thank you for the patch.
> > >+ * IOMMU API for Renesas VMSA-compatible IPMMU
> > >+ * Author: Laurent Pinchart <[email protected]>
>
> [...]
--
Regards,
Laurent Pinchart
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 <[email protected]>
>
> 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.
[Re: [PATCH 5/9] iommu: ipmmu-vmsa: make it explicitly non-modular] On 28/11/2018 (Wed 19:22) Laurent Pinchart wrote:
> Hi Paul,
>
> On Wednesday, 28 November 2018 17:32:05 EET Paul Gortmaker wrote:
> > [Re: [PATCH 5/9] iommu: ipmmu-vmsa: make it explicitly non-modular] On
> 28/11/2018 (Wed 12:50) Robin Murphy wrote:
> > > On 26/11/2018 22:31, Paul Gortmaker wrote:
> > [...]
> >
> > >> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> > >> index 9e2655f1c1bf..de39ef992d8a 100644
> > >> --- a/drivers/iommu/ipmmu-vmsa.c
> > >> +++ b/drivers/iommu/ipmmu-vmsa.c
> > >> @@ -1,6 +1,8 @@
> > >>
> > >> // SPDX-License-Identifier: GPL-2.0
> > >> /*
> > >> * IPMMU VMSA
> > >
> > > Nit: this line doesn't convey any information that the module description
> > > below doesn't also say far more clearly, so you may as well just replace
> > > it entirely.
> >
> > No problem. Will do in v2.
>
> With that change, the blank line after MODULE_DEVICE_TABLE() removed, and
> <linux/init.h> moved to keep alphabetical order sorting of the includes,
> please add
>
> Reviewed-by: Laurent Pinchart <[email protected]>
Updated and review tag added for v2.
Paul.
--
>
> to v2. Thank you for the patch.
>
> > > >+ * IOMMU API for Renesas VMSA-compatible IPMMU
> > > >+ * Author: Laurent Pinchart <[email protected]>
> >
> > [...]
>
> --
> Regards,
>
> Laurent Pinchart
>
>
>