* [PATCH v2] ufs: core: wlun suspend SSU/enter hibern8 fail recovery
@ 2022-12-01 9:43 peter.wang
2022-12-01 18:44 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: peter.wang @ 2022-12-01 9:43 UTC (permalink / raw)
To: stanley.chu, linux-scsi, martin.petersen, avri.altman,
alim.akhtar, jejb
Cc: wsd_upstream, linux-mediatek, peter.wang, chun-hung.wu,
alice.chao, cc.chou, chaotian.jing, jiajie.hao, powen.kao,
qilin.tan, lin.gui, tun-yu.yu, eddie.huang, naomi.chu
From: Peter Wang <peter.wang@mediatek.com>
When SSU/enter hibern8 fail in wlun suspend flow, trigger error
handler and return busy to break the suspend.
If not, wlun runtime pm status become error and the consumer will
stuck in runtime suspend status.
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
---
drivers/ufs/core/ufshcd.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index b1f59a5fe632..8e5f7d9fe7c2 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -8970,6 +8970,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
enum ufs_pm_level pm_lvl;
enum ufs_dev_pwr_mode req_dev_pwr_mode;
enum uic_link_state req_link_state;
+ unsigned long flags;
hba->pm_op_in_progress = true;
if (pm_op != UFS_SHUTDOWN_PM) {
@@ -9049,6 +9050,20 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
if (!hba->dev_info.b_rpm_dev_flush_capable) {
ret = ufshcd_set_dev_pwr_mode(hba, req_dev_pwr_mode);
+ if ((ret) && (pm_op != UFS_SHUTDOWN_PM)) {
+ /*
+ * If return err in suspend flow, IO will hang.
+ * Trigger error handler and break suspend for
+ * error recovery.
+ */
+ spin_lock_irqsave(hba->host->host_lock, flags);
+ hba->force_reset = true;
+ ufshcd_schedule_eh_work(hba);
+ spin_unlock_irqrestore(hba->host->host_lock,
+ flags);
+
+ ret = -EBUSY;
+ }
if (ret)
goto enable_scaling;
}
@@ -9060,6 +9075,20 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
*/
check_for_bkops = !ufshcd_is_ufs_dev_deepsleep(hba);
ret = ufshcd_link_state_transition(hba, req_link_state, check_for_bkops);
+ if ((ret) && (pm_op != UFS_SHUTDOWN_PM)) {
+ /*
+ * If return err in suspend flow, IO will hang.
+ * Trigger error handler and break suspend for
+ * error recovery.
+ */
+ spin_lock_irqsave(hba->host->host_lock, flags);
+ hba->force_reset = true;
+ ufshcd_schedule_eh_work(hba);
+ spin_unlock_irqrestore(hba->host->host_lock,
+ flags);
+
+ ret = -EBUSY;
+ }
if (ret)
goto set_dev_active;
--
2.18.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ufs: core: wlun suspend SSU/enter hibern8 fail recovery
2022-12-01 9:43 [PATCH v2] ufs: core: wlun suspend SSU/enter hibern8 fail recovery peter.wang
@ 2022-12-01 18:44 ` Bart Van Assche
2022-12-02 6:47 ` Peter Wang (王信友)
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2022-12-01 18:44 UTC (permalink / raw)
To: peter.wang, stanley.chu, linux-scsi, martin.petersen, avri.altman,
alim.akhtar, jejb
Cc: wsd_upstream, linux-mediatek, chun-hung.wu, alice.chao, cc.chou,
chaotian.jing, jiajie.hao, powen.kao, qilin.tan, lin.gui,
tun-yu.yu, eddie.huang, naomi.chu
On 12/1/22 01:43, peter.wang@mediatek.com wrote:
> @@ -9049,6 +9050,20 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
>
> if (!hba->dev_info.b_rpm_dev_flush_capable) {
> ret = ufshcd_set_dev_pwr_mode(hba, req_dev_pwr_mode);
> + if ((ret) && (pm_op != UFS_SHUTDOWN_PM)) {
Please remove the superfluous parentheses from the above statement.
> + /*
> + * If return err in suspend flow, IO will hang.
> + * Trigger error handler and break suspend for
> + * error recovery.
> + */
> + spin_lock_irqsave(hba->host->host_lock, flags);
__ufshcd_wl_suspend() is allowed to sleep. Please change
spin_lock_irqsave() into spin_lock_irq().
> + hba->force_reset = true;
> + ufshcd_schedule_eh_work(hba);
> + spin_unlock_irqrestore(hba->host->host_lock,
> + flags);
> +
> + ret = -EBUSY;
Why is the value of 'ret' changed into -EBUSY? Can the above code be
left out?
> @@ -9060,6 +9075,20 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
> */
> check_for_bkops = !ufshcd_is_ufs_dev_deepsleep(hba);
> ret = ufshcd_link_state_transition(hba, req_link_state, check_for_bkops);
> + if ((ret) && (pm_op != UFS_SHUTDOWN_PM)) {
> + /*
> + * If return err in suspend flow, IO will hang.
> + * Trigger error handler and break suspend for
> + * error recovery.
> + */
> + spin_lock_irqsave(hba->host->host_lock, flags);
> + hba->force_reset = true;
> + ufshcd_schedule_eh_work(hba);
> + spin_unlock_irqrestore(hba->host->host_lock,
> + flags);
> +
> + ret = -EBUSY;
> + }
Same comments as above for this code block.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ufs: core: wlun suspend SSU/enter hibern8 fail recovery
2022-12-01 18:44 ` Bart Van Assche
@ 2022-12-02 6:47 ` Peter Wang (王信友)
0 siblings, 0 replies; 3+ messages in thread
From: Peter Wang (王信友) @ 2022-12-02 6:47 UTC (permalink / raw)
To: linux-scsi@vger.kernel.org, bvanassche@acm.org,
avri.altman@wdc.com, Stanley Chu (朱原陞),
alim.akhtar@samsung.com, martin.petersen@oracle.com,
jejb@linux.ibm.com
Cc: linux-mediatek@lists.infradead.org,
Jiajie Hao (郝加节),
CC Chou (周志杰),
Eddie Huang (黃智傑),
Alice Chao (趙珮均), wsd_upstream,
Lin Gui (桂林),
Chun-Hung Wu (巫駿宏),
Tun-yu Yu (游敦聿),
Chaotian Jing (井朝天),
Powen Kao (高伯文),
Naomi Chu (朱詠田),
Qilin Tan (谭麒麟)
On Thu, 2022-12-01 at 10:44 -0800, Bart Van Assche wrote:
> On 12/1/22 01:43, peter.wang@mediatek.com wrote:
> > @@ -9049,6 +9050,20 @@ static int __ufshcd_wl_suspend(struct
> > ufs_hba *hba, enum ufs_pm_op pm_op)
> >
> > if (!hba->dev_info.b_rpm_dev_flush_capable) {
> > ret = ufshcd_set_dev_pwr_mode(hba,
> > req_dev_pwr_mode);
> > + if ((ret) && (pm_op != UFS_SHUTDOWN_PM)) {
>
> Please remove the superfluous parentheses from the above statement.
>
Hi Bart,
Okay, will change next version.
> > + /*
> > + * If return err in suspend flow, IO
> > will hang.
> > + * Trigger error handler and break
> > suspend for
> > + * error recovery.
> > + */
> > + spin_lock_irqsave(hba->host->host_lock,
> > flags);
>
> __ufshcd_wl_suspend() is allowed to sleep. Please change
> spin_lock_irqsave() into spin_lock_irq().
>
> > + hba->force_reset = true;
> > + ufshcd_schedule_eh_work(hba);
> > + spin_unlock_irqrestore(hba->host-
> > >host_lock,
> > + flags);
> > +
> > + ret = -EBUSY;
>
> Why is the value of 'ret' changed into -EBUSY? Can the above code be
> left out?
>
Because in runtime pm framework, return EBUSY is okay for next time
runtime suspend retry.
Return ETIMEOUT/EIO or other then EBUSY will keep error code in
veriable "runtime_error". (supplier first then consumer resume block by
supplier also get runtime_error too). Finally, lead to IO hang.
> > @@ -9060,6 +9075,20 @@ static int __ufshcd_wl_suspend(struct
> > ufs_hba *hba, enum ufs_pm_op pm_op)
> > */
> > check_for_bkops = !ufshcd_is_ufs_dev_deepsleep(hba);
> > ret = ufshcd_link_state_transition(hba, req_link_state,
> > check_for_bkops);
> > + if ((ret) && (pm_op != UFS_SHUTDOWN_PM)) {
> > + /*
> > + * If return err in suspend flow, IO will hang.
> > + * Trigger error handler and break suspend for
> > + * error recovery.
> > + */
> > + spin_lock_irqsave(hba->host->host_lock, flags);
> > + hba->force_reset = true;
> > + ufshcd_schedule_eh_work(hba);
> > + spin_unlock_irqrestore(hba->host->host_lock,
> > + flags);
> > +
> > + ret = -EBUSY;
> > + }
>
> Same comments as above for this code block.
>
> Thanks,
>
> Bart.
Okay, will change next version.
Thanks
BR
Peter
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-02 6:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-01 9:43 [PATCH v2] ufs: core: wlun suspend SSU/enter hibern8 fail recovery peter.wang
2022-12-01 18:44 ` Bart Van Assche
2022-12-02 6:47 ` Peter Wang (王信友)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox