Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4766348pxu; Wed, 21 Oct 2020 05:02:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+1KmMxfIW/LkuBngkMY/BYic+rUHkVC1rO7blRo4i8h2hkYUtTRCeMo2C9Ui0YrHMPSDw X-Received: by 2002:a17:906:f29a:: with SMTP id gu26mr2896296ejb.363.1603281753341; Wed, 21 Oct 2020 05:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603281753; cv=none; d=google.com; s=arc-20160816; b=iG+t2wtXShuKjKP8KElN5UWlfaMJ045q8/fHMv7LFrGllkllAkePI4R+N66PCDcOBK fBEm8yZ1brXgyvrPJWzSDPxzZKq5hkBgVzRDvDa+jzLolFph8Upoen5l5kav86y5wT8P 9w7co8XEstDUToitfbWsdtEIybrzAu/MxJDOKt98x4g4a7DH0qEmf+0VbWs+j1S/kl+9 neN5/vTTiDIGAehub5yNib9KS6VilfDOAbo+fet2c3oCHBZCaCaBxt46u2BLI5NT3vrM 7X9bF61iR2qlKlsYTv7xaVYPawKJntb+CvEk89oEMnkh6CAZXMes68d0/D7HNu9WtE9+ lr+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=S5lmg/47eSMB0cMlWY5RcQ2SoXrP4WZ/K1BZsdaCAF8=; b=gN240BecB56i3bn8YujW9Vh1H0nLPxyCtjwarBaGR6vjxF6Yl7ZfvRaq2p2kOIgTvz ZmfTRfUpAUn68u51le5NNQK9uJZUoFq4WIyeOycc/lUlIW4k89LMspfeSIcsjuu40wKi sP6+yXcGWathNb16XXTF8sRsVZlUMhoJne2IpdEZ3oqOen2YTc5a67OJGnBWmJEpgUjB U5daoqTb46ePRvyqN2aIogWMUTygSt6n/CbGm1gXkMFrgLaLB4jv3bGZOqHmQZRfpLcb Oa3ftcEKYQTG7V47tBXC9sZhzfiUvA6BM0AN9WaBDfUNIkuXtktD5/2fDTUJmzcViNkV 561A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=skRsORwa; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si1814055edl.492.2020.10.21.05.02.07; Wed, 21 Oct 2020 05:02:33 -0700 (PDT) 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=@mg.codeaurora.org header.s=smtp header.b=skRsORwa; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439958AbgJUCFY (ORCPT + 99 others); Tue, 20 Oct 2020 22:05:24 -0400 Received: from m42-4.mailgun.net ([69.72.42.4]:31507 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439947AbgJUCFY (ORCPT ); Tue, 20 Oct 2020 22:05:24 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1603245923; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=S5lmg/47eSMB0cMlWY5RcQ2SoXrP4WZ/K1BZsdaCAF8=; b=skRsORwanVq0mIEjVzbDWLN64FtDJt9LavFLh5EIiYqUmpS9liwspt6SY7PijCTRU5hRdwXq 7HmQRG3j+A53JADAcY3pQf09wfqu1yyT1clo7MuAnSQxZ9u5GabklpMfzaXlA+oCjz2kcch3 7PVTg8JyYUbcElBNbrFbMCuGoDM= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 5f8f9762e9e942744c293420 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 21 Oct 2020 02:05:22 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 1E434C433CB; Wed, 21 Oct 2020 02:05:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4AD07C433C9; Wed, 21 Oct 2020 02:05:21 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 21 Oct 2020 10:05:21 +0800 From: Can Guo To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Jaegeuk Kim , Alim Akhtar , Avri Altman Subject: Re: [PATCH v2 1/5] scsi: ufs: atomic update for clkgating_enable In-Reply-To: <20201020195258.2005605-2-jaegeuk@kernel.org> References: <20201020195258.2005605-1-jaegeuk@kernel.org> <20201020195258.2005605-2-jaegeuk@kernel.org> Message-ID: <6c7bc6794b215a0ae1ae0cd9d448efa3@codeaurora.org> X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-10-21 03:52, Jaegeuk Kim wrote: > From: Jaegeuk Kim > > When giving a stress test which enables/disables clkgating, we hit > device > timeout sometimes. This patch avoids subtle racy condition to address > it. > > Cc: Alim Akhtar > Cc: Avri Altman > Cc: Can Guo > Signed-off-by: Jaegeuk Kim Reviewed-by: Can Guo Next time can you have a cover letter in case of multiple patches? Thanks, Can Guo. > --- > drivers/scsi/ufs/ufshcd.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index b8f573a02713..7344353a9167 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -1807,19 +1807,19 @@ static ssize_t > ufshcd_clkgate_enable_store(struct device *dev, > return -EINVAL; > > value = !!value; > + > + spin_lock_irqsave(hba->host->host_lock, flags); > if (value == hba->clk_gating.is_enabled) > goto out; > > - if (value) { > - ufshcd_release(hba); > - } else { > - spin_lock_irqsave(hba->host->host_lock, flags); > + if (value) > + __ufshcd_release(hba); > + else > hba->clk_gating.active_reqs++; > - spin_unlock_irqrestore(hba->host->host_lock, flags); > - } > > hba->clk_gating.is_enabled = value; > out: > + spin_unlock_irqrestore(hba->host->host_lock, flags); > return count; > }