[v2,3/6] iommu/exynos: Modularize the driver
Commit Message
Rework the driver so it can be built as a loadable module. That can be
useful as not all ARM64 platforms need it. And that's ok for it to be a
module because it's not a critical driver (platform can work when it's
disabled).
Remove method and module exit function are not implemented, as the
removal of IOMMUs cannot be done reliably. As Robin Murphy mentioned in
[1]:
...it's better not to even pretend that removing an IOMMU's driver
while other drivers are using it (usually via DMA ops without even
realising) is going to have anything other than catastrophic
results.
[1] https://lore.kernel.org/lkml/20220702213724.3949-2-semen.protsenko@linaro.org/T/#md7e1e3f5b2c9e7fa5bc28fe33e818b6aa4a7237c
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2:
- Add MODULE_DEVICE_TABLE(of, ...) to support hot-plug loading
- Add MODULE_ALIAS() line
- Extracted "shutdown" driver method adding into a separate patch
drivers/iommu/Kconfig | 2 +-
drivers/iommu/exynos-iommu.c | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
Comments
On 03/11/2022 15:51, Sam Protsenko wrote:
> Rework the driver so it can be built as a loadable module. That can be
> useful as not all ARM64 platforms need it. And that's ok for it to be a
> module because it's not a critical driver (platform can work when it's
> disabled).
>
> Remove method and module exit function are not implemented, as the
> removal of IOMMUs cannot be done reliably. As Robin Murphy mentioned in
> [1]:
>
> ...it's better not to even pretend that removing an IOMMU's driver
> while other drivers are using it (usually via DMA ops without even
> realising) is going to have anything other than catastrophic
> results.
>
> [1] https://lore.kernel.org/lkml/20220702213724.3949-2-semen.protsenko@linaro.org/T/#md7e1e3f5b2c9e7fa5bc28fe33e818b6aa4a7237c
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
@@ -259,7 +259,7 @@ config TEGRA_IOMMU_SMMU
SoCs (Tegra30 up to Tegra210).
config EXYNOS_IOMMU
- bool "Exynos IOMMU Support"
+ tristate "Exynos IOMMU Support"
depends on ARCH_EXYNOS || COMPILE_TEST
depends on !CPU_BIG_ENDIAN # revisit driver if we can enable big-endian ptes
select IOMMU_API
@@ -16,6 +16,7 @@
#include <linux/interrupt.h>
#include <linux/kmemleak.h>
#include <linux/list.h>
+#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
@@ -798,8 +799,9 @@ static const struct of_device_id sysmmu_of_match[] = {
{ .compatible = "samsung,exynos-sysmmu", },
{ },
};
+MODULE_DEVICE_TABLE(of, sysmmu_of_match);
-static struct platform_driver exynos_sysmmu_driver __refdata = {
+static struct platform_driver exynos_sysmmu_driver = {
.probe = exynos_sysmmu_probe,
.driver = {
.name = "exynos-sysmmu",
@@ -1404,6 +1406,7 @@ static const struct iommu_ops exynos_iommu_ops = {
.release_device = exynos_iommu_release_device,
.pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
.of_xlate = exynos_iommu_of_xlate,
+ .owner = THIS_MODULE,
.default_domain_ops = &(const struct iommu_domain_ops) {
.attach_dev = exynos_iommu_attach_device,
.detach_dev = exynos_iommu_detach_device,
@@ -1454,3 +1457,7 @@ static int __init exynos_iommu_init(void)
return ret;
}
core_initcall(exynos_iommu_init);
+
+MODULE_DESCRIPTION("IOMMU driver for Exynos SoCs");
+MODULE_ALIAS("platform:exynos-sysmmu");
+MODULE_LICENSE("GPL");