scsi: ufs: Fix a bug in ufshcd_system_resume()
PATCH 1/1 scsi: ufs: Fix a bug in ufshcd_system_resume()
During system resume, ufshcd_system_resume() won't resume UFS host if runtime suspended. After that, scsi_bus_resume() try to set SCSI host's RPM status to RPM_ACTIVE, this will fail because UFS host's RPM status is still RPM_SUSPENDED. So fix it.
scsi host0: scsi_runtime_suspend()
ufshcd_runtime_suspend()
scsi host0: scsi_bus_suspend()
ufshcd_system_suspend()
----------------------------------
ufshcd_pltfrm_resume()
scsi host0: scsi_bus_resume()
scsi host0: scsi_bus_resume_common()
scsi host0: pm_runtime_set_active(dev)
scsi host0: runtime PM trying to activate child device host0 but parent (8800000.ufshc) is not active
--- drivers/scsi/ufs/ufshcd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/scsi/ufs/ufshcd.c +9 -6
@@ -8767,11 +8767,7 @@ int ufshcd_system_resume(struct ufs_hba *hba)if (!hba)return -EINVAL ; -if (!hba->is_powered ||pm_runtime_suspended (hba->dev)) -/* -* Let the runtime resume take care of resuming -* if runtime suspended. -*/ +if (!hba->is_powered) goto out;else ret =ufshcd_resume (hba,UFS_SYSTEM_PM );
@@ -8779,8 +8775,15 @@ int ufshcd_system_resume(struct ufs_hba *hba)trace_ufshcd_system_resume (dev_name (hba->dev), ret,ktime_to_us (ktime_sub (ktime_get (), start)), hba->curr_dev_pwr_mode, hba->uic_link_state); -if (!ret) +if (!ret) { hba->is_sys_suspended = false; + +if (pm_runtime_suspended (hba->dev)) { +pm_runtime_disable (hba->dev); +pm_runtime_set_active (hba->dev); +pm_runtime_enable (hba->dev); + } + }return ret; }EXPORT_SYMBOL (ufshcd_system_resume);
Signature · 1 line
2.17.1
Quoted 49 lines · Yang Yang
During system resume,
ufshcd_system_resume()won't resume UFS host if runtime suspended. After that,scsi_bus_resume()try to set SCSI host's RPM status toRPM_ACTIVE, this will fail because UFS host's RPM status is stillRPM_SUSPENDED. So fix it.scsi host0:
scsi_runtime_suspend()
ufshcd_runtime_suspend()
scsi host0:scsi_bus_suspend()
ufshcd_system_suspend()
----------------------------------
ufshcd_pltfrm_resume()
scsi host0:scsi_bus_resume()
scsi host0:scsi_bus_resume_common()
scsi host0:pm_runtime_set_active(dev)scsi host0: runtime PM trying to activate child device host0 but
parent(8800000.ufshc) is not activeFixes 57d104c153d3 ("ufs: add UFS power management support")Signed-off-by Yang Yang <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)drivers/scsi/ufs/ufshcd.c +2
-6@@ -8767,11 +8767,7 @@ int ufshcd_system_resume(struct ufs_hba *hba)if (!hba)return -EINVAL ; -if (!hba->is_powered ||pm_runtime_suspended (hba->dev)) -/* -* Let the runtime resume take care of resuming -* if runtime suspended. -*/ +if (!hba->is_powered) goto out;else ret =ufshcd_resume (hba,UFS_SYSTEM_PM );@@ -8779,8 +8775,15 @@ int ufshcd_system_resume(struct ufs_hba *hba)trace_ufshcd_system_resume (dev_name (hba->dev), ret,ktime_to_us (ktime_sub (ktime_get (), start)), hba->curr_dev_pwr_mode, hba->uic_link_state); -if (!ret) +if (!ret) { hba->is_sys_suspended = false;
drivers/scsi/ufs/ufshcd.c int ufshcd_system_resume(struct ufs_hba *hba) · line 8789
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +7
-0+ +if (pm_runtime_suspended (hba->dev)) { +pm_runtime_disable (hba->dev); +pm_runtime_set_active (hba->dev); +pm_runtime_enable (hba->dev); + } + }return ret; }EXPORT_SYMBOL (ufshcd_system_resume);
It is designed like this - if hba is runtime suspend, do not resume it during system resume, which is the so called deferred resume feature. This is to leave the runtime PM management to block layer PM, which is more power efficiency.
Quoted 2 lines
scsi host0: runtime PM trying to activate child device host0 but parent (8800000.ufshc) is not active
The log is not harmful or fatal, maybe just annoying. Do you see real problem with it? If yes, please share it here.
Thanks,
Can Guo.