From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61FCBCD6E5D for ; Sun, 31 May 2026 13:58:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E861112B54; Sun, 31 May 2026 13:58:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="ZU/GV54L"; dkim-atps=neutral Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB84410E5C0 for ; Sun, 31 May 2026 09:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1780220515; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=I124MUpdjyzqPwiXiO9Q5adcwpM3fxbXILO13MSKRkI=; b=ZU/GV54LPk3bp+fmqkFQ/ostUA+4lsAbzC34BozH0A5//95sHxnGSeIv2MalNC5+ZehHNK7Q9l0EdjWgFPCOC0m/cyX6NzdJKtYeFsxrn/daynvqMkMPUXWS1e2GER37ReU2KnpgOSjHTltIMM5DZNoLHDnrDaudbmGiEZu6FYE= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R691e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033037009110; MF=guanghuifeng@linux.alibaba.com; NM=1; PH=DS; RN=27; SR=0; TI=SMTPD_---0X3tRVpy_1780220211; Received: from VM20241011-104.tbsite.net(mailfrom:guanghuifeng@linux.alibaba.com fp:SMTPD_---0X3tRVpy_1780220211 cluster:ay36) by smtp.aliyun-inc.com; Sun, 31 May 2026 17:36:51 +0800 From: Guanghui Feng 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 5/9] iommu: apple-dart/ipmmu/mtk_iommu implement iova_to_phys_length Date: Sun, 31 May 2026 17:36:33 +0800 Message-ID: <20260531093637.3893199-6-guanghuifeng@linux.alibaba.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260531093637.3893199-1-guanghuifeng@linux.alibaba.com> References: <20260529115116.GR2487554@ziepe.ca> <20260531093637.3893199-1-guanghuifeng@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Sun, 31 May 2026 13:58:32 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Migrate remaining io-pgtable user drivers to implement iova_to_phys_length, passing through mapped_length from io-pgtable. Signed-off-by: Guanghui Feng Acked-by: Shiqiang Zhang Acked-by: Simon Guo --- drivers/iommu/apple-dart.c | 11 +++++++---- drivers/iommu/ipmmu-vmsa.c | 12 ++++++++---- drivers/iommu/mtk_iommu.c | 12 ++++++++---- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 17bdadb6b504..6f78bd28cee7 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -528,16 +528,19 @@ static int apple_dart_iotlb_sync_map(struct iommu_domain *domain, return 0; } -static phys_addr_t apple_dart_iova_to_phys(struct iommu_domain *domain, - dma_addr_t iova) +static phys_addr_t apple_dart_iova_to_phys_length(struct iommu_domain *domain, + dma_addr_t iova, size_t *mapped_length) { struct apple_dart_domain *dart_domain = to_dart_domain(domain); struct io_pgtable_ops *ops = dart_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 int apple_dart_map_pages(struct iommu_domain *domain, unsigned long iova, @@ -1018,7 +1021,7 @@ static const struct iommu_ops apple_dart_iommu_ops = { .flush_iotlb_all = apple_dart_flush_iotlb_all, .iotlb_sync = apple_dart_iotlb_sync, .iotlb_sync_map = apple_dart_iotlb_sync_map, - .iova_to_phys = apple_dart_iova_to_phys, + .iova_to_phys_length = apple_dart_iova_to_phys_length, .free = apple_dart_domain_free, } }; diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c index 9386b752dea2..a1b659ddbdb5 100644 --- a/drivers/iommu/ipmmu-vmsa.c +++ b/drivers/iommu/ipmmu-vmsa.c @@ -699,14 +699,18 @@ static void ipmmu_iotlb_sync(struct iommu_domain *io_domain, ipmmu_flush_iotlb_all(io_domain); } -static phys_addr_t ipmmu_iova_to_phys(struct iommu_domain *io_domain, - dma_addr_t iova) +static phys_addr_t ipmmu_iova_to_phys_length(struct iommu_domain *io_domain, + dma_addr_t iova, size_t *mapped_length) { struct ipmmu_vmsa_domain *domain = to_vmsa_domain(io_domain); + if (mapped_length) + *mapped_length = 0; + /* TODO: Is locking needed ? */ - return domain->iop->iova_to_phys(domain->iop, iova); + return domain->iop->iova_to_phys_length(domain->iop, iova, + mapped_length); } static int ipmmu_init_platform_device(struct device *dev, @@ -892,7 +896,7 @@ static const struct iommu_ops ipmmu_ops = { .unmap_pages = ipmmu_unmap, .flush_iotlb_all = ipmmu_flush_iotlb_all, .iotlb_sync = ipmmu_iotlb_sync, - .iova_to_phys = ipmmu_iova_to_phys, + .iova_to_phys_length = ipmmu_iova_to_phys_length, .free = ipmmu_domain_free, } }; diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 2be990c108de..214cab76e853 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -858,13 +858,17 @@ 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 (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && dom->bank->parent_data->enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE) @@ -1070,7 +1074,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