Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp332536pxu; Wed, 25 Nov 2020 04:31:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdIxHzIncUo7e1CDo6AmMM92mTkC3jPRityeSseLhyysFsjCQ4/jiAWsqjA4BLS2injLAg X-Received: by 2002:a17:907:aaf:: with SMTP id bz15mr2803514ejc.199.1606307496832; Wed, 25 Nov 2020 04:31:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606307496; cv=none; d=google.com; s=arc-20160816; b=0gF2CUf5/VkpAX9cJ4ctjZAin0aGg3lJW5B8FHmvj81gL6sdA9VMVwx1lWsv2aToHK ++ARG3eMTjJ4KuqlxqmNikN/11il+sQCtqolaYhdxBR1Kjo3O2fZxWc7wdluK797id6D kpdgjfBeqc4L2/ABPwHisUWQhCL/oMf+cyX6kMPe9v/pX2ugHpI4xQawgAhj/GIk4jrO /fOhNml4bVYPHlid/6ObrL6w7AirL0RqWHoJl2ZDhZfi+Mx5/b2gsZYdiM1tn0zL4SHt MM6Gsy3/ag6KUBtDOkTTt41/ncSFm7De4ZoYp0HF8I58b4sI1W6/223acvomJV+WwJ8S 16BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=IzxbLWPAzCvnd9nyyOetWt4SC9sFUf4tq9FIVtFdcTg=; b=CuR5MU9ItbX1U69lIMt1aaVRaD5H2/SIo3TWbzan5uJKMHFQotE2YZxoA+sliW6zFk kdZQNiQ+koarbw9OjHuYB8k0GVQhQWMCsw2KmrdL7hQ3JGWfFtAiabTLksNkJgBr3M6V uOxuX1BaOJucaZ/eZ1Db0iFDc1aLPSv8xq4PbO/5/8DPeGCn8jTRbkX6cpY/MV/sW8+v /DEM3mELGhwC4mnU+PGRx7mIzor5vSU6V14873T2gQcM2iuM5cdle9IdGQeK6GMPR6UW Z9Q+Uz5VSc/sYJmFo3jMxnwmtsyM6jOkDVBEM1EWXsIzM6IGw79bGcPVYmjy81KCxggE L+2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iYtQ0Ok0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k20si1156695ejj.381.2020.11.25.04.31.13; Wed, 25 Nov 2020 04:31:36 -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; dkim=pass header.i=@kernel.org header.s=default header.b=iYtQ0Ok0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728792AbgKYM10 (ORCPT + 99 others); Wed, 25 Nov 2020 07:27:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:46230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726330AbgKYM10 (ORCPT ); Wed, 25 Nov 2020 07:27:26 -0500 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE9A9206E5; Wed, 25 Nov 2020 12:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606307245; bh=evEwLaFL1TOZnnmN2k1Ii9RUrk1eDitE23z2suTvQ6U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iYtQ0Ok0TCUzNBLXPdRIrDidqt/+lGu4bC88noEHv4ZMCgWO/rJgzP+yJkNy7Oa90 l9N+Vo+HlQF+Xwy2MM/kcLk3cTL83wXG64ym2wPiLcJMKvrogdozHwhQjRstglhPfG kBPeDf+3nYbBXC3BUX7o89t6jAJIpzXJZPE5pgAs= Date: Wed, 25 Nov 2020 12:27:19 +0000 From: Will Deacon To: Yong Wu , robin.murphy@arm.com Cc: Joerg Roedel , 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 Subject: Re: [PATCH v2 0/6] MediaTek IOMMU improve tlb flush performance in map/unmap Message-ID: <20201125122719.GB15697@willie-the-truck> References: <20201119061836.15238-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201119061836.15238-1-yong.wu@mediatek.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 19, 2020 at 02:18:30PM +0800, Yong Wu wrote: > 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. Robin -- please can you take a look at this series? I'm not sure I'll have time to get to it at the moment and you understand how this stuff is supposed to work. Cheers, Will