Re: [PATCH v3 01/32] iommu: introduce iova_to_phys_length in iommu_domain_ops

From: Baolu Lu

Date: Wed Jun 03 2026 - 22:46:07 EST


On 6/3/26 23:17, Guanghui Feng wrote:
Add iova_to_phys_length callback to struct iommu_domain_ops alongside
the existing iova_to_phys. The new callback returns both the physical
address and the PTE mapping page size in a single page table walk.

Add iommu_iova_to_phys_length() core function that:
- Checks ops->iova_to_phys_length first (preferred path)
- Falls back to ops->iova_to_phys for unmigrated drivers

This enables callers like VFIO to efficiently traverse IOVA space
by actual mapping granularity instead of fixed PAGE_SIZE steps.

Signed-off-by: Guanghui Feng<guanghuifeng@xxxxxxxxxxxxxxxxx>
Acked-by: Shiqiang Zhang<shiyu.zsq@xxxxxxxxxxxxxxxxx>
Acked-by: Simon Guo<wei.guo.simon@xxxxxxxxxxxxxxxxx>
---
drivers/iommu/iommu.c | 50 ++++++++++++++++++++++++++++++++++++++-----
include/linux/iommu.h | 9 ++++++++
2 files changed, 54 insertions(+), 5 deletions(-)

Reviewed-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>