]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/6.8.6/scsi-ufs-qcom-avoid-re-init-quirk-when-gears-match.patch
Linux 6.8.6
[thirdparty/kernel/stable-queue.git] / releases / 6.8.6 / scsi-ufs-qcom-avoid-re-init-quirk-when-gears-match.patch
CommitLineData
335f7cc0
SL
1From 9b5da146eb938010b9efcbd24719e62a9e374e2e Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Tue, 23 Jan 2024 14:28:57 -0500
4Subject: scsi: ufs: qcom: Avoid re-init quirk when gears match
5
6From: Eric Chanudet <echanude@redhat.com>
7
8[ Upstream commit 10a39667a117daf0c1baaebcbe589715ee79178b ]
9
10On sa8775p-ride, probing the HBA will go through the
11UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH path although the power info is
12the same during the second init.
13
14The REINIT quirk only applies starting with controller v4. For these,
15ufs_qcom_get_hs_gear() reads the highest supported gear when setting the
16host_params. After the negotiation, if the host and device are on the same
17gear, it is the highest gear supported between the two. Skip REINIT to save
18some time.
19
20Signed-off-by: Eric Chanudet <echanude@redhat.com>
21Link: https://lore.kernel.org/r/20240123192854.1724905-4-echanude@redhat.com
22Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
23Tested-by: Andrew Halaney <ahalaney@redhat.com> # sa8775p-ride
24Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
25Signed-off-by: Sasha Levin <sashal@kernel.org>
26---
27 drivers/ufs/host/ufs-qcom.c | 13 +++++++++++--
28 1 file changed, 11 insertions(+), 2 deletions(-)
29
30diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
31index 3d43c7ac7a3f8..f532e2c004a25 100644
32--- a/drivers/ufs/host/ufs-qcom.c
33+++ b/drivers/ufs/host/ufs-qcom.c
34@@ -738,8 +738,17 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
35 * the second init can program the optimal PHY settings. This allows one to start
36 * the first init with either the minimum or the maximum support gear.
37 */
38- if (hba->ufshcd_state == UFSHCD_STATE_RESET)
39- host->phy_gear = dev_req_params->gear_tx;
40+ if (hba->ufshcd_state == UFSHCD_STATE_RESET) {
41+ /*
42+ * Skip REINIT if the negotiated gear matches with the
43+ * initial phy_gear. Otherwise, update the phy_gear to
44+ * program the optimal gear setting during REINIT.
45+ */
46+ if (host->phy_gear == dev_req_params->gear_tx)
47+ hba->quirks &= ~UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH;
48+ else
49+ host->phy_gear = dev_req_params->gear_tx;
50+ }
51
52 /* enable the device ref clock before changing to HS mode */
53 if (!ufshcd_is_hs_mode(&hba->pwr_info) &&
54--
552.43.0
56