Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6867640ybn; Mon, 30 Sep 2019 05:11:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYKdeFfMQA6MoflnXbyQ/PnBfBdmjIibrxVyq2ZV6yc1x9GSRH02GT9sCKeDhmj7fieJhF X-Received: by 2002:aa7:dad3:: with SMTP id x19mr12554153eds.59.1569845519738; Mon, 30 Sep 2019 05:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569845519; cv=none; d=google.com; s=arc-20160816; b=QrNEPOZSHuQXXUCkJn864xfywB0/TOAMpxMiuKeltz7Gqzi6tDbgXWkZZjxGcIAC0k PQHofhop6smjmkImf/CJEyveVIU05P5g2+O+6tTmAnSt2KwBQWG2DFcZmvx5Maf74+3t csy1veM6ywUPwlTngHc7sn1T5CywAhYCoKdsBNhhdQy1mxLnIaAPogN1100XVvkYAZW0 ATQaVOfcAlP8mLDn+uqap55f1Xyk8jDCVAGbcYreABZDGSg2UkgFUW2RvK3k1WPKcHp9 SuwaT5ONfKpNZHc7vp3EKKpdV5c6z410DGaVLR/1qLctc2/NGbknF5yhdUDx6aeEluVX h8Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DLW/7MBss6v086LGGr0Z/cI8TrjVDam8JrshvVhRGgI=; b=xLIp7lHHq8Xf4I04lbGaLQO/eMOeZ6LGu32/kbLl61R5RxNmmeDBj0OpwDVwISnhtT E4AO1IZCx2XHgOz29XBKcSP15CLAt2S1ytDEMUBU3V3eyllX1Mp/oDPvtziiDvfF8omx P30Py3f3BiSaz/BA0oDdJ+ChFU1udUjQZkAfBzJbPVPgrPaglX8AurxSLo/ckkrLaHQT w1NRjQfN85UKQE/1v4S1HIDLSthUwVnyu+6p/ArRBM5y0QTV+NRFBH+Sf+emBpBTMKT1 PlRnjteEtW0WB203Z08mcowMxApNCLJCKuyEqVFJirPLcwBYq++muN1g3imryqUUfaXF UpwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yXC7VC+s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id gz11si6898102ejb.341.2019.09.30.05.11.35; Mon, 30 Sep 2019 05:11:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yXC7VC+s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730189AbfI3MJe (ORCPT + 99 others); Mon, 30 Sep 2019 08:09:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:54332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726072AbfI3MJd (ORCPT ); Mon, 30 Sep 2019 08:09:33 -0400 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 26E43206C0; Mon, 30 Sep 2019 12:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569845373; bh=T9SJSGU8WXO5UsIOSvNDLMijEaReW5+dr3E41swIY98=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yXC7VC+skmjWzmwCouYtMdDU+SNlxZHXtQ/mbwq6tDKFujDyqWYETrOlU3yBpanVd t/BPYmnze36c5QXEAlQQ8qQ05Yeo0SFhBy2mRlWC5kNCz0C6tjFYCaxSo1Daz+n9pv JIwrt+D0Ywqyr9eDIYz8fkeoXiv5ezfl6BcSGWdE= Date: Mon, 30 Sep 2019 13:09:27 +0100 From: Will Deacon To: Yong Wu Cc: Matthias Brugger , Joerg Roedel , Will Deacon , youlin.pei@mediatek.com, anan.sun@mediatek.com, Nicolas Boichat , cui.zhang@mediatek.com, srv_heupstream@mediatek.com, chao.hao@mediatek.com, linux-kernel@vger.kernel.org, Evan Green , Tomasz Figa , iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, Robin Murphy , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] iommu/mediatek: Move the tlb_sync into tlb_flush Message-ID: <20190930120926.t26ydhgggi2scg3e@willie-the-truck> References: <1569822142-14303-1-git-send-email-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1569822142-14303-1-git-send-email-yong.wu@mediatek.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 30, 2019 at 01:42:22PM +0800, Yong Wu wrote: > The commit 4d689b619445 ("iommu/io-pgtable-arm-v7s: Convert to IOMMU API > TLB sync") help move the tlb_sync of unmap from v7s into the iommu > framework. It helps add a new function "mtk_iommu_iotlb_sync", But it > lacked the dom->pgtlock, then it will cause the variable > "tlb_flush_active" may be changed unexpectedly, we could see this warning > log randomly: > > mtk-iommu 10205000.iommu: Partial TLB flush timed out, falling back to > full flush > > To fix this issue, we can add dom->pgtlock in the "mtk_iommu_iotlb_sync". > And when checking this issue, we find that __arm_v7s_unmap call > io_pgtable_tlb_add_flush consecutively when it is supersection/largepage, > this also is potential unsafe for us. There is no tlb flush queue in the > MediaTek M4U HW. The HW always expect the tlb_flush/tlb_sync one by one. > If v7s don't always gurarantee the sequence, Thus, In this patch I move > the tlb_sync into tlb_flush(also rename the function deleting "_nosync"). > and we don't care if it is leaf, rearrange the callback functions. Also, > the tlb flush/sync was already finished in v7s, then iotlb_sync and > iotlb_sync_all is unnecessary. > > Besides, there are two minor changes: > a) Use writel for the register F_MMU_INV_RANGE which is for triggering the > HW work. We expect all the setting(iova_start/iova_end...) have already > been finished before F_MMU_INV_RANGE. > b) Reduce the tlb timeout value from 100000us to 1000us. the original value > is so long that affect the multimedia performance. > > Fixes: 4d689b619445 ("iommu/io-pgtable-arm-v7s: Convert to IOMMU API TLB sync") > Signed-off-by: Chao Hao > Signed-off-by: Yong Wu > --- > This patch looks break the logic for tlb_flush and tlb_sync. I'm not > sure if it > is reasonable. If someone has concern, I could change: > a) Add dom->pgtlock in the mtk_iommu_iotlb_sync > b) Add a io_pgtable_tlb_sync in [1]. The patch looks ok to me, but please could you split it up so that the timeout and writel are done separately? Thanks, Will