Skip to content

Commit fe06b7c

Browse files
Mani-Sadhasivammartinkpetersen
authored andcommitted
scsi: ufs: core: Set default runtime/system PM levels before ufshcd_hba_init()
Commit bb98507 ("scsi: ufs: core: Honor runtime/system PM levels if set by host controller drivers") introduced the check for setting default PM levels only if the levels are uninitialized by the host controller drivers. But it missed the fact that the levels could be initialized to 0 (UFS_PM_LVL_0) on purpose by the controller drivers. Even though none of the drivers are doing so now, the logic should be fixed irrespectively. So set the default levels unconditionally before calling ufshcd_hba_init() API which initializes the controller drivers. It ensures that the controller drivers could override the default levels if required. Fixes: bb98507 ("scsi: ufs: core: Honor runtime/system PM levels if set by host controller drivers") Reported-by: Bao D. Nguyen <quic_nguyenb@quicinc.com> Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Link: https://lore.kernel.org/r/20250219105047.49932-1-manivannan.sadhasivam@linaro.org Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent dce5c4a commit fe06b7c

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10431,6 +10431,21 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1043110431
*/
1043210432
spin_lock_init(&hba->clk_gating.lock);
1043310433

10434+
/*
10435+
* Set the default power management level for runtime and system PM.
10436+
* Host controller drivers can override them in their
10437+
* 'ufs_hba_variant_ops::init' callback.
10438+
*
10439+
* Default power saving mode is to keep UFS link in Hibern8 state
10440+
* and UFS device in sleep state.
10441+
*/
10442+
hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10443+
UFS_SLEEP_PWR_MODE,
10444+
UIC_LINK_HIBERN8_STATE);
10445+
hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10446+
UFS_SLEEP_PWR_MODE,
10447+
UIC_LINK_HIBERN8_STATE);
10448+
1043410449
err = ufshcd_hba_init(hba);
1043510450
if (err)
1043610451
goto out_error;
@@ -10544,21 +10559,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1054410559
goto out_disable;
1054510560
}
1054610561

10547-
/*
10548-
* Set the default power management level for runtime and system PM if
10549-
* not set by the host controller drivers.
10550-
* Default power saving mode is to keep UFS link in Hibern8 state
10551-
* and UFS device in sleep state.
10552-
*/
10553-
if (!hba->rpm_lvl)
10554-
hba->rpm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10555-
UFS_SLEEP_PWR_MODE,
10556-
UIC_LINK_HIBERN8_STATE);
10557-
if (!hba->spm_lvl)
10558-
hba->spm_lvl = ufs_get_desired_pm_lvl_for_dev_link_state(
10559-
UFS_SLEEP_PWR_MODE,
10560-
UIC_LINK_HIBERN8_STATE);
10561-
1056210562
INIT_DELAYED_WORK(&hba->rpm_dev_flush_recheck_work, ufshcd_rpm_dev_flush_recheck_work);
1056310563
INIT_DELAYED_WORK(&hba->ufs_rtc_update_work, ufshcd_rtc_work);
1056410564

0 commit comments

Comments
 (0)