[PATCH RFC 2/2] iommu/dma: skip swiotlb bounce for DMA_ATTR_MMIO in dma_iova_link()
From: Peng Fan (OSS)
Date: Wed Sep 16 2026 - 12:29:11 EST
From: Peng Fan <peng.fan@xxxxxxx>
Same issue as the iommu_dma_map_phys() fix: MMIO resources never need
swiotlb bounce buffering, but dma_iova_link() enters the swiotlb path
when the physical address is not page-aligned, then rejects the mapping
with -EPERM.
Move the DMA_ATTR_MMIO check before the swiotlb block so the entire bounce
path is skipped for MMIO, falling through directly to __dma_iova_link()
which creates the IOMMU mapping.
Fixes: c288d657dd515 ("iommu/dma: implement DMA_ATTR_MMIO for dma_iova_link().")
Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
---
drivers/iommu/dma-iommu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index 26b9c2d71cd30..6807430ee3ab0 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -1998,9 +1998,9 @@ int dma_iova_link(struct device *dev, struct dma_iova_state *state,
if (!dev_is_dma_coherent(dev) && (attrs & DMA_ATTR_REQUIRE_COHERENT))
return -EOPNOTSUPP;
- if (dev_use_swiotlb(dev, size, dir) &&
+ if (!(attrs & DMA_ATTR_MMIO) && dev_use_swiotlb(dev, size, dir) &&
iova_unaligned(iovad, phys, size)) {
- if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))
+ if (attrs & DMA_ATTR_REQUIRE_COHERENT)
return -EPERM;
return iommu_dma_iova_link_swiotlb(dev, state, phys, offset,
--
2.34.1