ufs: core: wlun suspend SSU/enter hibern8 fail recovery
Subsystems (4)
PATCH v5 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 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/ufs/core/ufshcd.c +25 -0
@@ -106,6 +106,13 @@ 16, 4, buf, __len, false); \ } while (0) +#define ufshcd_force_error_recovery (hba) do { \ + spin_lock_irq(hba->host->host_lock); \ + hba->force_reset = true; \ + ufshcd_schedule_eh_work(hba); \ + spin_unlock_irq(hba->host->host_lock); \ +} while (0) +int ufshcd_dump_regs (struct ufs_hba *hba,size_t offset,size_t len,const char *prefix) {
@@ -9049,6 +9056,15 @@ 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. +*/ +ufshcd_force_error_recovery (hba); + ret = -EBUSY ; + }if (ret) goto enable_scaling; }
@@ -9060,6 +9076,15 @@ 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. +*/ +ufshcd_force_error_recovery (hba); + ret = -EBUSY ; + }if (ret) goto set_dev_active;
Signature · 1 line
2.18.0
Hi Peter,
Please update the patch version and bring all tags (review, ack ...etc.) to your new patch : )
Quoted 68 lines · On Thu, Dec 8, 2022 at 2:17 PM <[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.Fixes b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")Signed-off-by Peter Wang <[email protected]>--- drivers/ufs/core/ufshcd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/ufs/core/ufshcd.c +25
-1@@ -106,6 +106,13 @@ 16, 4, buf, __len, false); \ } while (0) +#define ufshcd_force_error_recovery (hba) do { \ + spin_lock_irq(hba->host->host_lock); \ + hba->force_reset = true; \ + ufshcd_schedule_eh_work(hba); \ + spin_unlock_irq(hba->host->host_lock); \ +} while (0) +int ufshcd_dump_regs (struct ufs_hba *hba,size_t offset,size_t len,const char *prefix) {@@ -9049,6 +9056,15 @@ 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. +*/ +ufshcd_force_error_recovery (hba); + ret = -EBUSY ; + }if (ret) goto enable_scaling; }@@ -9060,6 +9076,15 @@ 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. +*/ +ufshcd_force_error_recovery (hba); + ret = -EBUSY ; + }if (ret) goto set_dev_active; --2.18.0
Signature · 3 lines
Yours truly, 朱原陞 (Stanley Chu)
Quoted 19 lines · On 8/12/22 08:10, [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.Fixes b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun")Signed-off-by Peter Wang <[email protected]>--- drivers/ufs/core/ufshcd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/ufs/core/ufshcd.c +0
-0
drivers/ufs/core/ufshcd.c line 114
Quoted 9 lines
drivers/ufs/core/ufshcd.c +6
-0@@ -106,6 +106,13 @@ 16, 4, buf, __len, false); \ } while (0) +#define ufshcd_force_error_recovery (hba) do { \ + spin_lock_irq(hba->host->host_lock); \ + hba->force_reset = true; \ + ufshcd_schedule_eh_work(hba); \ + spin_unlock_irq(hba->host->host_lock); \ +} while (0)
Thanks for separating it out, but there is no reason to make this a macro, so it should be a function, because functions offer nicer structure and less chance of surprises. It need not be an inline function either because the compiler can determine that, and this is not a hot path. i.e.
static void ufshcd_force_error_recovery(struct ufs_hba *hba)
{
spin_lock_irq(hba->host->host_lock);
hba->force_reset = true;
ufshcd_schedule_eh_work(hba);
spin_unlock_irq(hba->host->host_lock);
}Quoted 36 lines
drivers/ufs/core/ufshcd.c +19
-0+int ufshcd_dump_regs (struct ufs_hba *hba,size_t offset,size_t len,const char *prefix) {@@ -9049,6 +9056,15 @@ 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. +*/ +ufshcd_force_error_recovery (hba); + ret = -EBUSY ; + }if (ret) goto enable_scaling; }@@ -9060,6 +9076,15 @@ 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. +*/ +ufshcd_force_error_recovery (hba); + ret = -EBUSY ; + }if (ret) goto set_dev_active;
Quoted 43 lines · Adrian Hunter
Quoted 34 lines · On 8/12/22 08:10, [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.Fixes b294ff3e3449 ("scsi: ufs: core: Enable power management forwlun")
Signed-off-by Peter Wang <[email protected]>--- drivers/ufs/core/ufshcd.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/ufs/core/ufshcd.c +3
-0@@ -106,6 +106,13 @@16 ,4 , buf, __len, false); \ } while (0) +#define ufshcd_force_error_recovery (hba) do { \ +spin_lock_irq (hba->host- >host_lock); \ + hba->force_reset =true; \
drivers/ufs/core/ufshcd.c +2
-0+ufshcd_schedule_eh_work (hba); \ + spin_unlock_irq(hba->host-Quoted 1 line
host_lock); \Quoted 1 line
+} while (0)
Thanks for separating it out, but there is no reason to make this a macro, so it should be a function, because functions offer nicer structure and less chance of surprises. It need not be an inline function either because the compiler can determine that, and this is not a hot path. i.e.
Quoted 8 lines
static void
ufshcd_force_error_recovery(struct ufs_hba *hba){ spin_lock_irq(hba->host->host_lock); hba->force_reset = true; ufshcd_schedule_eh_work(hba); spin_unlock_irq(hba->host->host_lock); }
Hi Adrian,
Okay, will change to static function next version, Thank you very much. :)
Peter
Quoted 45 lines
Quoted 43 lines
+
int ufshcd_dump_regs(structufs_hba*hba,size_toffset,size_t
len,drivers/ufs/core/ufshcd.c +3
-0const char *prefix) {@@ -9049,6 +9056,15 @@ 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 +14
-0+* error recovery. +*/ +ufshcd_force_error_recovery (hba); + ret = -EBUSY ; + }if (ret) goto enable_scaling; }@@ -9060,6 +9076,15 @@ static int __ufshcd_wl_suspend(structufs_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. +*/ +ufshcd_force_error_recovery (hba); + ret = -EBUSY ; + }if (ret)goto
set_dev_active;