Skip to content

Commit fc88ca1

Browse files
Mani-Sadhasivammartinkpetersen
authored andcommitted
scsi: ufs: qcom: Update PHY settings only when scaling to higher gears
The "hs_gear" variable is used to program the PHY settings (submode) during ufs_qcom_power_up_sequence(). Currently, it is being updated every time the agreed gear changes. Due to this, if the gear got downscaled before suspend (runtime/system), then while resuming, the PHY settings for the lower gear will be applied first and later when scaling to max gear with REINIT, the PHY settings for the max gear will be applied. This adds a latency while resuming and also really not needed as the PHY gear settings are backwards compatible i.e., we can continue using the PHY settings for max gear with lower gear speed. So let's update the "hs_gear" variable _only_ when the agreed gear is greater than the current one. This guarantees that the PHY settings will be changed only during probe time and fatal error condition. Due to this, UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH can now be skipped when the PM operation is in progress. Cc: [email protected] Fixes: 96a7141 ("scsi: ufs: core: Add support for reinitializing the UFS device") Reported-by: Can Guo <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Can Guo <[email protected]> Tested-by: Can Guo <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent fd915c6 commit fc88ca1

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8722,7 +8722,8 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
87228722
if (ret)
87238723
goto out;
87248724

8725-
if (hba->quirks & UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH) {
8725+
if (!hba->pm_op_in_progress &&
8726+
(hba->quirks & UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH)) {
87268727
/* Reset the device and controller before doing reinit */
87278728
ufshcd_device_reset(hba);
87288729
ufshcd_hba_stop(hba);

drivers/ufs/host/ufs-qcom.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,13 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
923923
return ret;
924924
}
925925

926-
/* Use the agreed gear */
927-
host->hs_gear = dev_req_params->gear_tx;
926+
/*
927+
* Update hs_gear only when the gears are scaled to a higher value. This is because,
928+
* the PHY gear settings are backwards compatible and we only need to change the PHY
929+
* settings while scaling to higher gears.
930+
*/
931+
if (dev_req_params->gear_tx > host->hs_gear)
932+
host->hs_gear = dev_req_params->gear_tx;
928933

929934
/* enable the device ref clock before changing to HS mode */
930935
if (!ufshcd_is_hs_mode(&hba->pwr_info) &&

0 commit comments

Comments
 (0)