Skip to contentSkip to conversation

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

PATCH Superseded [email protected] 2 participants 3 messages Dec 1, 2022 – Dec 2, 2022

Subsystems (3)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/ufs/core/ufshcd.c +29 -0
index b1f59a5fe632..8e5f7d9fe7c2 100644
@@ -8970,6 +8970,7 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 	enum ufs_pm_level pm_lvl;
 	enum ufs_dev_pwr_mode req_dev_pwr_mode;
 	enum uic_link_state req_link_state;
+	unsigned long flags;
 
 	hba->pm_op_in_progress = true;
 	if (pm_op != UFS_SHUTDOWN_PM) {
@@ -9049,6 +9050,20 @@ 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_irqsave(hba->host->host_lock, flags);
+				hba->force_reset = true;
+				ufshcd_schedule_eh_work(hba);
+				spin_unlock_irqrestore(hba->host->host_lock,
+					flags);
+
+				ret = -EBUSY;
+			}
 			if (ret)
 				goto enable_scaling;
 		}
@@ -9060,6 +9075,20 @@ 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_irqsave(hba->host->host_lock, flags);
+		hba->force_reset = true;
+		ufshcd_schedule_eh_work(hba);
+		spin_unlock_irqrestore(hba->host->host_lock,
+			flags);
+
+		ret = -EBUSY;
+	}
 	if (ret)
 		goto set_dev_active;
 
Signature · 1 line
2.18.0
#1 lore raw

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

Quoted 5 lines · On 12/1/22 01:43, [email protected] wrote:
drivers/ufs/core/ufshcd.c +1 -0
@@ -9049,6 +9050,20 @@ 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)) {

Please remove the superfluous parentheses from the above statement.

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

Quoted 6 lines
drivers/ufs/core/ufshcd.c +6 -0
+				/*
+				 * If return err in suspend flow, IO will hang.
+				 * Trigger error handler and break suspend for
+				 * error recovery.
+				 */
+				spin_lock_irqsave(hba->host->host_lock, flags);

__ufshcd_wl_suspend() is allowed to sleep. Please change spin_lock_irqsave() into spin_lock_irq().

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

Quoted 6 lines
drivers/ufs/core/ufshcd.c +6 -0
+				hba->force_reset = true;
+				ufshcd_schedule_eh_work(hba);
+				spin_unlock_irqrestore(hba->host->host_lock,
+					flags);
+
+				ret = -EBUSY;

Why is the value of 'ret' changed into -EBUSY? Can the above code be left out?

Quoted 8 lines
drivers/ufs/core/ufshcd.c +4 -0
@@ -9060,6 +9075,20 @@ 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

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

Quoted 10 lines
drivers/ufs/core/ufshcd.c +10 -0
+		 * error recovery.
+		 */
+		spin_lock_irqsave(hba->host->host_lock, flags);
+		hba->force_reset = true;
+		ufshcd_schedule_eh_work(hba);
+		spin_unlock_irqrestore(hba->host->host_lock,
+			flags);
+
+		ret = -EBUSY;
+	}

Same comments as above for this code block.

Thanks,

Bart.

#2 lore raw
Quoted 11 lines · Bart Van Assche

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

Quoted 7 lines · On 12/1/22 01:43, [email protected] wrote:
drivers/ufs/core/ufshcd.c +1 -0
@@ -9049,6 +9050,20 @@ 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)) {

Please remove the superfluous parentheses from the above statement.

Hi Bart,

Okay, will change next version.

Quoted 16 lines
Quoted 9 lines
(quoted diff) +2 -0
+				/*
+				 * If return err in suspend flow, IO

will hang.

(quoted diff) +1 -0
+				 * Trigger error handler and break

suspend for

drivers/ufs/core/ufshcd.c +3 -0
+				 * error recovery.
+				 */
+				spin_lock_irqsave(hba->host->host_lock, 

flags);

__ufshcd_wl_suspend() is allowed to sleep. Please change spin_lock_irqsave() into spin_lock_irq().

Quoted 3 lines
drivers/ufs/core/ufshcd.c +3 -0
+				hba->force_reset = true;
+				ufshcd_schedule_eh_work(hba);
+				spin_unlock_irqrestore(hba->host-
Quoted 8 lines

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

Quoted 4 lines
Quoted 1 line

host_lock,

drivers/ufs/core/ufshcd.c +3 -0
+					flags);
+
+				ret = -EBUSY;

Why is the value of 'ret' changed into -EBUSY? Can the above code be left out?

Because in runtime pm framework, return EBUSY is okay for next time runtime suspend retry.
Return ETIMEOUT/EIO or other then EBUSY will keep error code in veriable "runtime_error". (supplier first then consumer resume block by supplier also get runtime_error too). Finally, lead to IO hang.

Quoted 23 lines
Quoted 10 lines
drivers/ufs/core/ufshcd.c +4 -0
@@ -9060,6 +9075,20 @@ 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

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

Quoted 10 lines
drivers/ufs/core/ufshcd.c +10 -0
+		 * error recovery.
+		 */
+		spin_lock_irqsave(hba->host->host_lock, flags);
+		hba->force_reset = true;
+		ufshcd_schedule_eh_work(hba);
+		spin_unlock_irqrestore(hba->host->host_lock,
+			flags);
+
+		ret = -EBUSY;
+	}

Same comments as above for this code block.

Quoted 3 lines

Thanks,

Bart.

Okay, will change next version.

Thanks
BR
Peter

Quoted 1 line