Re: [PATCH 7/7] iommu/arm-smmu: Allow building as a module

From: Isaac J. Manjarres
Date: Mon Nov 04 2019 - 14:34:11 EST


On Wed, Oct 30, 2019 at 02:51:12PM +0000, Will Deacon wrote:
> By conditionally dropping support for the legacy binding and exporting
> the newly introduced 'arm_smmu_impl_init()' function we can allow the
> ARM SMMU driver to be built as a module.
>
> Signed-off-by: Will Deacon <will@xxxxxxxxxx>
> ---
> drivers/iommu/Kconfig | 14 ++++++++-
> drivers/iommu/arm-smmu-impl.c | 6 ++++
> drivers/iommu/arm-smmu.c | 54 +++++++++++++++++++++--------------
> 3 files changed, 51 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig
> index 7583d47fc4d5..02703f51e533 100644
> --- a/drivers/iommu/Kconfig
> +++ b/drivers/iommu/Kconfig
> @@ -350,7 +350,7 @@ config SPAPR_TCE_IOMMU
>
> # ARM IOMMU support
> config ARM_SMMU
> - bool "ARM Ltd. System MMU (SMMU) Support"
> + tristate "ARM Ltd. System MMU (SMMU) Support"
> depends on (ARM64 || ARM) && MMU
> select IOMMU_API
> select IOMMU_IO_PGTABLE_LPAE
> @@ -362,6 +362,18 @@ config ARM_SMMU
> Say Y here if your SoC includes an IOMMU device implementing
> the ARM SMMU architecture.
>
> +config ARM_SMMU_LEGACY_DT_BINDINGS
> + bool "Support the legacy \"mmu-masters\" devicetree bindings"
> + depends on ARM_SMMU=y && OF
> + help
> + Support for the badly designed and deprecated \"mmu-masters\"
> + devicetree bindings. This allows some DMA masters to attach
> + to the SMMU but does not provide any support via the DMA API.
> + If you're lucky, you might be able to get VFIO up and running.
> +
> + If you say Y here then you'll make me very sad. Instead, say N
> + and move your firmware to the utopian future that was 2016.
> +
> config ARM_SMMU_DISABLE_BYPASS_BY_DEFAULT
> bool "Default to disabling bypass on ARM SMMU v1 and v2"
> depends on ARM_SMMU
> diff --git a/drivers/iommu/arm-smmu-impl.c b/drivers/iommu/arm-smmu-impl.c
> index 5c87a38620c4..2f82d40317d6 100644
> --- a/drivers/iommu/arm-smmu-impl.c
> +++ b/drivers/iommu/arm-smmu-impl.c
> @@ -5,6 +5,7 @@
> #define pr_fmt(fmt) "arm-smmu: " fmt
>
> #include <linux/bitfield.h>
> +#include <linux/module.h>
> #include <linux/of.h>
>
> #include "arm-smmu.h"
> @@ -172,3 +173,8 @@ struct arm_smmu_device *arm_smmu_impl_init(struct arm_smmu_device *smmu)
>
> return smmu;
> }
> +EXPORT_SYMBOL_GPL(arm_smmu_impl_init);
> +
> +MODULE_DESCRIPTION("IOMMU quirks for ARM architected SMMU implementations");
> +MODULE_AUTHOR("Robin Murphy <robin.murphy@xxxxxxx>");
> +MODULE_LICENSE("GPL v2");
Hi Will,

A minor comment: I was curious about why arm-smmu.c and arm-smmu-impl.c
were being compiled as two separate modules, as opposed to combining
them into one module? The latter approach seemed more appropriate, given
that arm-smmu-impl doesn't offer much as a module on its own. Thoughts?

--Isaac