[PATCH 0/4] iommu/dma: restore flush queue use in dma_iova_destroy()

From: Marek Szyprowski

Date: Fri Nov 27 2026 - 06:59:38 EST


Hi,

Commit 1acce29926d9 ("iommu/dma: simplify dma_iova_destroy() and drop
the free_iova helper") made dma_iova_destroy() always invalidate the
IOTLB synchronously and free the IOVA directly, bypassing the flush
queue on DMA-FQ domains. As Sibi reported [1], this makes iommu.strict=0
ineffective for NVMe I/O (blk_rq_dma_map()) and costs about 4x of
sequential throughput on SMMUv3 without RANGE_INV.

This series is an alternative to the revert proposed in [1]. Instead of
restoring the free_iova flag, dma_iova_try_alloc() decides once whether
the IOVA space is going to be released through the flush queue and
records that in a new DMA_IOVA_USE_FQ flag in dma_iova_state::__size,
next to DMA_IOVA_USE_SWIOTLB, so struct dma_iova_state does not grow.
dma_iova_destroy() then unmaps with a gather queued according to that
flag and retires it together with the IOVA free, exactly like
__iommu_dma_unmap(): either by iommu_iotlb_sync() or by handing the
IOVA (and any released page table pages) over to the flush queue. The
gather is never left dangling and the IOVA is never returned to the
allocator before a pending queued invalidation, as pointed out by Jason.
dma_iova_unlink() stays strict, as the unlinked range remains owned by
the caller and may be linked again right away. The whole reservation is
still freed, keeping the size fix of the original cleanup.

Storing a flag in the upper bits of __size requires that nobody reads
__size directly, so patches 1-2 convert the venus and iris IOVA
reservation code to dma_iova_size() and patch 3 adds a DMA_IOVA_FLAGS
mask used by dma_iova_size(), dma_iova_try_alloc() and the vfio-pci
dma-buf length check. Patch 4 is the actual fix.

The series has been developped with an aid of LLM, build tested on arm64
and x86_64. Sibi, it would be great if you could rerun your fio test on
top of it.

[1] https://lore.kernel.org/all/20261125135120.1126571-1-sibi.sankar@xxxxxxxxxxxxxxxx/

Best regards
Marek Szyprowski, PhD
Samsung R&D Institute Poland


Patch summary:

Marek Szyprowski (4):
media: venus: use dma_iova_size() to check the reserved IOVA size
media: iris: use dma_iova_size() to check the reserved IOVA size
dma-mapping: add DMA_IOVA_FLAGS mask for the dma_iova_state size flags
iommu/dma: restore flush queue use in dma_iova_destroy()

drivers/iommu/dma-iommu.c | 111 +++++++++++++-----
drivers/media/platform/qcom/iris/iris_probe.c | 3 +-
drivers/media/platform/qcom/venus/core.c | 3 +-
drivers/vfio/pci/vfio_pci_dmabuf.c | 2 +-
include/linux/dma-mapping.h | 14 ++-
5 files changed, 98 insertions(+), 35 deletions(-)

--
2.43.0