[PATCH 05/11] ARM: dma-mapping: Bypass the legacy path for core-owned DMA API domains
From: Mikko Perttunen
Date: Mon Sep 14 2026 - 22:22:48 EST
ARM's arch_setup_dma_ops / arm_setup_iommu_dma_ops creates a custom
IOMMU domain for DMA API usage, and continues to do so when the IOMMU
driver doesn't explicitly request a DMA default domain type.
When, however, that DMA default domain is requested and the core owns
the domain, we need to skip our own domain management. Add checks to
arm_setup/teardown_iommu_dma_ops for these cases.
Signed-off-by: Mikko Perttunen <mperttunen@xxxxxxxxxx>
---
arch/arm/mm/dma-mapping.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index e0d58778c5f5..91f12fb91509 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -1761,9 +1761,18 @@ EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
static void arm_setup_iommu_dma_ops(struct device *dev)
{
- struct dma_iommu_mapping *mapping;
+ struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
u64 dma_base = 0, size = 1ULL << 32;
+ /*
+ * An existing cookie means the core owns the domain. Only set the
+ * per-binding DMA ops.
+ */
+ if (mapping) {
+ set_dma_ops(dev, &iommu_ops);
+ return;
+ }
+
if (dev->dma_range_map) {
dma_base = dma_range_map_min(dev->dma_range_map);
size = dma_range_map_max(dev->dma_range_map) - dma_base;
@@ -1792,6 +1801,9 @@ static void arm_teardown_iommu_dma_ops(struct device *dev)
if (!mapping)
return;
+ if (!mapping->owns_domain)
+ return;
+
arm_iommu_detach_device(dev);
arm_iommu_release_mapping(mapping);
}
--
2.55.0