scsi: ufs: ufs-qcom: Allow the first init start with the maximum supported gear
authorCan Guo <quic_cang@quicinc.com>
Sat, 2 Dec 2023 12:36:10 +0000 (04:36 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 14 Dec 2023 03:37:21 +0000 (22:37 -0500)
commit743e1f596cccd371e7467fe585a1836773fbd922
treebd0aeec233521ffd486bdbdae0c43e993ece8565
parent55820a7f2cb9b9a4b603cc22dcf0ca5331f86d25
scsi: ufs: ufs-qcom: Allow the first init start with the maximum supported gear

During host driver init, the phy_gear is set to the minimum supported gear
(HS_G2). Then, during the first power mode change, the negotiated gear, say
HS-G4, is updated to the phy_gear variable so that in the second init the
updated phy_gear can be used to program the PHY.

But the current code only allows update the phy_gear to a higher value. If
one wants to start the first init with the maximum support gear, say HS-G4,
the phy_gear is not updated to HS-G3 if the device only supports HS-G3.

The original check added there is intend to make sure the phy_gear won't be
updated when gear is scaled down (during clock scaling). Update the check
so that one can start the first init with the maximum support gear without
breaking the original fix by checking the ufshcd_state, that is, allow
update to phy_gear only if power mode change is invoked from
ufshcd_probe_hba().

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Signed-off-by: Can Guo <quic_cang@quicinc.com>
Link: https://lore.kernel.org/r/1701520577-31163-5-git-send-email-quic_cang@quicinc.com
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/ufs/host/ufs-qcom.c