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=-12.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 1ED70C433DB for ; Thu, 7 Jan 2021 12:51:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C3A22337F for ; Thu, 7 Jan 2021 12:51:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C3A22337F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=d+qf4U9RFBWjvuYm+lFWGP6p4fioXJ0DV6l01qOiCNI=; b=ixPYPNKOoFbagrzJgv7U5a1jao 5BxSLzY8iRwnu/4lNfmR+1/Dl3AWNjlBz8Ym7FFZlGQFv7c7IAoGXWcPtMPVGcjcB73x7CpmL8qee yd7i0MaOr9Op/XWeqmPmHAkAcePqBKboublS/sEGc+A2fryWqQR/nvF10RUlslZ5CNLH63n2cObR8 kdvlKiKvPExD6md34ItBThw6W9zr4Yl1R59WWFNrjFF8uL8FlEpGEbG99LDQ3vb//ZyB5w4SCTYLO N/CqGMCcNv9vOS6t3cGwdgPOn170xFBTwOqixQlLmLq9w3seh2NMAaYWom+tpyZtGvx3FiUVAJF+d 3NpI2l+Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxUkb-0003tt-FO; Thu, 07 Jan 2021 12:50:49 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kxUd5-0008GC-Mv; Thu, 07 Jan 2021 12:43:05 +0000 X-UUID: f2c3900887744b108d6d21722ab4647a-20210107 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=Hh/1H8FnQJSKV24yDdM2cetmKXTSl8oqt0FpNZQeyGI=; b=gz/DXWQ3gwd6bq6wH/uCbLLEJZzO/fQQNSrVhYdTt2NED0I8Sq1/rm8A2mnSPIT/byY5njq/bWhv0n1n1piN+7jdvcFKTffz1hf6K2CE+lmwVgIGEw5oZlz+nmOiMvOh/K2VOnNwnrZSG+AeUTDlOqAwXpca55JmGx60vHQwETk=; X-UUID: f2c3900887744b108d6d21722ab4647a-20210107 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2003300804; Thu, 07 Jan 2021 04:29:25 -0800 Received: from mtkmbs07n1.mediatek.inc (172.21.101.16) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Jan 2021 04:29:23 -0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Jan 2021 20:29:22 +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:21 +0800 From: Yong Wu To: Joerg Roedel , Will Deacon , "Robin Murphy" Subject: [PATCH v4 0/7] MediaTek IOMMU improve tlb flush performance in map/unmap Date: Thu, 7 Jan 2021 20:29:02 +0800 Message-ID: <20210107122909.16317-1-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210107_074303_997962_3ADA258E X-CRM114-Status: GOOD ( 12.59 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: youlin.pei@mediatek.com, anan.sun@mediatek.com, Nicolas Boichat , srv_heupstream@mediatek.com, chao.hao@mediatek.com, linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Christoph Hellwig , Tomasz Figa , iommu@lists.linux-foundation.org, David Laight , linux-mediatek@lists.infradead.org, yong.wu@mediatek.com, Matthias Brugger , Greg Kroah-Hartman , kernel-team@android.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org This patchset is to improve tlb flushing performance in iommu_map/unmap for MediaTek IOMMU. For iommu_map, currently MediaTek IOMMU use IO_PGTABLE_QUIRK_TLBI_ON_MAP to do tlb_flush for each a memory chunk. this is so unnecessary. we could improve it by tlb flushing one time at the end of iommu_map. For iommu_unmap, currently we have already improve this performance by gather. But the current gather should take care its granule size. if the granule size is different, it will do tlb flush and gather again. Our HW don't care about granule size. thus I gather the range in our file. After this patchset, we could achieve only tlb flushing once in iommu_map and iommu_unmap. Regardless of sg, for each a segment, I did a simple test: size = 20 * SZ_1M; /* the worst case, all are 4k mapping. */ ret = iommu_map(domain, 0x5bb02000, 0x123f1000, size, IOMMU_READ); iommu_unmap(domain, 0x5bb02000, size); This is the comparing time(unit is us): original-time after-improve map-20M 59943 2347 unmap-20M 264 36 This patchset also flush tlb once in the iommu_map_sg case. patch [1/7][2/7][3/7] are for map while the others are for unmap. change note: v4: a. base on v5.11-rc1. b. Add a little helper _iommu_map. c. Fix a build fail for tegra-gart.c. I didn't notice there is another place call gart_iommu_sync_map. d. Switch gather->end to the read end address("start + end - 1"). v3: https://lore.kernel.org/linux-iommu/20201216103607.23050-1-yong.wu@mediatek.com/#r Refactor the unmap flow suggested by Robin. v2: https://lore.kernel.org/linux-iommu/20201119061836.15238-1-yong.wu@mediatek.com/ Refactor all the code. base on v5.10-rc1. Yong Wu (7): iommu: Move iotlb_sync_map out from __iommu_map iommu: Add iova and size as parameters in iotlb_sync_map iommu/mediatek: Add iotlb_sync_map to sync whole the iova range iommu: Switch gather->end to the inclusive end iommu/io-pgtable: Allow io_pgtable_tlb ops optional iommu/mediatek: Gather iova in iommu_unmap to achieve tlb sync once iommu/mediatek: Remove the tlb-ops for v7s drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +- drivers/iommu/iommu.c | 23 +++++++--- drivers/iommu/mtk_iommu.c | 47 +++++++++------------ drivers/iommu/tegra-gart.c | 7 ++- include/linux/io-pgtable.h | 8 ++-- include/linux/iommu.h | 7 +-- 6 files changed, 52 insertions(+), 42 deletions(-) -- 2.18.0 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek