All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanley Chu <chu.stanley@gmail.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Stanley Chu <stanley.chu@mediatek.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Avri Altman <avri.altman@wdc.com>,
	alim.akhtar@samsung.com,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	peter.wang@mediatek.com, Chun-Hung Wu <chun-hung.wu@mediatek.com>,
	alice.chao@mediatek.com, powen.kao@mediatek.com,
	mason.zhang@mediatek.com, qilin.tan@mediatek.com,
	lin.gui@mediatek.com, eddie.huang@mediatek.com,
	tun-yu.yu@mediatek.com, cc.chou@mediatek.com,
	chaotian.jing@mediatek.com, jiajie.hao@mediatek.com
Subject: Re: [PATCH v1] scsi: ufs: Fix ufshcd_scale_clks decision in recovery flow
Date: Sat, 30 Jul 2022 15:08:05 +0800	[thread overview]
Message-ID: <CAGaU9a_G1kH8VezozhZ3-S6-GvMr=EUVc4btU8Dwdo+cCJDxUg@mail.gmail.com> (raw)
In-Reply-To: <7e8c58cf-64c1-8426-bf22-97d3df85ed38@acm.org>

Hi Bart,

On Sat, Jul 30, 2022 at 4:12 AM Bart Van Assche <bvanassche@acm.org> wrote:
>
> On 7/29/22 00:55, Stanley Chu wrote:
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index 581d88af07ab..dc57a7988023 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -1574,8 +1574,6 @@ static ssize_t ufshcd_clkscale_enable_store(struct device *dev,
> >       ufshcd_rpm_get_sync(hba);
> >       ufshcd_hold(hba, false);
> >
> > -     hba->clk_scaling.is_enabled = value;
> > -
> >       if (value) {
> >               ufshcd_resume_clkscaling(hba);
> >       } else {
> > @@ -1586,6 +1584,8 @@ static ssize_t ufshcd_clkscale_enable_store(struct device *dev,
> >                                       __func__, err);
> >       }
> >
> > +     hba->clk_scaling.is_enabled = value;
> > +
> >       ufshcd_release(hba);
> >       ufshcd_rpm_put_sync(hba);
> >   out:
> > @@ -7259,7 +7259,8 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)
> >       hba->silence_err_logs = false;
> >
> >       /* scale up clocks to max frequency before full reinitialization */
> > -     ufshcd_scale_clks(hba, true);
> > +     if (ufshcd_is_clkscaling_supported(hba) && hba->clk_scaling.is_enabled)
> > +             ufshcd_scale_clks(hba, true);
> >
> >       err = ufshcd_hba_enable(hba);
>
> I see a race condition between the hba->clk_scaling.is_enabled check in
> ufshcd_host_reset_and_restore() and the code that sets
> ufshcd_clkscale_enable_store(). Shouldn't the code in
> ufshcd_host_reset_and_restore() that scales up the clocks be serialized
> against ufshcd_clkscale_enable_store()?

Both check and set paths are serialized by hba->host_sem currently.

Would I miss any other unserialized paths?

Thanks,
Stanley


>
> Thanks,
>
> Bart.



-- 
Yours truly,

朱原陞 (Stanley Chu)

  reply	other threads:[~2022-07-30  7:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29  7:55 [PATCH v1] scsi: ufs: Fix ufshcd_scale_clks decision in recovery flow Stanley Chu
2022-07-29 20:11 ` Bart Van Assche
2022-07-30  7:08   ` Stanley Chu [this message]
2022-08-01 17:34     ` Bart Van Assche
2022-08-02  0:31       ` Stanley Chu

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='CAGaU9a_G1kH8VezozhZ3-S6-GvMr=EUVc4btU8Dwdo+cCJDxUg@mail.gmail.com' \
    --to=chu.stanley@gmail.com \
    --cc=alice.chao@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=cc.chou@mediatek.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=chun-hung.wu@mediatek.com \
    --cc=eddie.huang@mediatek.com \
    --cc=jejb@linux.ibm.com \
    --cc=jiajie.hao@mediatek.com \
    --cc=lin.gui@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mason.zhang@mediatek.com \
    --cc=peter.wang@mediatek.com \
    --cc=powen.kao@mediatek.com \
    --cc=qilin.tan@mediatek.com \
    --cc=stanley.chu@mediatek.com \
    --cc=tun-yu.yu@mediatek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.