Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp103177pxx; Wed, 28 Oct 2020 19:48:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQBrobOzU0U7j7E7Fr7wbMomXIb9wZVBteW+tvMAjmktyDoTEyciqpkWT3MDzpXBlxL02F X-Received: by 2002:a17:906:49cf:: with SMTP id w15mr2148312ejv.252.1603939724699; Wed, 28 Oct 2020 19:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603939724; cv=none; d=google.com; s=arc-20160816; b=fy5i+k6JJDr7gvcUtYLp8rkS+GL3F3pHOY5403CIasni99PVaNnuJbRmwukkOgWJy5 vIibWAg2ucos1KIGy9Mybym4lAKgLyd3e7YCpYdD577HyAjHzpu97nlNUlQJC/AEuCy8 /i9CfY6lQ7LoZOEn4gesdf1ec3aSnUyeTS7/iQ50WtWVbWjonavhoLUAXAkWqiQdTZKK 7euWQaMSr7AudERajbjDYVWseK5Ii2y4WK9AhURipkg6SUa7l6p3tQL9ClIikGJ/z3lB /cComDmqrYiMxWjPULZ8FqTJ5T1YMceSPGzp0kCF7KUqdaY2d+tJ2mig6ATu5WWuoFAV KCeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=u+gii4PPhV16F58/fbHZAzRIULUHIbExso3Wi4yxo8E=; b=iqdu45ukqFT9jyurIbSdI8Ss4XhccedZfdGTBgBNST4Pdw+E3sCxLtB78eM6OeFwXz Cm+96VJIsH81KCTpzkalHcgoNMClQGUJY7aVImlxi3/t8wwHlVt9f3iUvrx6Hld2MB1c ZLZCzlWukHO1KVmebKysqfzu1eqiCdCRt/dclU96dCvbwvP0TS8XQte/70tZAHKm9L6z hFJG6QwdYvMQAKIl0Lg9ZuubT68IQLM16NdFLRc+Qxq8NLIKalBgZZXGt9DZNYvL9L0B tGkM3Nx41pibMPqWv9VqlBXpOrJY4swNVw+W342C5IJNOL6PBbvRtCQBR2tCxcNb+IpO 75eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dfusWPKW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc22si787680ejb.708.2020.10.28.19.48.22; Wed, 28 Oct 2020 19:48:44 -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=@kernel.org header.s=default header.b=dfusWPKW; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730833AbgJ1WMm (ORCPT + 99 others); Wed, 28 Oct 2020 18:12:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:56480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730832AbgJ1WMY (ORCPT ); Wed, 28 Oct 2020 18:12:24 -0400 Received: from google.com (unknown [104.132.1.66]) (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 E2A9E24795; Wed, 28 Oct 2020 19:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603914234; bh=Uig8XlVVywuZSs/xiHVDxKfmc2EvUkGvRLURSxmRfOM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dfusWPKWqTKRnMdbvN3oZ846WjjPGP1zahpiGLPq7lLhrOPyDeFDLz1cHc9PWFcZx AfCnIMUYVw2KHtvQTMXiA8EyfosDwA6yEnKTaOfqCqREvHybxFLydVlbuyxPljCaBW 36b9cwb9UexFKfBKUhyXKkEQkJPSzToDbMT4hDOI= Date: Wed, 28 Oct 2020 12:43:52 -0700 From: Jaegeuk Kim To: Can Guo 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 Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <76df977d164683c7404d2dc702f2e5ad@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > > 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; > > > > }