[PATCH v3 17/32] iommu/rockchip: implement iova_to_phys_length
From: Guanghui Feng
Date: Wed Jun 03 2026 - 12:08:17 EST
Implement iova_to_phys_length for Rockchip IOMMU driver,
returning the actual PTE mapping size.
Signed-off-by: Guanghui Feng <guanghuifeng@xxxxxxxxxxxxxxxxx>
---
drivers/iommu/rockchip-iommu.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index 0013cf196c57..a51c29340b98 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -648,12 +648,12 @@ static irqreturn_t rk_iommu_irq(int irq, void *dev_id)
return ret;
}
-static phys_addr_t rk_iommu_iova_to_phys(struct iommu_domain *domain,
- dma_addr_t iova)
+static phys_addr_t rk_iommu_iova_to_phys_length(struct iommu_domain *domain,
+ dma_addr_t iova, size_t *mapped_length)
{
struct rk_iommu_domain *rk_domain = to_rk_domain(domain);
unsigned long flags;
- phys_addr_t pt_phys, phys = 0;
+ phys_addr_t pt_phys, phys = PHYS_ADDR_MAX;
u32 dte, pte;
u32 *page_table;
@@ -670,6 +670,8 @@ static phys_addr_t rk_iommu_iova_to_phys(struct iommu_domain *domain,
goto out;
phys = rk_ops->pt_address(pte) + rk_iova_page_offset(iova);
+ if (mapped_length)
+ *mapped_length = SPAGE_SIZE;
out:
spin_unlock_irqrestore(&rk_domain->dt_lock, flags);
@@ -1187,7 +1189,7 @@ static const struct iommu_ops rk_iommu_ops = {
.attach_dev = rk_iommu_attach_device,
.map_pages = rk_iommu_map,
.unmap_pages = rk_iommu_unmap,
- .iova_to_phys = rk_iommu_iova_to_phys,
+ .iova_to_phys_length = rk_iommu_iova_to_phys_length,
.free = rk_iommu_domain_free,
}
};
--
2.43.7