Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp264152pxu; Thu, 7 Jan 2021 04:32:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUr8x5QrL4iPY4AB1NwZTnv1TwVxCC5SdUKOH7pA9CIXmpCudKwZ9dR3V0wpOmfjQuaSvE X-Received: by 2002:a50:c053:: with SMTP id u19mr1516246edd.109.1610022763784; Thu, 07 Jan 2021 04:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610022763; cv=none; d=google.com; s=arc-20160816; b=mL9Rv4gODFkZGr5N6ZRH4WGjXI1Vv/FjbvVVCQU9fKFKDsakD6FsWSPR54eeqmiJSi exkxstawhO5lagU7jO/t3favcmVyjy/413zL4/E3Dpe9IXTUxgAnw0kMs6DSwhGQGmxu iwThL0qXkmbu+/xzuTkpLMnFu+78NWErRuEIFbp9uGNSl7gsRjP02mZMM4ZDwrxnH5Ma 2MTmbLF6faHFD7jG74JrTOBM2aREQxjtPIObBawaBz0jrIdV0FgzUOOxEgDPjNdonO4m 9IlxF0f7kkTb5lg/zZ2KW1GppOzCOijPrdGriOD6RmN+xlhd9fFe+mvahhsuIvZYb2mo 1o6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=YSzlSH1y+3AU/PGYg/nHSPO42W0w6oX2y6uQ9okhvXw=; b=qbD6siVxlFHhEvoW8T0XtQqdet+i8k8T3iqxfflm4A6bJnMNp5HK7CPoLU6zWdK/+w eJIthqFHi+tzlLDPRFXzbd1gzatYQ9g2UFbsuZgsdLu5VCybB1z+BOu8PYQnwqYu5CsX QyvVJLR6rcrUnxYz+cm7uboknwYJuxJY2KnpxrtxoUU93RtgSQWQve1NUV+QZsK41bSO Lf1ihZ3GZs+wlLbpYuH5EXGYDo7cpmLyfxtVZZS2Xm5NJGyYm7cDm2DLnUbnrIQRmi0m GhlNE/Q7mfcXclkyOUJnSBtZYHTNOKn+CcOQoDPpc+SgIFjpIYb0RqoncwudBURLjI+M ahCA== 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=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si2236592edr.325.2021.01.07.04.32.19; Thu, 07 Jan 2021 04:32:43 -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=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728127AbhAGMab (ORCPT + 99 others); Thu, 7 Jan 2021 07:30:31 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:40986 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725835AbhAGMab (ORCPT ); Thu, 7 Jan 2021 07:30:31 -0500 X-UUID: c5d0814a69d74f03a8ef9cd8d85a71d4-20210107 X-UUID: c5d0814a69d74f03a8ef9cd8d85a71d4-20210107 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1614309563; Thu, 07 Jan 2021 20:29:46 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Jan 2021 20:29:44 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 7 Jan 2021 20:29:44 +0800 From: Yong Wu To: Joerg Roedel , Will Deacon , Robin Murphy CC: Matthias Brugger , Krzysztof Kozlowski , Tomasz Figa , , , , , , , , Nicolas Boichat , , , Greg Kroah-Hartman , , Christoph Hellwig , David Laight Subject: [PATCH v4 2/7] iommu: Add iova and size as parameters in iotlb_sync_map Date: Thu, 7 Jan 2021 20:29:04 +0800 Message-ID: <20210107122909.16317-3-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210107122909.16317-1-yong.wu@mediatek.com> References: <20210107122909.16317-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/iommu.c | 4 ++-- drivers/iommu/tegra-gart.c | 7 +++++-- include/linux/iommu.h | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index c304a6a30d42..3d099a31ddca 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2443,7 +2443,7 @@ static int _iommu_map(struct iommu_domain *domain, unsigned long iova, 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; } @@ -2575,7 +2575,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..05e8e19b8269 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); } @@ -269,7 +270,9 @@ static void gart_iommu_sync_map(struct iommu_domain *domain) static void gart_iommu_sync(struct iommu_domain *domain, struct iommu_iotlb_gather *gather) { - gart_iommu_sync_map(domain); + size_t length = gather->end - gather->start; + + gart_iommu_sync_map(domain, gather->start, length); } static const struct iommu_ops gart_iommu_ops = { diff --git a/include/linux/iommu.h b/include/linux/iommu.h index b3f0e2018c62..9ce0aa9e236b 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -246,7 +246,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); -- 2.18.0