mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Stanley Chu <chu.stanley@gmail.com>
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: Mon, 1 Aug 2022 10:34:51 -0700	[thread overview]
Message-ID: <b92ef74c-1068-b86e-c3c2-a95f057e2494@acm.org> (raw)
In-Reply-To: <CAGaU9a_G1kH8VezozhZ3-S6-GvMr=EUVc4btU8Dwdo+cCJDxUg@mail.gmail.com>

On 7/30/22 00:08, Stanley Chu wrote:
> 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?

Where in ufshcd_host_reset_and_restore() or in its callers is 
hba->host_sem obtained? I don't see it. Am I perhaps overlooking something?

Thanks,

Bart.

  reply	other threads:[~2022-08-01 17:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29  7:55 Stanley Chu
2022-07-29 20:11 ` Bart Van Assche
2022-07-30  7:08   ` Stanley Chu
2022-08-01 17:34     ` Bart Van Assche [this message]
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=b92ef74c-1068-b86e-c3c2-a95f057e2494@acm.org \
    --to=bvanassche@acm.org \
    --cc=alice.chao@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=cc.chou@mediatek.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=chu.stanley@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®