From 57a8a9ea537284c74296b4f3f035881fc618bca9 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Tue, 7 Jul 2020 11:27:24 -0700 Subject: [PATCH] arm: dma-mapping: Use iommu_dma ops for arm32 Reuse the same code paths as arm64. Change-Id: I41d89b53b77abd14d6e2ae94e31145b2c7fb37c2 Signed-off-by: Patrick Daly --- arch/arm/mm/dma-mapping.c | 27 ++++++++++++++------------- drivers/iommu/Kconfig | 1 - 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 337496e53703..ba23f9059cf4 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -2489,8 +2490,9 @@ static void arm_iommu_get_dma_window(struct device *dev, u64 *dma_addr, *dma_size = of_read_number(ranges + naddr, nsize); } -static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, - const struct iommu_ops *iommu) +static bool __maybe_unused +arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, + const struct iommu_ops *iommu) { struct iommu_group *group; struct iommu_domain *domain; @@ -2550,8 +2552,9 @@ static void arm_teardown_iommu_dma_ops(struct device *dev) } #else -static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, - const struct iommu_ops *iommu) +static bool __maybe_unused +arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, + const struct iommu_ops *iommu) { return false; } @@ -2566,10 +2569,9 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, const struct iommu_ops *iommu, bool coherent) { const struct dma_map_ops *dma_ops; - struct dma_iommu_mapping *mapping; dev->archdata.dma_coherent = coherent; -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB) || defined(CONFIG_IOMMU_DMA) dev->dma_coherent = coherent; #endif @@ -2581,14 +2583,13 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, if (dev->dma_ops) return; - if (arm_setup_iommu_dma_ops(dev, dma_base, size, iommu)) { - mapping = to_dma_iommu_mapping(dev); - dma_ops = mapping->ops; - } else { - dma_ops = arm_get_dma_map_ops(coherent); - } + if (iommu) + iommu_setup_dma_ops(dev, dma_base, size); - set_dma_ops(dev, dma_ops); + if (!dev->dma_ops) { + dma_ops = arm_get_dma_map_ops(coherent); + set_dma_ops(dev, dma_ops); + } #ifdef CONFIG_XEN if (xen_initial_domain()) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index 329f8c15a1e0..3c482f6a978e 100644 --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -469,7 +469,6 @@ config ARM_SMMU depends on QCOM_SCM || !QCOM_SCM #if QCOM_SCM=m this can't be =y select IOMMU_API select IOMMU_IO_PGTABLE_LPAE - select ARM_DMA_USE_IOMMU if ARM help Support for implementations of the ARM System MMU architecture versions 1 and 2.