2020-03-26 15:10:08

by Stanley Chu

[permalink] [raw]
Subject: [PATCH v2 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek

Hi,

This patchset adds error recovery flow for suspend and resume in ufs-mediatek driver.

v1 -> v2:
- Fix format of comments

Stanley Chu (2):
scsi: ufs: export ufshcd_link_recovery for vendor's error recovery
scsi: ufs-mediatek: add error recovery for suspend and resume

drivers/scsi/ufs/ufs-mediatek.c | 13 +++++++++++--
drivers/scsi/ufs/ufshcd.c | 3 ++-
drivers/scsi/ufs/ufshcd.h | 1 +
3 files changed, 14 insertions(+), 3 deletions(-)

--
2.18.0


2020-03-26 15:11:06

by Stanley Chu

[permalink] [raw]
Subject: [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume

Once fail happens during suspend and resume flow if the desired low
power link state is H8, link recovery is required for MediaTek UFS
controller.

For resume flow, since power and clocks are already enabled before
invoking vendor's resume callback, simply using ufshcd_link_recovery()
inside callback is fine.

For suspend flow, the device power enters low power mode or is disabled
before suspend callback, thus ufshcd_link_recovery() can not be directly
used in callback. To leverage host reset flow during ufshcd_suspend(),
set link as off state enforcedly to let ufshcd_host_reset_and_restore()
be executed by ufshcd_suspend().

Signed-off-by: Stanley Chu <[email protected]>
---
drivers/scsi/ufs/ufs-mediatek.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 3b0e575d7460..2384e35ac85f 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -486,8 +486,15 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)

if (ufshcd_is_link_hibern8(hba)) {
err = ufs_mtk_link_set_lpm(hba);
- if (err)
+ if (err) {
+ /*
+ * Set link as off state enforcedly to trigger
+ * ufshcd_host_reset_and_restore() in ufshcd_suspend()
+ * for completed host reset.
+ */
+ ufshcd_set_link_off(hba);
return -EAGAIN;
+ }
}

if (!ufshcd_is_link_active(hba))
@@ -506,8 +513,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)

if (ufshcd_is_link_hibern8(hba)) {
err = ufs_mtk_link_set_hpm(hba);
- if (err)
+ if (err) {
+ err = ufshcd_link_recovery(hba);
return err;
+ }
}

return 0;
--
2.18.0

2020-03-27 09:25:14

by Avri Altman

[permalink] [raw]
Subject: RE: [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume


>
> Once fail happens during suspend and resume flow if the desired low
> power link state is H8, link recovery is required for MediaTek UFS
> controller.
>
> For resume flow, since power and clocks are already enabled before
> invoking vendor's resume callback, simply using ufshcd_link_recovery()
> inside callback is fine.
>
> For suspend flow, the device power enters low power mode or is disabled
> before suspend callback, thus ufshcd_link_recovery() can not be directly
> used in callback. To leverage host reset flow during ufshcd_suspend(),
> set link as off state enforcedly
Not sure this is a proper English, but I'm not sure.

to let ufshcd_host_reset_and_restore()
> be executed by ufshcd_suspend().
>
> Signed-off-by: Stanley Chu <[email protected]>
Reviewed-by: Avri Altman <[email protected]>

2020-03-27 09:57:19

by Stanley Chu

[permalink] [raw]
Subject: RE: [PATCH v2 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume

Hi Avri,

On Fri, 2020-03-27 at 09:23 +0000, Avri Altman wrote:
> >
> > Once fail happens during suspend and resume flow if the desired low
> > power link state is H8, link recovery is required for MediaTek UFS
> > controller.
> >
> > For resume flow, since power and clocks are already enabled before
> > invoking vendor's resume callback, simply using ufshcd_link_recovery()
> > inside callback is fine.
> >
> > For suspend flow, the device power enters low power mode or is disabled
> > before suspend callback, thus ufshcd_link_recovery() can not be directly
> > used in callback. To leverage host reset flow during ufshcd_suspend(),
> > set link as off state enforcedly
> Not sure this is a proper English, but I'm not sure.
>
> to let ufshcd_host_reset_and_restore()
> > be executed by ufshcd_suspend().

Thanks for your review! I will fix this sentence in next version.

Stanley Chu