linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stanley Chu <stanley.chu@mediatek.com>
To: Can Guo <cang@codeaurora.org>
Cc: <asutoshd@codeaurora.org>, <nguyenb@codeaurora.org>,
	<hongwus@codeaurora.org>, <rnayak@codeaurora.org>,
	<linux-scsi@vger.kernel.org>, <kernel-team@android.com>,
	<saravanak@google.com>, <salyzyn@google.com>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Bean Huo <beanhuo@micron.com>,
	"Bart Van Assche" <bvanassche@acm.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scsi: ufs: Make sure clk scaling happens only when hba is runtime ACTIVE
Date: Tue, 27 Oct 2020 11:10:11 +0800	[thread overview]
Message-ID: <1603768211.2104.8.camel@mtkswgap22> (raw)
In-Reply-To: <67c4ae5998765daa674a4df696d8d673@codeaurora.org>

Hi Can,

On Tue, 2020-10-20 at 10:35 +0800, Can Guo wrote:
> Hi Stanley,
> 
> On 2020-09-22 15:09, Can Guo wrote:
> > If someone plays with the UFS clk scaling devfreq governor through 
> > sysfs,
> > ufshcd_devfreq_scale may be called even when hba is not runtime ACTIVE,
> > which can lead to unexpected error. We cannot just protect it by 
> > calling
> > pm_runtime_get_sync, because that may cause racing problem since hba
> > runtime suspend ops needs to suspend clk scaling. In order to fix it, 
> > call
> > pm_runtime_get_noresume and check hba's runtime status, then only 
> > proceed
> > if hba is runtime ACTIVE, otherwise just bail.
> > 
> > governor_store
> >  devfreq_performance_handler
> >   update_devfreq
> >    devfreq_set_target
> >     ufshcd_devfreq_target
> >      ufshcd_devfreq_scale
> > 
> > Signed-off-by: Can Guo <cang@codeaurora.org>
> > 
> > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> > index e4cb994..847f355 100644
> > --- a/drivers/scsi/ufs/ufshcd.c
> > +++ b/drivers/scsi/ufs/ufshcd.c
> > @@ -1294,8 +1294,15 @@ static int ufshcd_devfreq_target(struct device 
> > *dev,
> >  	}
> >  	spin_unlock_irqrestore(hba->host->host_lock, irq_flags);
> > 
> > +	pm_runtime_get_noresume(hba->dev);
> > +	if (!pm_runtime_active(hba->dev)) {
> > +		pm_runtime_put_noidle(hba->dev);
> > +		ret = -EAGAIN;
> > +		goto out;
> > +	}
> >  	start = ktime_get();
> >  	ret = ufshcd_devfreq_scale(hba, scale_up);
> > +	pm_runtime_put(hba->dev);
> > 
> >  	trace_ufshcd_profile_clk_scaling(dev_name(hba->dev),
> >  		(scale_up ? "up" : "down"),
> 
> Could you please review this one since we may be the only two
> users of clk scaling?
> 

Looks good to me.

Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>



  reply	other threads:[~2020-10-27  3:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22  7:09 [PATCH] scsi: ufs: Make sure clk scaling happens only when hba is runtime ACTIVE Can Guo
2020-10-20  2:35 ` Can Guo
2020-10-27  3:10   ` Stanley Chu [this message]
2020-11-19 15:03 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1603768211.2104.8.camel@mtkswgap22 \
    --to=stanley.chu@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=hongwus@codeaurora.org \
    --cc=jejb@linux.ibm.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nguyenb@codeaurora.org \
    --cc=rnayak@codeaurora.org \
    --cc=salyzyn@google.com \
    --cc=saravanak@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).