Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp505679pxb; Tue, 3 Nov 2020 05:30:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVmb07CyWtgJNOXhVu55WhfNzbGaQ8tlYmcNrU0h3AegB0f1tlohmwQi70aJvvT2X9y9el X-Received: by 2002:a50:c945:: with SMTP id p5mr21156084edh.55.1604410252877; Tue, 03 Nov 2020 05:30:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604410252; cv=none; d=google.com; s=arc-20160816; b=uumc4gsStdeSOjxaOUJqlwZrnVNlU7iB3PzF5dAEDBsaA3fLtYjcqmquOS7rdfh8Cm Yy5pcl8byZUaLAzT8OTu2R6iEsICQBplXtDQOKb4K64Gs2BgqHaEniKtGEavdZKGC2gt RWXdunyxS8+p2ancVWmr529+VBF3ABSdqTA/8jzsD01aBSuoems0bQAusIpsOd9sPvqs UP3DXgLUT9TaUXLARx3cKuzY9CycHoPHvYtCSBVAzCjl4wzxJW/yHcgnxmWNm9GpRcoI el1F5nFKHUfYIEhboOgt4OOkNdLPFv9esX8n+5FdK/wVvKgAwjw+kC/2ubNcxw1UAmrz 2SyQ== 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=dldIYfTJS6IkZ8/7xmZR8OD1UnVkZixlc/QiTKGvk1I=; b=sLx8NOy7JfbDkzskuMYLgiH6ydkezzA3gjxcFjdZfSpmzBvKN8JFAKh5CwjvKbpWGw UwxgN4mVlAUoR6IBcWjJZu64eBjAXnrAtfR7tNcnQSlg6jSEWGBcJGCGPO46v/5A98rv s84hvMGiwntVSVKQILe6JLIe+7X1lHAV8usRgIVHm9eCLOAFO1QEU2KSs55fVBn1fltg vVKtK5oOCVxj/BbE7nxQeDX3xeEvAYWJovItlHznSMQyKK4dGB4mMC8KeaT/x60XJgC6 gUrQVaRgY/aC8P0PLY7LLjpUQxQNpcBf1Kw03JL/4cEEEkPuKzGOFymj5geTd5eXhvLL jhiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=HA1RGYqw; 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 g9si12741694edr.404.2020.11.03.05.30.30; Tue, 03 Nov 2020 05:30:52 -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=@mg.codeaurora.org header.s=smtp header.b=HA1RGYqw; 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 S1729278AbgKCN2o (ORCPT + 99 others); Tue, 3 Nov 2020 08:28:44 -0500 Received: from z5.mailgun.us ([104.130.96.5]:22061 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729263AbgKCN2k (ORCPT ); Tue, 3 Nov 2020 08:28:40 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1604410120; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=dldIYfTJS6IkZ8/7xmZR8OD1UnVkZixlc/QiTKGvk1I=; b=HA1RGYqw+XW527HoVmYIFcDvQaIIhNZEuFSvBPr6U0F+dQJvrHa+pHcaX+C6bHatpAhGXDNi cVL78SX+m6XV46ogf1h4A5lzcDZnSfTeuCoI6Ha5KbVwhx9bMomICkRwIdZRls/n9se9J6mZ X42FybIMqD+ce4AdLATGnV00lwk= X-Mailgun-Sending-Ip: 104.130.96.5 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 5fa15af8b64b1c5b780e9877 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 03 Nov 2020 13:28:24 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 02243C4345F; Tue, 3 Nov 2020 05:28:11 +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 autolearn=unavailable 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 638A0C433B1; Tue, 3 Nov 2020 05:28:10 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 03 Nov 2020 13:28:10 +0800 From: Can Guo To: Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, kernel-team@android.com, alim.akhtar@samsung.com, avri.altman@wdc.com, bvanassche@acm.org Subject: Re: [PATCH v4 1/5] scsi: ufs: atomic update for clkgating_enable In-Reply-To: <20201028194352.GA3060274@google.com> References: <20201026195124.363096-1-jaegeuk@kernel.org> <20201026195124.363096-2-jaegeuk@kernel.org> <20d1c2ca06e95beb207fd4ba1b61dc80@codeaurora.org> <20201027033311.GA1745317@google.com> <76df977d164683c7404d2dc702f2e5ad@codeaurora.org> <20201028194352.GA3060274@google.com> Message-ID: <2c73eb84991227b7e42ba4c1d268d390@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-29 03:43, Jaegeuk Kim wrote: > On 10/27, Can Guo wrote: >> On 2020-10-27 11:33, Jaegeuk Kim wrote: >> > On 10/27, Can Guo wrote: >> > > On 2020-10-27 03:51, 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. >> > > > >> > > > Note that, this requires a patch to address the device stuck by >> > > > REQ_CLKS_OFF in >> > > > __ufshcd_release(). >> > > > >> > > > The fix is "scsi: ufs: avoid to call REQ_CLKS_OFF to CLKS_OFF". >> > > >> > > Why don't you just squash the fix into this one? >> > >> > I'm seeing this patch just revealed that problem. >> >> That scenario (back to back calling of ufshcd_release()) only happens >> when you stress the clkgate_enable sysfs node, so let's keep the fix >> as one to make things simple. What do you think? > > If we don't have this patch, do you think this issue won't happen at > all? > At least I've never seen this scenario these years, otherwise I would have put up a fix. Thanks, Can Guo. >> >> Thanks, >> >> Can Guo. >> >> > >> > > >> > > Thanks, >> > > >> > > Can Guo. >> > > >> > > > >> > > > Signed-off-by: Jaegeuk Kim >> > > > --- >> > > > 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 cc8d5f0c3fdc..6c9269bffcbd 100644 >> > > > --- a/drivers/scsi/ufs/ufshcd.c >> > > > +++ b/drivers/scsi/ufs/ufshcd.c >> > > > @@ -1808,19 +1808,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; >> > > > }