All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] ufs: core: wlun suspend dev/link state error recovery
@ 2024-03-28 10:47 peter.wang
  2024-03-28 17:31 ` Bart Van Assche
  0 siblings, 1 reply; 3+ messages in thread
From: peter.wang @ 2024-03-28 10:47 UTC (permalink / raw)
  To: 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,
	chu.stanley

From: Peter Wang <peter.wang@mediatek.com>

When wl suspend error occurs, for example, BKOP or SSU timeout, the host
triggers an error handler and returns -EBUSY to break the wl suspend process.
However, it is possible for the runtime PM to enter wl suspend again before
the error handler has finished, and return -EINVAL because the device is
in an error state. To address this, ensure that the rumtime PM waits for the
error handler to finish, or trigger the error handler in such cases,
because returning -EINVAL can cause the I/O to hang.

Signed-off-by: Peter Wang <peter.wang@mediatek.com>
---
 drivers/ufs/core/ufshcd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index e30fd125988d..0a32f423f6a0 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -9791,7 +9791,10 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 
 	/* UFS device & link must be active before we enter in this function */
 	if (!ufshcd_is_ufs_dev_active(hba) || !ufshcd_is_link_active(hba)) {
-		ret = -EINVAL;
+		/*  Wait err handler finish or tirgger err recovery in this case */
+		if (!ufshcd_eh_in_progress(hba))
+			ufshcd_force_error_recovery(hba);
+		ret = -EBUSY;
 		goto enable_scaling;
 	}
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] ufs: core: wlun suspend dev/link state error recovery
  2024-03-28 10:47 [PATCH v1] ufs: core: wlun suspend dev/link state error recovery peter.wang
@ 2024-03-28 17:31 ` Bart Van Assche
  2024-03-29  1:48   ` Peter Wang (王信友)
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2024-03-28 17:31 UTC (permalink / raw)
  To: peter.wang, 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, chu.stanley

On 3/28/24 03:47, peter.wang@mediatek.com wrote:
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index e30fd125988d..0a32f423f6a0 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -9791,7 +9791,10 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
>   
>   	/* UFS device & link must be active before we enter in this function */
>   	if (!ufshcd_is_ufs_dev_active(hba) || !ufshcd_is_link_active(hba)) {
> -		ret = -EINVAL;
> +		/*  Wait err handler finish or tirgger err recovery in this case */
> +		if (!ufshcd_eh_in_progress(hba))
> +			ufshcd_force_error_recovery(hba);
> +		ret = -EBUSY;
>   		goto enable_scaling;
>   	}

Please fix the spelling in the above source code comment ("tirgger").

Thanks,

Bart.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] ufs: core: wlun suspend dev/link state error recovery
  2024-03-28 17:31 ` Bart Van Assche
@ 2024-03-29  1:48   ` Peter Wang (王信友)
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Wang (王信友) @ 2024-03-29  1:48 UTC (permalink / raw)
  To: linux-scsi, bvanassche, avri.altman, jejb, alim.akhtar, martin.petersen
  Cc: linux-mediatek, Jiajie Hao (郝加节),
	CC Chou (周志杰),
	Eddie Huang (黃智傑),
	Alice Chao (趙珮均),
	wsd_upstream, Lin Gui (桂林),
	Chun-Hung Wu (巫駿宏),
	Tun-yu Yu (游敦聿),
	chu.stanley, Chaotian Jing (井朝天),
	Powen Kao (高伯文),
	Naomi Chu (朱詠田),
	Qilin Tan (谭麒麟)

On Thu, 2024-03-28 at 10:31 -0700, Bart Van Assche wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On 3/28/24 03:47, peter.wang@mediatek.com wrote:
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index e30fd125988d..0a32f423f6a0 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -9791,7 +9791,10 @@ static int __ufshcd_wl_suspend(struct
> ufs_hba *hba, enum ufs_pm_op pm_op)
> >   
> >   /* UFS device & link must be active before we enter in this
> function */
> >   if (!ufshcd_is_ufs_dev_active(hba) ||
> !ufshcd_is_link_active(hba)) {
> > -ret = -EINVAL;
> > +/*  Wait err handler finish or tirgger err recovery in this case
> */
> > +if (!ufshcd_eh_in_progress(hba))
> > +ufshcd_force_error_recovery(hba);
> > +ret = -EBUSY;
> >   goto enable_scaling;
> >   }
> 
> Please fix the spelling in the above source code comment ("tirgger").
> 
> Thanks,
> 
> Bart.
> 
> 

Hi Bart,

Will fix typo next version.

Thanks
Peter



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-29  1:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 10:47 [PATCH v1] ufs: core: wlun suspend dev/link state error recovery peter.wang
2024-03-28 17:31 ` Bart Van Assche
2024-03-29  1:48   ` Peter Wang (王信友)

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.