Skip to contentSkip to conversation

ufs: core: wlun suspend SSU/enter hibern8 fail recovery

PATCH Superseded [email protected] 4 participants 6 messages Dec 6, 2022 – Dec 8, 2022

Subsystems (3)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 ufs: core: wlun suspend SSU/enter hibern8 fail recovery

From: Peter Wang <[email protected]>

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.

---
 drivers/ufs/core/ufshcd.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/ufs/core/ufshcd.c +26 -0
index b1f59a5fe632..98f105f32877 100644
@@ -9049,6 +9049,19 @@ 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_irq(hba->host->host_lock);
+				hba->force_reset = true;
+				ufshcd_schedule_eh_work(hba);
+				spin_unlock_irq(hba->host->host_lock);
+
+				ret = -EBUSY;
+			}
 			if (ret)
 				goto enable_scaling;
 		}
@@ -9060,6 +9073,19 @@ 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_irq(hba->host->host_lock);
+		hba->force_reset = true;
+		ufshcd_schedule_eh_work(hba);
+		spin_unlock_irq(hba->host->host_lock);
+
+		ret = -EBUSY;
+	}
 	if (ret)
 		goto set_dev_active;
 
Signature · 1 line
2.18.0
Reviewed-by on v4 1/1
#3 lore raw
In reply to [email protected]
Quoted 8 lines · On 6/12/22 05:11, [email protected] wrote:

From: Peter Wang <[email protected]>

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.

Should this have a Fixes or stable tag?

Another minor comment below, otherwise:

Quoted 32 lines
---
 drivers/ufs/core/ufshcd.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/ufs/core/ufshcd.c +13 -0
index b1f59a5fe632..98f105f32877 100644
@@ -9049,6 +9049,19 @@ 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_irq(hba->host->host_lock);
+				hba->force_reset = true;
+				ufshcd_schedule_eh_work(hba);
+				spin_unlock_irq(hba->host->host_lock);
+
+				ret = -EBUSY;
+			}
 			if (ret)
 				goto enable_scaling;
 		}
@@ -9060,6 +9073,19 @@ 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);

drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 9085

Quoted 10 lines
drivers/ufs/core/ufshcd.c +10 -0
+	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_irq(hba->host->host_lock);
+		hba->force_reset = true;
+		ufshcd_schedule_eh_work(hba);
+		spin_unlock_irq(hba->host->host_lock);

Same 4 lines of code could be separated into a helper function.

Quoted 6 lines
drivers/ufs/core/ufshcd.c +3 -0
+
+		ret = -EBUSY;
+	}
 	if (ret)
 		goto set_dev_active;
 
#4 lore raw
Quoted 12 lines · Adrian Hunter
Quoted 8 lines · On 6/12/22 05:11, [email protected] wrote:

From: Peter Wang <[email protected]>

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.

Should this have a Fixes or stable tag?

Hi Adrian,

Yes, will add Fixes tag.
Thanks for reminder.

Quoted 46 lines

Another minor comment below, otherwise:

Quoted 42 lines
---
 drivers/ufs/core/ufshcd.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/ufs/core/ufshcd.c +3 -0
index b1f59a5fe632..98f105f32877 100644
@@ -9049,6 +9049,19 @@ 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.

drivers/ufs/core/ufshcd.c +1 -0
+				 * Trigger error handler and break

suspend for

drivers/ufs/core/ufshcd.c +13 -0
+				 * error recovery.
+				 */
+				spin_lock_irq(hba->host->host_lock);
+				hba->force_reset = true;
+				ufshcd_schedule_eh_work(hba);
+				spin_unlock_irq(hba->host->host_lock);
+
+				ret = -EBUSY;
+			}
 			if (ret)
 				goto enable_scaling;
 		}
@@ -9060,6 +9073,19 @@ 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
Quoted 8 lines

drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · line 9061

Quoted 6 lines
drivers/ufs/core/ufshcd.c +6 -0
+		 * error recovery.
+		 */
+		spin_lock_irq(hba->host->host_lock);
+		hba->force_reset = true;
+		ufshcd_schedule_eh_work(hba);
+		spin_unlock_irq(hba->host->host_lock);

Same 4 lines of code could be separated into a helper function.

OK, will change next version.
Thanks for review.

Quoted 9 lines
Quoted 7 lines
drivers/ufs/core/ufshcd.c +3 -0
+
+		ret = -EBUSY;
+	}
 	if (ret)

goto set_dev_active;

#5 lore raw
In reply to Adrian Hunter
Quoted 75 lines · Adrian Hunter
Quoted 8 lines · On 6/12/22 05:11, [email protected] wrote:

From: Peter Wang <[email protected]>

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.

Should this have a Fixes or stable tag?

Another minor comment below, otherwise:

Quoted 38 lines
---
 drivers/ufs/core/ufshcd.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/ufs/core/ufshcd.c +3 -0
index b1f59a5fe632..98f105f32877 100644
@@ -9049,6 +9049,19 @@ 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.

drivers/ufs/core/ufshcd.c +1 -0
+				 * Trigger error handler and break

suspend for

drivers/ufs/core/ufshcd.c +9 -0
+				 * error recovery.
+				 */
+				spin_lock_irq(hba->host->host_lock);
+				hba->force_reset = true;
+				ufshcd_schedule_eh_work(hba);
+				spin_unlock_irq(hba->host->host_lock);
+
+				ret = -EBUSY;
+			}
 			if (ret)
 				goto enable_scaling;
 		}
@@ -9060,6 +9073,19 @@ 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);

drivers/ufs/core/ufshcd.c static int __ufshcd_wl_suspend(struct · line 9087

Quoted 10 lines
drivers/ufs/core/ufshcd.c +10 -0
+	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_irq(hba->host->host_lock);
+		hba->force_reset = true;
+		ufshcd_schedule_eh_work(hba);
+		spin_unlock_irq(hba->host->host_lock);

Same 4 lines of code could be separated into a helper function.

Quoted 6 lines
drivers/ufs/core/ufshcd.c +3 -0
+
+		ret = -EBUSY;
+	}
 	if (ret)

goto set_dev_active;