From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753017AbdFUB3O (ORCPT ); Tue, 20 Jun 2017 21:29:14 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:8363 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752964AbdFUB3N (ORCPT ); Tue, 20 Jun 2017 21:29:13 -0400 Subject: Re: [PATCH 1/1] iommu/arm-smmu-v3: replace writel with writel_relaxed in queue_inc_prod To: Robin Murphy , Will Deacon , Joerg Roedel , linux-arm-kernel , iommu , linux-kernel References: <1497956694-11784-1-git-send-email-thunder.leizhen@huawei.com> CC: Zefan Li , Xinwei Hu , "Tianhong Ding" , Hanjun Guo From: "Leizhen (ThunderTown)" Message-ID: <5949CBB7.1030908@huawei.com> Date: Wed, 21 Jun 2017 09:28:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.23.164] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.5949CBC1.00CD,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1c1f12211375f1572c512cd58cb75b55 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/6/20 19:35, Robin Murphy wrote: > On 20/06/17 12:04, Zhen Lei wrote: >> This function is protected by spinlock, and the latter will do memory >> barrier implicitly. So that we can safely use writel_relaxed. In fact, the >> dmb operation will lengthen the time protected by lock, which indirectly >> increase the locking confliction in the stress scene. > > If you remove the DSB between writing the commands (to Normal memory) > and writing the pointer (to Device memory), how can you guarantee that > the complete command is visible to the SMMU and it isn't going to try to > consume stale memory contents? The spinlock is irrelevant since it's > taken *before* the command is written. OK, I see, thanks. Let's me see if there are any other methods. And I think that this may should be done well by hardware. > > Robin. > >> Signed-off-by: Zhen Lei >> --- >> drivers/iommu/arm-smmu-v3.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c >> index 380969a..d2fbee3 100644 >> --- a/drivers/iommu/arm-smmu-v3.c >> +++ b/drivers/iommu/arm-smmu-v3.c >> @@ -728,7 +728,7 @@ static void queue_inc_prod(struct arm_smmu_queue *q) >> u32 prod = (Q_WRP(q, q->prod) | Q_IDX(q, q->prod)) + 1; >> >> q->prod = Q_OVF(q, q->prod) | Q_WRP(q, prod) | Q_IDX(q, prod); >> - writel(q->prod, q->prod_reg); >> + writel_relaxed(q->prod, q->prod_reg); >> } >> >> /* >> -- >> 2.5.0 >> >> > > > . > -- Thanks! BestRegards