UPSTREAM: 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: c02fe9e222d1 ("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>

Bug: 426423615
Change-Id: Ibd2dc45b2875e7165001b7b7a260beb7359ba6c8
(cherry picked from commit 663d0c19f3acc0d697f623d34b8eb3b438bf2bda)
Signed-off-by: Ziqi Chen <quic_ziqichen@quicinc.com>
This commit is contained in:
Ziqi Chen
2025-05-22 10:15:35 +08:00
committed by Sandeep Dhavale
parent 237708e9d3
commit f6ca783ba2

View File

@@ -1785,7 +1785,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:
@@ -1807,10 +1807,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);
}
/*