linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek
@ 2020-03-27  9:53 Stanley Chu
  2020-03-27  9:53 ` [PATCH v3 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery Stanley Chu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stanley Chu @ 2020-03-27  9:53 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
	linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
	peter.wang, chun-hung.wu, andy.teng, Stanley Chu

Hi,

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

v2 -> v3:
  - Fix commit messages (Avri Altman)

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

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

* [PATCH v3 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery
  2020-03-27  9:53 [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Stanley Chu
@ 2020-03-27  9:53 ` Stanley Chu
  2020-03-27  9:53 ` [PATCH v3 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume Stanley Chu
  2020-03-27 17:06 ` [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Stanley Chu @ 2020-03-27  9:53 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
	linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
	peter.wang, chun-hung.wu, andy.teng, Stanley Chu

export ufshcd_link_recovery to allow vendors to recover failed link
in vendor's callbacks.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
---
 drivers/scsi/ufs/ufshcd.c | 3 ++-
 drivers/scsi/ufs/ufshcd.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index b4294b2c6f4a..227660a1a446 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -3756,7 +3756,7 @@ static int ufshcd_uic_change_pwr_mode(struct ufs_hba *hba, u8 mode)
 	return ret;
 }
 
-static int ufshcd_link_recovery(struct ufs_hba *hba)
+int ufshcd_link_recovery(struct ufs_hba *hba)
 {
 	int ret;
 	unsigned long flags;
@@ -3783,6 +3783,7 @@ static int ufshcd_link_recovery(struct ufs_hba *hba)
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(ufshcd_link_recovery);
 
 static int __ufshcd_uic_hibern8_enter(struct ufs_hba *hba)
 {
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 9f1576bbfc50..b7bd81795c24 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -795,6 +795,7 @@ int ufshcd_alloc_host(struct device *, struct ufs_hba **);
 void ufshcd_dealloc_host(struct ufs_hba *);
 int ufshcd_hba_enable(struct ufs_hba *hba);
 int ufshcd_init(struct ufs_hba * , void __iomem * , unsigned int);
+int ufshcd_link_recovery(struct ufs_hba *hba);
 int ufshcd_make_hba_operational(struct ufs_hba *hba);
 void ufshcd_remove(struct ufs_hba *);
 int ufshcd_uic_hibern8_exit(struct ufs_hba *hba);
-- 
2.18.0

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

* [PATCH v3 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume
  2020-03-27  9:53 [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Stanley Chu
  2020-03-27  9:53 ` [PATCH v3 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery Stanley Chu
@ 2020-03-27  9:53 ` Stanley Chu
  2020-03-27 17:06 ` [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Stanley Chu @ 2020-03-27  9:53 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
	linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
	peter.wang, chun-hung.wu, andy.teng, Stanley Chu

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 vendor callback. One solution is to set the link to off state
and then ufshcd_host_reset_and_restore() will be executed by ufshcd_suspend().

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
---
 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 40a66b31b31f..673c16596fb2 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -499,8 +499,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))
@@ -519,8 +526,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

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

* Re: [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek
  2020-03-27  9:53 [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Stanley Chu
  2020-03-27  9:53 ` [PATCH v3 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery Stanley Chu
  2020-03-27  9:53 ` [PATCH v3 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume Stanley Chu
@ 2020-03-27 17:06 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2020-03-27 17:06 UTC (permalink / raw)
  To: Stanley Chu
  Cc: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb,
	beanhuo, asutoshd, cang, matthias.bgg, bvanassche,
	linux-mediatek, linux-arm-kernel, linux-kernel, kuohong.wang,
	peter.wang, chun-hung.wu, andy.teng


Stanley,

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

Applied to 5.7/scsi-queue. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2020-03-27 17:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27  9:53 [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Stanley Chu
2020-03-27  9:53 ` [PATCH v3 1/2] scsi: ufs: export ufshcd_link_recovery for vendor's error recovery Stanley Chu
2020-03-27  9:53 ` [PATCH v3 2/2] scsi: ufs-mediatek: add error recovery for suspend and resume Stanley Chu
2020-03-27 17:06 ` [PATCH v3 0/2] scsi: ufs: add error recovery for suspend and resume in ufs-mediatek Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).