Migrate MediaTek IOMMU to implement iova_to_phys_length, passing through
mapped_length from io-pgtable.

Signed-off-by: Guanghui Feng <[email protected]>
---
 drivers/iommu/mtk_iommu.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 2be990c108de..58125f029214 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -858,13 +858,19 @@ static int mtk_iommu_sync_map(struct iommu_domain 
*domain, unsigned long iova,
        return 0;
 }
 
-static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,
-                                         dma_addr_t iova)
+static phys_addr_t mtk_iommu_iova_to_phys_length(struct iommu_domain *domain,
+                                         dma_addr_t iova, size_t 
*mapped_length)
 {
        struct mtk_iommu_domain *dom = to_mtk_domain(domain);
        phys_addr_t pa;
 
-       pa = dom->iop->iova_to_phys(dom->iop, iova);
+       if (mapped_length)
+               *mapped_length = 0;
+
+       pa = dom->iop->iova_to_phys_length(dom->iop, iova, mapped_length);
+       if (pa == PHYS_ADDR_MAX)
+               return PHYS_ADDR_MAX;
+
        if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) &&
            dom->bank->parent_data->enable_4GB &&
            pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE)
@@ -1070,7 +1076,7 @@ static const struct iommu_ops mtk_iommu_ops = {
                .flush_iotlb_all = mtk_iommu_flush_iotlb_all,
                .iotlb_sync     = mtk_iommu_iotlb_sync,
                .iotlb_sync_map = mtk_iommu_sync_map,
-               .iova_to_phys   = mtk_iommu_iova_to_phys,
+               .iova_to_phys_length = mtk_iommu_iova_to_phys_length,
                .free           = mtk_iommu_domain_free,
        }
 };
-- 
2.43.7

Reply via email to