Three minor fixes w.r.t suspend/resume
v2 cover Three minor fixes w.r.t suspend/resume
1st change can fix a possible OCP issue when AH8 error happens.
2nd and 3rd change can fix race conditions btw suspend/resume and other contexts.
Can Guo (3):
scsi: ufs: Do not put UFS power into LPM if link is broken
scsi: ufs: Cancel rpm_dev_flush_recheck_work during system suspend
scsi: ufs: Narrow down fast pass in system suspend path
Change since V1:
- Incorporated Daejun's comment.
drivers/scsi/ufs/ufshcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v2 1/3 scsi: ufs: Do not put UFS power into LPM if link is broken
During resume, if link is broken due to AH8 failure, make sure ufshcd_resume() do not put UFS power back into LPM.
--- drivers/scsi/ufs/ufshcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +2 -2
@@ -8660,7 +8660,7 @@ static void ufshcd_vreg_set_lpm(struct ufs_hba *hba) }else if (!ufshcd_is_ufs_dev_active (hba)) {ufshcd_toggle_vreg (hba->dev, hba->vreg_info.vcc, false); vcc_off = true; -if (!ufshcd_is_link_active (hba)) { +if (ufshcd_is_link_hibern8 (hba) ||ufshcd_is_link_off (hba)) {ufshcd_config_vreg_lpm (hba, hba->vreg_info.vccq);ufshcd_config_vreg_lpm (hba, hba->vreg_info.vccq2); }
@@ -8682,7 +8682,7 @@ static int ufshcd_vreg_set_hpm(struct ufs_hba *hba) !hba->dev_info.is_lu_power_on_wp) { ret =ufshcd_setup_vreg (hba, true); } else if (!ufshcd_is_ufs_dev_active(hba)) { -if (!ret && !ufshcd_is_link_active (hba)) { +if (!ufshcd_is_link_active (hba)) { ret =ufshcd_config_vreg_hpm (hba, hba->vreg_info.vccq);if (ret) goto vcc_disable;
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v2 2/3 scsi: ufs: Cancel rpm_dev_flush_recheck_work during system suspend
In reply to Can GuoDuring ufs system suspend, leaving rpm_dev_flush_recheck_work running or pending is risky, because concurrency may happen btw system suspend/resume and runtime resume routine. Fix it by cancelling rpm_dev_flush_recheck_work synchronously during system suspend.
--- drivers/scsi/ufs/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/ufs/ufshcd.c +2 -0
@@ -9044,6 +9044,8 @@ int ufshcd_system_suspend(struct ufs_hba *hba)if (!hba->is_powered)return 0 ; +cancel_delayed_work_sync (&hba->rpm_dev_flush_recheck_work); + if ((ufs_get_pm_lvl_to_dev_pwr_mode(hba->spm_lvl) == hba->curr_dev_pwr_mode) && (ufs_get_pm_lvl_to_link_pwr_state(hba->spm_lvl) ==
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
PATCH v2 3/3 scsi: ufs: Narrow down fast pass in system suspend path
In reply to Can GuoIf spm_lvl is set to 0 or 1, when system suspend kicks start and hba is runtime active, system suspend may just bail without doing anything (the fast pass), leaving other contexts still running, e.g., clock gating and clock scaling. When system resume kicks start, concurrency can happen btw ufshcd_resume() and these contexts, leading to various stability issues. Fix it by adding a check against hba's runtime status and allowing fast pass only if hba is runtime suspended, otherwise let system suspend go ahead call ufshcd_suspend(). This can guarantee that these contexts are stopped by either runtime suspend or system suspend.
--- drivers/scsi/ufs/ufshcd.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/ufs/ufshcd.c +1 -0
@@ -9050,6 +9050,7 @@ int ufshcd_system_suspend(struct ufs_hba *hba) hba->curr_dev_pwr_mode) && (ufs_get_pm_lvl_to_link_pwr_state (hba->spm_lvl) == hba->uic_link_state) && +pm_runtime_suspended (hba->dev) && !hba->dev_info.b_rpm_dev_flush_capable) goto out;
Signature · 1 line
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
Hi Can Guo,
Quoted 8 lines
1st change can fix a possible OCP issue when AH8 error happens.
2nd and 3rd change can fix race conditions btw suspend/resume and other contexts.Can Guo (3):
scsi: ufs: Do not put UFS power into LPM if link is broken
scsi: ufs: Cancelrpm_dev_flush_recheck_workduring system suspend
scsi: ufs: Narrow down fast pass in system suspend path
Quoted 6 lines
Change since V1:
- Incorporated Daejun's comment.
drivers/scsi/ufs/ufshcd.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)
This series looks good to me.
Thanks,
Daejun
Martin K. Petersen
AppliedQuoted 9 lines · Can Guo
1st change can fix a possible OCP issue when AH8 error happens.
2nd and 3rd change can fix race conditions btw suspend/resume and other contexts.Can Guo (3):
scsi: ufs: Do not put UFS power into LPM if link is broken
scsi: ufs: Cancelrpm_dev_flush_recheck_workduring system suspend
scsi: ufs: Narrow down fast pass in system suspend path[...]
Applied to 5.13/scsi-fixes, thanks!
[1/3] scsi: ufs: Do not put UFS power into LPM if link is broken
https://git.kernel.org/mkp/scsi/c/23043dd87b15 [2/3] scsi: ufs: Cancel rpm_dev_flush_recheck_work during system suspend https://git.kernel.org/mkp/scsi/c/637822e63b79 [3/3] scsi: ufs: Narrow down fast pass in system suspend path https://git.kernel.org/mkp/scsi/c/ce4f62f9dd8c
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering