Migrate ARM SMMU to implement iova_to_phys_length, calling
ops->iova_to_phys_length on the io-pgtable layer. Update qcom-debug
caller accordingly.

Signed-off-by: Guanghui Feng <[email protected]>
---
 drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c |  2 +-
 drivers/iommu/arm/arm-smmu/arm-smmu.c            | 15 +++++++++------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c 
b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c
index 65e0ef6539fe..4fd01341157f 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c
@@ -415,7 +415,7 @@ irqreturn_t qcom_smmu_context_fault(int irq, void *dev)
                return IRQ_HANDLED;
        }
 
-       phys_soft = ops->iova_to_phys(ops, cfi.iova);
+       phys_soft = ops->iova_to_phys_length(ops, cfi.iova, NULL);
 
        tmp = report_iommu_fault(&smmu_domain->domain, NULL, cfi.iova,
                                 cfi.fsynr & ARM_SMMU_CB_FSYNR0_WNR ? 
IOMMU_FAULT_WRITE : IOMMU_FAULT_READ);
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c 
b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 0bd21d206eb3..dfbd541f9e3e 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -1366,7 +1366,7 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct 
iommu_domain *domain,
                        "iova to phys timed out on %pad. Falling back to 
software table walk.\n",
                        &iova);
                arm_smmu_rpm_put(smmu);
-               return ops->iova_to_phys(ops, iova);
+               return ops->iova_to_phys_length(ops, iova, NULL);
        }
 
        phys = arm_smmu_cb_readq(smmu, idx, ARM_SMMU_CB_PAR);
@@ -1384,20 +1384,23 @@ static phys_addr_t arm_smmu_iova_to_phys_hard(struct 
iommu_domain *domain,
        return addr;
 }
 
-static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
-                                       dma_addr_t iova)
+static phys_addr_t arm_smmu_iova_to_phys_length(struct iommu_domain *domain,
+                                       dma_addr_t iova, size_t *mapped_length)
 {
        struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
        struct io_pgtable_ops *ops = smmu_domain->pgtbl_ops;
 
+       if (mapped_length)
+               *mapped_length = 0;
+
        if (!ops)
-               return 0;
+               return PHYS_ADDR_MAX;
 
        if (smmu_domain->smmu->features & ARM_SMMU_FEAT_TRANS_OPS &&
                        smmu_domain->stage == ARM_SMMU_DOMAIN_S1)
                return arm_smmu_iova_to_phys_hard(domain, iova);
 
-       return ops->iova_to_phys(ops, iova);
+       return ops->iova_to_phys_length(ops, iova, mapped_length);
 }
 
 static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
@@ -1652,7 +1655,7 @@ static const struct iommu_ops arm_smmu_ops = {
                .unmap_pages            = arm_smmu_unmap_pages,
                .flush_iotlb_all        = arm_smmu_flush_iotlb_all,
                .iotlb_sync             = arm_smmu_iotlb_sync,
-               .iova_to_phys           = arm_smmu_iova_to_phys,
+               .iova_to_phys_length    = arm_smmu_iova_to_phys_length,
                .set_pgtable_quirks     = arm_smmu_set_pgtable_quirks,
                .free                   = arm_smmu_domain_free,
        }
-- 
2.43.7

Reply via email to