From: Chaotian Jing <chaotian.jing@mediatek.com>
To: Peter Wang <peter.wang@mediatek.com>,
Bart Van Assche <bvanassche@acm.org>, <stanley.chu@mediatek.com>,
<linux-scsi@vger.kernel.org>, <martin.petersen@oracle.com>,
<avri.altman@wdc.com>, <alim.akhtar@samsung.com>,
<jejb@linux.ibm.com>
Cc: <wsd_upstream@mediatek.com>, <linux-mediatek@lists.infradead.org>,
<chun-hung.wu@mediatek.com>, <alice.chao@mediatek.com>,
<cc.chou@mediatek.com>, <jiajie.hao@mediatek.com>,
<powen.kao@mediatek.com>, <qilin.tan@mediatek.com>,
<lin.gui@mediatek.com>
Subject: Re: [PATCH v1] scsi: ufs: correct ufshcd_shutdown flow
Date: Fri, 22 Jul 2022 09:27:45 +0800 [thread overview]
Message-ID: <fab0b6332a5a43634f3df437c2b38bc3e618aa4d.camel@mediatek.com> (raw)
In-Reply-To: <a71af42f-3b66-c0a1-c79d-a4573d0376fe@mediatek.com>
On Thu, 2022-07-21 at 12:30 +0800, Peter Wang wrote:
> Hi Bart
>
> On 7/21/22 5:40 AM, Bart Van Assche wrote:
> > On 7/19/22 06:02, peter.wang@mediatek.com wrote:
> > > From: Peter Wang <peter.wang@mediatek.com>
> > >
> > > After ufshcd_wl_shutdown set device poweroff and link off,
> > > ufshcd_shutdown not turn off regulators/clocks.
> > > Correct the flow to wait ufshcd_wl_shutdown done and turn off
> > > regulators/clocks by polling ufs device/link state 500ms.
> > > Also remove pm_runtime_get_sync because it is unnecessary.
> >
> > Please explain in the patch description why the
> > pm_runtime_get_sync()
> > call is not necessary.
>
> Because shutdown is focus on turn off clock/power, we don't need
> turn
> on(resume) and turn off, right?
>
> >
> > > diff --git a/drivers/ufs/core/ufshcd.c
> > > b/drivers/ufs/core/ufshcd.c
> > > index c7b337480e3e..1c11af48b584 100644
> > > --- a/drivers/ufs/core/ufshcd.c
> > > +++ b/drivers/ufs/core/ufshcd.c
> > > @@ -9461,10 +9461,14 @@ EXPORT_SYMBOL(ufshcd_runtime_resume);
> > > */
> > > int ufshcd_shutdown(struct ufs_hba *hba)
> > > {
> > > - if (ufshcd_is_ufs_dev_poweroff(hba) &&
> > > ufshcd_is_link_off(hba))
> > > - goto out;
> > > + ktime_t timeout = ktime_add_ms(ktime_get(), 500);
> >
> > Where does the 500 ms timeout come from?
>
> It is a time to wait device into power off, if the 500 ms is not
> suitable, could you suggess a value?
>
> >
> > Additionally, given the large timeout, please use jiffies instead
> > of
> > ktime_get().
>
> Okay, will change next version.
>
> >
> > > - pm_runtime_get_sync(hba->dev);
> > > + /* Wait ufshcd_wl_shutdown clear ufs state, timeout 500 ms
> > > */
> > > + while (!ufshcd_is_ufs_dev_poweroff(hba) ||
> > > !ufshcd_is_link_off(hba)) {
> > > + if (ktime_after(ktime_get(), timeout))
> > > + goto out;
> > > + msleep(1);
> > > + }
> >
> > Please explain why this wait loop has been introduced.
>
> Both ufshcd_shtdown and ufshcd_wl_shutdown could run concurrently.
Is it possible to avoid the dev's shutdown and its parent's shutdown
run concurrently ? if cannnot avoid it, then seems the concurrently run
case may happen at any device and its parent device! then how do deal
with it ?
Also, the timeout 500ms may make no sense as the child device may not
get the device lock of its parent(it must wait parent's shutdown()
return then it can get the device lock).
>
> if ufshcd_wl_shutdown -> ufshcd_shtdown, clock/power off should ok.
>
> If ufshcd_shtdown -> ufshcd_wl_shutdown, wait ufshcd_wl_shutdown set
> device to power off and turn off clock/power.
>
> If timeout happen, means device still in active mode, cannot turn
> off
> clock/power directly. Skip and keep clock/power on in this case.
>
>
> >
> > Thanks,
> >
> > Bart.
next prev parent reply other threads:[~2022-07-22 2:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 13:02 [PATCH v1] scsi: ufs: correct ufshcd_shutdown flow peter.wang
2022-07-20 21:40 ` Bart Van Assche
2022-07-21 4:30 ` Peter Wang
2022-07-22 1:27 ` Chaotian Jing [this message]
2022-07-22 2:32 ` Peter Wang
2022-07-22 18:04 ` Bart Van Assche
2022-07-25 3:45 ` Peter Wang
2022-07-22 21:07 ` Bart Van Assche
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=fab0b6332a5a43634f3df437c2b38bc3e618aa4d.camel@mediatek.com \
--to=chaotian.jing@mediatek.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=chun-hung.wu@mediatek.com \
--cc=jejb@linux.ibm.com \
--cc=jiajie.hao@mediatek.com \
--cc=lin.gui@mediatek.com \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=peter.wang@mediatek.com \
--cc=powen.kao@mediatek.com \
--cc=qilin.tan@mediatek.com \
--cc=stanley.chu@mediatek.com \
--cc=wsd_upstream@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.