public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Guanghui Feng <guanghuifeng@linux•alibaba.com>
To: boris.brezillon@collabora•com, robh@kernel•org,
	steven.price@arm•com, adrian.larumbe@collabora•com,
	maarten.lankhorst@linux•intel.com, mripard@kernel•org,
	tzimmermann@suse•de, airlied@gmail•com, liviu.dudau@arm•com,
	joro@8bytes•org, will@kernel•org, robin.murphy@arm•com,
	alex@shazbot•org, dri-devel@lists•freedesktop.org,
	linux-kernel@vger•kernel.org, iommu@lists•linux.dev,
	kvm@vger•kernel.org, linux-arm-kernel@lists•infradead.org,
	jgg@ziepe•ca, kevin.tian@intel•com, baolu.lu@linux•intel.com,
	suravee.suthikulpanit@amd•com, dwmw2@infradead•org
Cc: xlpang@linux•alibaba.com, oliver.yang@linux•alibaba.com,
	shiyu.zsq@linux•alibaba.com, wei.guo.simon@linux•alibaba.com
Subject: [PATCH 4/9] iommu/arm-smmu: implement iova_to_phys_length
Date: Sun, 31 May 2026 17:36:32 +0800	[thread overview]
Message-ID: <20260531093637.3893199-5-guanghuifeng@linux.alibaba.com> (raw)
In-Reply-To: <20260531093637.3893199-1-guanghuifeng@linux.alibaba.com>

Migrate ARM SMMU drivers to implement iova_to_phys_length, calling
ops->iova_to_phys_length on the io-pgtable layer to get both phys
and PTE page size.

Signed-off-by: Guanghui Feng <guanghuifeng@linux•alibaba.com>
Acked-by: Shiqiang Zhang <shiyu.zsq@linux•alibaba.com>
Acked-by: Simon Guo <wei.guo.simon@linux•alibaba.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c      | 10 +++++++---
 drivers/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 +++++++----
 4 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index e8d7dbe495f0..c9f356c75bc5 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -4069,14 +4069,18 @@ static void arm_smmu_iotlb_sync(struct iommu_domain *domain,
 }
 
 static phys_addr_t
-arm_smmu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
+arm_smmu_iova_to_phys_length(struct iommu_domain *domain, dma_addr_t iova,
+			     size_t *mapped_length)
 {
 	struct io_pgtable_ops *ops = to_smmu_domain(domain)->pgtbl_ops;
 
+	if (mapped_length)
+		*mapped_length = 0;
+
 	if (!ops)
 		return 0;
 
-	return ops->iova_to_phys(ops, iova);
+	return ops->iova_to_phys_length(ops, iova, mapped_length);
 }
 
 static struct platform_driver arm_smmu_driver;
@@ -4396,7 +4400,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,
 		.free			= arm_smmu_domain_free_paging,
 	}
 };
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..e29e0ea12f24 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,12 +1384,15 @@ 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;
 
@@ -1397,7 +1400,7 @@ static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
 			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,
 	}
diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
index a1e8cf29f594..08bb6fce992f 100644
--- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c
+++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c
@@ -489,19 +489,22 @@ static void qcom_iommu_iotlb_sync(struct iommu_domain *domain,
 	qcom_iommu_flush_iotlb_all(domain);
 }
 
-static phys_addr_t qcom_iommu_iova_to_phys(struct iommu_domain *domain,
-					   dma_addr_t iova)
+static phys_addr_t qcom_iommu_iova_to_phys_length(struct iommu_domain *domain,
+					   dma_addr_t iova, size_t *mapped_length)
 {
 	phys_addr_t ret;
 	unsigned long flags;
 	struct qcom_iommu_domain *qcom_domain = to_qcom_iommu_domain(domain);
 	struct io_pgtable_ops *ops = qcom_domain->pgtbl_ops;
 
+	if (mapped_length)
+		*mapped_length = 0;
+
 	if (!ops)
 		return 0;
 
 	spin_lock_irqsave(&qcom_domain->pgtbl_lock, flags);
-	ret = ops->iova_to_phys(ops, iova);
+	ret = ops->iova_to_phys_length(ops, iova, mapped_length);
 	spin_unlock_irqrestore(&qcom_domain->pgtbl_lock, flags);
 
 	return ret;
@@ -602,7 +605,7 @@ static const struct iommu_ops qcom_iommu_ops = {
 		.unmap_pages	= qcom_iommu_unmap,
 		.flush_iotlb_all = qcom_iommu_flush_iotlb_all,
 		.iotlb_sync	= qcom_iommu_iotlb_sync,
-		.iova_to_phys	= qcom_iommu_iova_to_phys,
+		.iova_to_phys_length = qcom_iommu_iova_to_phys_length,
 		.free		= qcom_iommu_domain_free,
 	}
 };
-- 
2.43.7



  parent reply	other threads:[~2026-05-31  9:37 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260529115116.GR2487554@ziepe.ca>
2026-05-31  9:36 ` [PATCH 0/9] iommu: introduce iova_to_phys_length for efficient IOVA-to-physical translation Guanghui Feng
2026-05-31  9:36   ` [PATCH 1/9] iommu: introduce iova_to_phys_length in iommu_domain_ops Guanghui Feng
2026-05-31 23:51     ` Jason Gunthorpe
2026-06-01  8:41       ` guanghuifeng
2026-06-01 13:43         ` Jason Gunthorpe
2026-06-01 14:14           ` guanghuifeng
2026-06-01 14:31             ` Jason Gunthorpe
2026-05-31  9:36   ` [PATCH 2/9] iommu/io-pgtable: introduce iova_to_phys_length in io_pgtable_ops Guanghui Feng
2026-05-31  9:36   ` [PATCH 3/9] iommu/generic_pt: implement iova_to_phys_length Guanghui Feng
2026-05-31 23:54     ` Jason Gunthorpe
2026-06-01  9:23       ` guanghuifeng
     [not found]       ` <fa924b86-1ca9-4819-8330-0d5f6ede8923@linux.alibaba.com>
2026-06-01 14:32         ` Jason Gunthorpe
2026-06-02  7:20       ` guanghuifeng
2026-06-02 12:32         ` Jason Gunthorpe
2026-05-31  9:36   ` Guanghui Feng [this message]
2026-05-31  9:36   ` [PATCH 5/9] iommu: apple-dart/ipmmu/mtk_iommu " Guanghui Feng
2026-05-31  9:36   ` [PATCH 6/9] iommu: direct page-table drivers " Guanghui Feng
2026-05-31  9:36   ` [PATCH 7/9] vfio/iommufd: use iova_to_phys_length for efficient unmap Guanghui Feng
2026-05-31 23:58     ` Jason Gunthorpe
2026-05-31  9:36   ` [PATCH 8/9] drm/gpu, iommu/io-pgtable: switch to iova_to_phys_length Guanghui Feng
2026-05-31  9:36   ` [PATCH 9/9] iommu: remove deprecated iova_to_phys from domain_ops and io_pgtable_ops Guanghui Feng
2026-06-02 10:46   ` [PATCH v2 00/30] iommu: introduce iova_to_phys_length for efficient IOVA-to-physical translation Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 01/30] iommu: introduce iova_to_phys_length in iommu_domain_ops Guanghui Feng
2026-06-03  1:08       ` Jason Gunthorpe
2026-06-02 10:46     ` [PATCH v2 02/30] iommu/io-pgtable-arm: introduce iova_to_phys_length in io_pgtable_ops Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 03/30] iommu/io-pgtable-arm-v7s: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 04/30] iommu/io-pgtable-dart: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 05/30] iommu/generic_pt: implement iova_to_phys_length Guanghui Feng
2026-06-03  1:11       ` Jason Gunthorpe
2026-06-02 10:46     ` [PATCH v2 06/30] iommu/arm-smmu-v3: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 07/30] iommu/arm-smmu: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 08/30] iommu/qcom_iommu: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 09/30] iommu/apple-dart: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 10/30] iommu/ipmmu-vmsa: " Guanghui Feng
2026-06-03  1:13       ` Jason Gunthorpe
2026-06-02 10:46     ` [PATCH v2 11/30] iommu/mtk_iommu: " Guanghui Feng
2026-06-03  1:17       ` Jason Gunthorpe
2026-06-02 10:46     ` [PATCH v2 12/30] iommu/exynos: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 13/30] iommu/fsl_pamu: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 14/30] iommu/msm: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 15/30] iommu/mtk_v1: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 16/30] iommu/omap: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 17/30] iommu/rockchip: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 18/30] iommu/s390: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 19/30] iommu/sprd: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 20/30] iommu/sun50i: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 21/30] iommu/tegra-smmu: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 22/30] iommu/virtio: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 23/30] vfio/iommufd: use iova_to_phys_length for efficient unmap Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 24/30] drm/panfrost: switch to iova_to_phys_length Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 25/30] drm/panthor: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 26/30] iommu/io-pgtable: selftests " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 27/30] iommu/io-pgtable-arm: remove deprecated iova_to_phys wrapper Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 28/30] iommu/io-pgtable-arm-v7s: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 29/30] iommu/io-pgtable-dart: " Guanghui Feng
2026-06-02 10:46     ` [PATCH v2 30/30] iommu: remove iova_to_phys from domain_ops and io_pgtable_ops Guanghui Feng
2026-06-03 15:17     ` [PATCH v3 00/32] iommu: introduce iova_to_phys_length and remove iova_to_phys Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 01/32] iommu: introduce iova_to_phys_length in iommu_domain_ops Guanghui Feng
2026-06-04  2:44         ` Baolu Lu
2026-06-04 14:16         ` Jason Gunthorpe
2026-06-03 15:17       ` [PATCH v3 02/32] iommu/io-pgtable-arm: introduce iova_to_phys_length in io_pgtable_ops Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 03/32] iommu/io-pgtable-arm-v7s: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 04/32] iommu/io-pgtable-dart: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 05/32] iommu/generic_pt: implement iova_to_phys_length Guanghui Feng
2026-06-04  3:30         ` Baolu Lu
2026-06-04 14:12           ` Jason Gunthorpe
2026-06-03 15:17       ` [PATCH v3 06/32] iommu/arm-smmu-v3: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 07/32] iommu/arm-smmu: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 08/32] iommu/qcom_iommu: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 09/32] iommu/apple-dart: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 10/32] iommu/ipmmu-vmsa: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 11/32] iommu/mtk_iommu: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 12/32] iommu/exynos: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 13/32] iommu/fsl_pamu: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 14/32] iommu/msm: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 15/32] iommu/mtk_v1: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 16/32] iommu/omap: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 17/32] iommu/rockchip: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 18/32] iommu/s390: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 19/32] iommu/sprd: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 20/32] iommu/sun50i: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 21/32] iommu/tegra-smmu: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 22/32] iommu/virtio: " Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 23/32] vfio: use iova_to_phys_length for efficient unmap Guanghui Feng
2026-06-04 14:27         ` Jason Gunthorpe
2026-06-03 15:17       ` [PATCH v3 24/32] iommufd: " Guanghui Feng
2026-06-04 14:26         ` Jason Gunthorpe
2026-06-03 15:17       ` [PATCH v3 25/32] iommufd/selftest: switch to iommu_iova_to_phys_length Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 26/32] drm/panfrost: switch to iova_to_phys_length Guanghui Feng
2026-06-03 15:17       ` [PATCH v3 27/32] drm/panthor: " Guanghui Feng
2026-06-03 15:18       ` [PATCH v3 28/32] iommu/io-pgtable: selftests " Guanghui Feng
2026-06-03 15:18       ` [PATCH v3 29/32] iommu/io-pgtable-arm: remove deprecated iova_to_phys wrapper Guanghui Feng
2026-06-03 15:18       ` [PATCH v3 30/32] iommu/io-pgtable-arm-v7s: " Guanghui Feng
2026-06-03 15:18       ` [PATCH v3 31/32] iommu/io-pgtable-dart: " Guanghui Feng
2026-06-03 15:18       ` [PATCH v3 32/32] iommu: remove iova_to_phys from domain_ops and io_pgtable_ops Guanghui Feng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260531093637.3893199-5-guanghuifeng@linux.alibaba.com \
    --to=guanghuifeng@linux$(echo .)alibaba.com \
    --cc=adrian.larumbe@collabora$(echo .)com \
    --cc=airlied@gmail$(echo .)com \
    --cc=alex@shazbot$(echo .)org \
    --cc=baolu.lu@linux$(echo .)intel.com \
    --cc=boris.brezillon@collabora$(echo .)com \
    --cc=dri-devel@lists$(echo .)freedesktop.org \
    --cc=dwmw2@infradead$(echo .)org \
    --cc=iommu@lists$(echo .)linux.dev \
    --cc=jgg@ziepe$(echo .)ca \
    --cc=joro@8bytes$(echo .)org \
    --cc=kevin.tian@intel$(echo .)com \
    --cc=kvm@vger$(echo .)kernel.org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=liviu.dudau@arm$(echo .)com \
    --cc=maarten.lankhorst@linux$(echo .)intel.com \
    --cc=mripard@kernel$(echo .)org \
    --cc=oliver.yang@linux$(echo .)alibaba.com \
    --cc=robh@kernel$(echo .)org \
    --cc=robin.murphy@arm$(echo .)com \
    --cc=shiyu.zsq@linux$(echo .)alibaba.com \
    --cc=steven.price@arm$(echo .)com \
    --cc=suravee.suthikulpanit@amd$(echo .)com \
    --cc=tzimmermann@suse$(echo .)de \
    --cc=wei.guo.simon@linux$(echo .)alibaba.com \
    --cc=will@kernel$(echo .)org \
    --cc=xlpang@linux$(echo .)alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox