Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp222510pxb; Wed, 18 Nov 2020 22:20:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxF20CjNkQkGYyqEf9waVkywv+mU3AfuTO9JtIAp7r2OOQcA+Sz/N3mlBNLpdEhDkc5ryo3 X-Received: by 2002:a17:906:80ca:: with SMTP id a10mr28259455ejx.351.1605766851551; Wed, 18 Nov 2020 22:20:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605766851; cv=none; d=google.com; s=arc-20160816; b=xwRK/uALbv1ZUV6D1EW0FFEaRMAloulvq3E5LLxopDFCVIH9uzVTRMCfQYU9FfjlAv ha4J1t1ncYux54qqlW8WoHaI+KUWUK487uhkxF7UotPDNFGZcEPb+JjNruqDMu9+itm5 VjUBzgLURTGp59dCx8l9CP+d2KEsaBCESJZWJcGOVhBJQhyZkI24ql08fVzsobdsFtp4 tQWcBYWseuDg+J5n+rPti1XLRR+mAN1AtSR2InaD1vM4Idoqru2PEZaJ55BabZ+QBhNP IaSHtunFGLxBC7dXlMbeM5XuK5X4GEr6vgjX5BXFuYhhUf7/oiHZpRcgfbzQDZGTDzYa pbwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=/CJ6Tcs+lRFciR5Jt1E+qhfBaARvaH+z+ghTWuCNtIw=; b=hkqgB3mnU8j5sulNHYQ6mTDc5RE7v/3eGBHaEZFDmhXDuUdWRdVAADGzNdM0bMmVgu 1jGU6kEhC2k/PZP4coOYMSDVb4uG73YQxzYyNvPhieLb9hLl8nxH4U1IKTGDpDZqYFSN 2xPJIDtgTm29z5knrs989of68oyyX0tRyDXBsjaYlHV7O3YPdRSmGX7b6CLm6mr/7NXA SaEoGDpk90ix7tu5cE9buLETYnaQPQgsBAf71y/6AGLhgtdAly6pjTH3+j/7fCHVgS3f epu1rbbi9tcN4Y8+Nx09Rtc12WfB1nte64VfKpGz3FypwzbMjCLtUokn2ojcH1wQjSgp kDew== 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 j8si18553649edn.520.2020.11.18.22.20.29; Wed, 18 Nov 2020 22:20:51 -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 S1726252AbgKSGSu (ORCPT + 99 others); Thu, 19 Nov 2020 01:18:50 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:39577 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726224AbgKSGSu (ORCPT ); Thu, 19 Nov 2020 01:18:50 -0500 X-UUID: c867fb6f2b3f4e09acb102905d195901-20201119 X-UUID: c867fb6f2b3f4e09acb102905d195901-20201119 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] 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 1304192711; Thu, 19 Nov 2020 14:18:44 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 19 Nov 2020 14:18:43 +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:42 +0800 From: Yong Wu To: Joerg Roedel , Will Deacon , Robin Murphy CC: Matthias Brugger , Krzysztof Kozlowski , Tomasz Figa , , , , , , , , Nicolas Boichat , , , Subject: [PATCH v2 0/6] MediaTek IOMMU improve tlb flush performance in map/unmap Date: Thu, 19 Nov 2020 14:18:30 +0800 Message-ID: <20201119061836.15238-1-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 add a flag(granule_ignore) for this case. 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/6][2/6][3/6] are for map while the others are for unmap. change note: v2: Refactor all the code. base on v5.10-rc1. v1: https://lore.kernel.org/linux-iommu/20201019113100.23661-1-chao.hao@mediatek.com/ Yong Wu (6): iommu: Move iotlb_sync_map out from __iommu_map iommu: Add iova and size as parameters in iommu_iotlb_map iommu/mediatek: Add iotlb_sync_map to sync whole the iova range iommu: Add granule_ignore when tlb gather iommu/mediatek: Enable granule_ignore for unmap iommu/mediatek: Convert tlb_flush_walk to gather_add_page drivers/iommu/iommu.c | 24 +++++++++++++++++++----- drivers/iommu/mtk_iommu.c | 32 ++++++++++++++++++++++++++------ drivers/iommu/tegra-gart.c | 3 ++- include/linux/iommu.h | 7 +++++-- 4 files changed, 52 insertions(+), 14 deletions(-) -- 2.18.0