[PATCH 0/9] iommu: introduce iova_to_phys_length for efficient IOVA-to-physical translation

From: Guanghui Feng

Date: Sun May 31 2026 - 05:39:18 EST


This series introduces a new iova_to_phys_length() interface across the
IOMMU subsystem that returns both the physical address and the PTE mapping
page size in a single page-table walk.

Motivation:

The existing iova_to_phys() only returns a physical address without any
information about the page size of the underlying PTE mapping. Callers
like VFIO and iommufd that need to traverse IOVA ranges are forced to
walk one PAGE_SIZE step at a time, even when the IOMMU has mapped large
regions using 2MB or 1GB huge pages. This results in O(n) page-table
walks where O(1) would suffice per mapping entry.

Approach:

The new callback .iova_to_phys_length returns the physical address and
sets *mapped_length to the PTE page size (e.g. 4KB, 2MB, 1GB). This
allows callers to skip ahead by the actual mapping granularity.

The migration follows an add-migrate-remove pattern to ensure every
commit in this series compiles independently (bisectable):

1. Add the new interface with fallback to legacy iova_to_phys
2. Migrate all IOMMU drivers (io-pgtable, generic_pt, per-SoC)
3. Migrate callers (VFIO, iommufd, DRM)
4. Remove the deprecated iova_to_phys from ops structs

Performance impact:

For VFIO unmap of a 2MB region mapped with 2MB pages, this reduces
page-table walks from 512 (PAGE_SIZE steps) to 1 (one per 2MB PTE),
a ~512x improvement in that path.

Guanghui Feng (9):
iommu: introduce iova_to_phys_length in iommu_domain_ops
iommu/io-pgtable: introduce iova_to_phys_length in io_pgtable_ops
iommu/generic_pt: implement iova_to_phys_length
iommu/arm-smmu: implement iova_to_phys_length
iommu: apple-dart/ipmmu/mtk_iommu implement iova_to_phys_length
iommu: direct page-table drivers implement iova_to_phys_length
vfio/iommufd: use iova_to_phys_length for efficient unmap
drm/gpu, iommu/io-pgtable: switch to iova_to_phys_length
iommu: remove deprecated iova_to_phys from domain_ops and
io_pgtable_ops

drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +-
drivers/gpu/drm/panthor/panthor_mmu.c | 2 +-
drivers/iommu/apple-dart.c | 11 +--
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++-
.../iommu/arm/arm-smmu/arm-smmu-qcom-debug.c | 2 +-
drivers/iommu/arm/arm-smmu/arm-smmu.c | 13 ++--
drivers/iommu/arm/arm-smmu/qcom_iommu.c | 11 +--
drivers/iommu/exynos-iommu.c | 21 ++++--
drivers/iommu/fsl_pamu_domain.c | 26 ++++++-
drivers/iommu/generic_pt/iommu_pt.h | 49 ++++++++-----
drivers/iommu/io-pgtable-arm-selftests.c | 12 ++--
drivers/iommu/io-pgtable-arm-v7s.c | 25 ++++---
drivers/iommu/io-pgtable-arm.c | 14 ++--
drivers/iommu/io-pgtable-dart.c | 17 +++--
drivers/iommu/iommu.c | 30 +++++++-
drivers/iommu/iommufd/pages.c | 71 +++++++++++++++----
drivers/iommu/iommufd/selftest.c | 2 +-
drivers/iommu/ipmmu-vmsa.c | 12 ++--
drivers/iommu/msm_iommu.c | 25 +++++--
drivers/iommu/mtk_iommu.c | 12 ++--
drivers/iommu/mtk_iommu_v1.c | 15 +++-
drivers/iommu/omap-iommu.c | 32 ++++++---
drivers/iommu/rockchip-iommu.c | 11 ++-
drivers/iommu/s390-iommu.c | 15 ++--
drivers/iommu/sprd-iommu.c | 13 +++-
drivers/iommu/sun50i-iommu.c | 13 +++-
drivers/iommu/tegra-smmu.c | 12 +++-
drivers/iommu/virtio-iommu.c | 13 +++-
drivers/vfio/vfio_iommu_type1.c | 24 +++++--
include/linux/generic_pt/iommu.h | 13 ++--
include/linux/io-pgtable.h | 10 ++-
include/linux/iommu.h | 12 +++-
32 files changed, 404 insertions(+), 146 deletions(-)

--
2.43.7