Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp223104pxb; Wed, 18 Nov 2020 22:22:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0Gg0jFS+h9/CA8KvYrGJGor0mJzlH0qg3mEqo5eqBkHG6p6H7Qr6G/4VRlYgDhV1JeEss X-Received: by 2002:a05:6402:b45:: with SMTP id bx5mr28196305edb.193.1605766939980; Wed, 18 Nov 2020 22:22:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605766939; cv=none; d=google.com; s=arc-20160816; b=TsjnxrJMzhfosDe/9xKejQ4h/okFpORnXFUiJQAqZyFQzEJ9/bFVRzlgxmYOwkQA2C uzDb6JMGw+tlMG9slYR6L6xr4aLqw7kTMMcfkIn0NWlW5BJIjGyRAOhGKhkP9bJA43qy NxUaOnG1kvaAEzZXFtbyx3vrin7FvMK/yFxOY4eNwGxppNPYRr7K10b/SAeo8r6mm4l4 LTgXyKaizkaL5z4hGRW7hxERsVbQrI5dnTZrHV26JTQjX3JWDMRZSf533Xe0u/reDhQk 5UzvPzwa6lyETv7Ot5sJVndFRMI1aH+cdmswwt5BMKN+OFFuvu4dtyh9zTAawvCYGEqI 2wGg== 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=rCteZt5rHYMSYfdMbGEUPoGERodYMxT5YA1Dh8Ua2zw=; b=Nq1oIJa+ewOK/MdGNrj6fTQ7/PWYcnj5iQXcMyolGb902WdnOLDXNaAc5sXzV3/irT J66Ec0ghc/hdZkLkpBiYD9mXBXqR01TFineJxc69fjN/SOfnoQv9nqBdbBHdihp7+oYr fyy3VW62deJYPrd4jE6Q/B6ZaNEdblnOtoY2ymk0jrmsBxapCqy/o5MGDqxWFqriC4S8 LmIjdhyArAXubLfi4Knusos3pyut+G6BdDq98Wdy6Ov4HRQEviDGK+6VAvxh7Gr8uAW5 Qdi/gGHZg0y7gJ9fDM/9I7TY1rJw5nYUCTseHCGxsPMfgvW5JnLWbfPFSBI6yLndOysw 1pOw== 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 cn1si17021604edb.408.2020.11.18.22.21.56; Wed, 18 Nov 2020 22:22:19 -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 S1726348AbgKSGTG (ORCPT + 99 others); Thu, 19 Nov 2020 01:19:06 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:39962 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726224AbgKSGTG (ORCPT ); Thu, 19 Nov 2020 01:19:06 -0500 X-UUID: aea9e6e6d67143c5b82407cfc8e7b8e2-20201119 X-UUID: aea9e6e6d67143c5b82407cfc8e7b8e2-20201119 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.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 1688754634; Thu, 19 Nov 2020 14:19:02 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 19 Nov 2020 14:19:00 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 19 Nov 2020 14:18:59 +0800 From: Yong Wu To: Joerg Roedel , Will Deacon , Robin Murphy CC: Matthias Brugger , Krzysztof Kozlowski , Tomasz Figa , , , , , , , , Nicolas Boichat , , , Subject: [PATCH v2 2/6] iommu: Add iova and size as parameters in iommu_iotlb_map Date: Thu, 19 Nov 2020 14:18:32 +0800 Message-ID: <20201119061836.15238-3-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201119061836.15238-1-yong.wu@mediatek.com> References: <20201119061836.15238-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 --- 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); -- 2.18.0