Skip to contentSkip to conversation

scsi: ufs: add error recovery for suspend and resume in ufs-mediatek

PATCH Superseded Stanley Chu 1 participant 3 messages Mar 14, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover 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.

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 | 12 ++++++++++--
 drivers/scsi/ufs/ufshcd.c       |  3 ++-
 drivers/scsi/ufs/ufshcd.h       |  1 +
 3 files changed, 13 insertions(+), 3 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/2 scsi: ufs: export ufshcd_link_recovery for vendor's error recovery

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

---
 drivers/scsi/ufs/ufshcd.c | 3 ++-
 drivers/scsi/ufs/ufshcd.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +2 -1
index cd33d07c56cf..ca9b6898648a 100644
@@ -3812,7 +3812,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;
@@ -3839,6 +3839,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)
 {
drivers/scsi/ufs/ufshcd.h +1 -0
index 269ddb92bb55..e701960f8669 100644
@@ -779,6 +779,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);
Signature · 1 line
2.18.0
#2 lore raw

PATCH 2/2 scsi: ufs-mediatek: add error recovery for suspend and resume

In reply to 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 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().

---
 drivers/scsi/ufs/ufs-mediatek.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufs-mediatek.c +10 -2
index c0fd7d2e4d0d..f19e9a64d490 100644
@@ -499,8 +499,14 @@ 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 +525,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;
Signature · 1 line
2.18.0