Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5356511ybp; Tue, 8 Oct 2019 01:19:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTkB6R0f3ZR03sjFA1vdWrd3T9heKLp/8FLkFcZGR80ZdIds6COEf6mRGmK3iKEgCO6gkl X-Received: by 2002:a50:9eac:: with SMTP id a41mr13410627edf.193.1570522751806; Tue, 08 Oct 2019 01:19:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570522751; cv=none; d=google.com; s=arc-20160816; b=KJlKldvIUpRda+lBza1ry6rfpOH+2Rl+olEjbkwQvLbd2OlfoT336Jm1fNyOn6KJWP nPtvdZKMlXHWCqB0DfWrrDRTOMxF9DK1Ufltv7DZJkzKBpkj2CdRRfhTvNLVoTt6wThG xbUtF8ZIRQ/LO7atHunjGtGggbAWJwVtTUk/YiOd3bmMoRSqSMrEZYQ5yyNWrKsgozHQ w7YwGOX0s/gMzHeKF/ie2TMQ4mi8qdItF+amnb7+0Am1ganZ0yF1J4g4Uva61k1zWawU AqLZwNOnkBNwNZcC+HSTFOnivJKy2MP70dGNHlUPXh3TxAUsk6jTvoxJk7pJfDupVLvS WVdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=BCc/IwC2uKYHGmOz6WOtFKbbeVPRzg/vuPr1B2Kfc0w=; b=Tx/rWMpMfjYfQCQ5A28xkYMiQ3sVGKlIS9RfMYjmDL5HipV/VfXXsofHaVNIocmRmj zCMpShURWRFvQ5j6gaDV8XJEsVZL5yFWPzX/9vPf8A3ph16+jOUplVpPqJcjR1FpXDMk +p10sAzi4v2v4MhUqH2G5VfaiYOkH34cCT+6kpoM16eijHWFG8m/VKoeu+NQogGk58ik QU087HocAufmuj6psZJD1aHAPEBXOIqrKLPsFyjOT7l9ibXVgF17rr282ynQPWt15xQu EdOIfWjEZhEJNtpyYxj1WveufSNZ6XtJOM435a41+eQGY5lslo1xMbY5vbrf/gAfHwze xu+A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ca4si8442050ejb.39.2019.10.08.01.18.48; Tue, 08 Oct 2019 01:19:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730535AbfJHISm (ORCPT + 99 others); Tue, 8 Oct 2019 04:18:42 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:28715 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730309AbfJHISl (ORCPT ); Tue, 8 Oct 2019 04:18:41 -0400 X-UUID: 0b511a8e3bf04a068a8709439614994f-20191008 X-UUID: 0b511a8e3bf04a068a8709439614994f-20191008 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1743715037; Tue, 08 Oct 2019 16:18:35 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 8 Oct 2019 16:18:33 +0800 Received: from [10.17.3.153] (172.27.4.253) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 8 Oct 2019 16:18:32 +0800 Message-ID: <1570522712.19130.42.camel@mhfsdcap03> Subject: Re: [PATCH] iommu/mediatek: Move the tlb_sync into tlb_flush From: Yong Wu To: Will Deacon CC: Matthias Brugger , Joerg Roedel , Will Deacon , , , Nicolas Boichat , , , , , Evan Green , "Tomasz Figa" , , , Robin Murphy , Date: Tue, 8 Oct 2019 16:18:32 +0800 In-Reply-To: <20190930120926.t26ydhgggi2scg3e@willie-the-truck> References: <1569822142-14303-1-git-send-email-yong.wu@mediatek.com> <20190930120926.t26ydhgggi2scg3e@willie-the-truck> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-SNTS-SMTP: 7D17782CEA9D438245218EEEE6BBEC1C3BB60458E15FE650459FFB65E1DB5FFA2000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-09-30 at 13:09 +0100, Will Deacon wrote: > 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 for the quick review, I will separate them. > > Thanks, > > Will