Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp76516pxu; Wed, 25 Nov 2020 13:32:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxx1AZ+iz2z2RQ0oWBA3AmdzqSTqEBumElbDCdkfd6yvJ5hz9FPUC0mlPygMQodGedakyfH X-Received: by 2002:a05:6402:8d5:: with SMTP id d21mr5329884edz.11.1606339965723; Wed, 25 Nov 2020 13:32:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606339965; cv=none; d=google.com; s=arc-20160816; b=etddNB66lnuwR3wZ1Vd759cEmUtPbC8q/gufXyx2BRLHSr8CzvkbaxHVNBtmeVhwr3 489L+xDrwaFsJZfXP3njORE/if9VFpFSS0+HghP3W5sZTnCO+ySz2+k2V7BXSbJCqcSz bB3IK0gJQmRjH+woRJhlpsyWmu1VSPGhNt3c1kz6SWf9LA0XRKetKruOZpadfHbwi1HC 9I6cgvfkSnBN+w3EKR+S4FVP3nKrE2uvX8+lRDPKpqI29aANBwWIrmZ6apRDeVEczWj1 KEP81Y8S3wx6PD9H0yssv+Ph4PXlpHmmFAhWkaWd7RHSVnSvz40VPtmWXIBkgwe4dAmZ 8oQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=0Ialwnp+hWDTkMzoNPeCC0HNpKx9N0SykF0rG8AvZ6Y=; b=ziO6oY00cgZh/nC8obasqw3vt6pkd46DEXuPHSh05/pVlhS7hDvbXFcQo0em75Coxs sEHrzqf2ABxpXbERHF+XdicBja9qLBbRZkYeYGTBvVavu8R22Qm1qFQoGhRnwXmETfLk 9pvNTZYREUDf+ADe51OwFbBOzsKxNKM6/WHI+UyExiyQbBGacJ8Ut7vAdZUIcMV5Svkd V2XXMn8Wx0D0kJwQLzLp6yU+P2/kO0SjJoX9qzsGnJp9LmkWuyEJL+TSQoyqJhoplLY6 oxsSthRF95MAMtMf1obSLJtFvMXaiIQvYjG1MZxdUYFWbQcrQqkIMmo/dG0Juc/xk/Xx KXJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l12si1907854edq.55.2020.11.25.13.32.23; Wed, 25 Nov 2020 13:32:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731562AbgKYQiM (ORCPT + 99 others); Wed, 25 Nov 2020 11:38:12 -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); >