scsi: ufs: qcom: Check gear against max gear in vop freq_to_gear()

The vop freq_to_gear() may return a gear greater than the negotiated max
gear. Return the negotiated max gear if the mapped gear is greater.

Fixes: c02fe9e222 ("scsi: ufs: qcom: Implement the freq_to_gear_speed() vop")
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
Link: https://lore.kernel.org/r/20250522021537.999107-2-quic_ziqichen@quicinc.com
Reported-by: Neil Armstrong <neil.armstrong@linaro.org>
Closes: https://lore.kernel.org/all/c7f2476a-943a-4d73-ad80-802c91e5f880@linaro.org/
Tested-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Tested-by: Loïc Minier <loic.minier@oss.qualcomm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
pull/1260/head
Ziqi Chen 2025-05-22 10:15:35 +08:00 committed by Martin K. Petersen
parent 0ae992637c
commit 663d0c19f3
1 changed files with 3 additions and 3 deletions

View File

@ -2083,7 +2083,7 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)
static u32 ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq)
{
u32 gear = 0;
u32 gear = UFS_HS_DONT_CHANGE;
switch (freq) {
case 403000000:
@ -2105,10 +2105,10 @@ static u32 ufs_qcom_freq_to_gear_speed(struct ufs_hba *hba, unsigned long freq)
break;
default:
dev_err(hba->dev, "%s: Unsupported clock freq : %lu\n", __func__, freq);
break;
return UFS_HS_DONT_CHANGE;
}
return gear;
return min_t(u32, gear, hba->max_pwr_info.info.gear_rx);
}
/*