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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FA9CC56201 for ; Wed, 25 Nov 2020 16:38:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C537A2083E for ; Wed, 25 Nov 2020 16:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731960AbgKYQiN (ORCPT ); Wed, 25 Nov 2020 11:38:13 -0500 Received: from foss.arm.com ([217.140.110.172]:58446 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730362AbgKYQiM (ORCPT ); Wed, 25 Nov 2020 11:38:12 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B928F31B; Wed, 25 Nov 2020 08:38:11 -0800 (PST) Received: from [10.57.59.159] (unknown [10.57.59.159]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 46E283F7BB; Wed, 25 Nov 2020 08:38:09 -0800 (PST) Subject: Re: [PATCH v2 2/6] iommu: Add iova and size as parameters in iommu_iotlb_map To: Yong Wu , Joerg Roedel , Will Deacon Cc: Matthias Brugger , Krzysztof Kozlowski , Tomasz Figa , linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, youlin.pei@mediatek.com, Nicolas Boichat , anan.sun@mediatek.com, chao.hao@mediatek.com, jun.wen@mediatek.com References: <20201119061836.15238-1-yong.wu@mediatek.com> <20201119061836.15238-3-yong.wu@mediatek.com> From: Robin Murphy Message-ID: Date: Wed, 25 Nov 2020 16:38:08 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <20201119061836.15238-3-yong.wu@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-19 06:18, Yong Wu wrote: > iotlb_sync_map allow IOMMU drivers tlb sync after completing the whole > mapping. This patch adds iova and size as the parameters in it. then the > IOMMU driver could flush tlb with the whole range once after iova mapping > to improve performance. Reviewed-by: Robin Murphy > Signed-off-by: Yong Wu > --- > drivers/iommu/iommu.c | 6 +++--- > drivers/iommu/tegra-gart.c | 3 ++- > include/linux/iommu.h | 3 ++- > 3 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index decef851fa3a..df87c8e825f7 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -2425,7 +2425,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, > might_sleep(); > ret = __iommu_map(domain, iova, paddr, size, prot, GFP_KERNEL); > if (ret == 0 && ops->iotlb_sync_map) > - ops->iotlb_sync_map(domain); > + ops->iotlb_sync_map(domain, iova, size); > > return ret; > } > @@ -2439,7 +2439,7 @@ int iommu_map_atomic(struct iommu_domain *domain, unsigned long iova, > > ret = __iommu_map(domain, iova, paddr, size, prot, GFP_ATOMIC); > if (ret == 0 && ops->iotlb_sync_map) > - ops->iotlb_sync_map(domain); > + ops->iotlb_sync_map(domain, iova, size); > > return ret; > } > @@ -2557,7 +2557,7 @@ static size_t __iommu_map_sg(struct iommu_domain *domain, unsigned long iova, > } > > if (ops->iotlb_sync_map) > - ops->iotlb_sync_map(domain); > + ops->iotlb_sync_map(domain, iova, mapped); > return mapped; > > out_err: > diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c > index fac720273889..d15d13a98ed1 100644 > --- a/drivers/iommu/tegra-gart.c > +++ b/drivers/iommu/tegra-gart.c > @@ -261,7 +261,8 @@ static int gart_iommu_of_xlate(struct device *dev, > return 0; > } > > -static void gart_iommu_sync_map(struct iommu_domain *domain) > +static void gart_iommu_sync_map(struct iommu_domain *domain, unsigned long iova, > + size_t size) > { > FLUSH_GART_REGS(gart_handle); > } > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index b95a6f8db6ff..794d4085edd3 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -244,7 +244,8 @@ struct iommu_ops { > size_t (*unmap)(struct iommu_domain *domain, unsigned long iova, > size_t size, struct iommu_iotlb_gather *iotlb_gather); > void (*flush_iotlb_all)(struct iommu_domain *domain); > - void (*iotlb_sync_map)(struct iommu_domain *domain); > + void (*iotlb_sync_map)(struct iommu_domain *domain, unsigned long iova, > + size_t size); > void (*iotlb_sync)(struct iommu_domain *domain, > struct iommu_iotlb_gather *iotlb_gather); > phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova); >