From: Nitin Rawat <quic_nitirawa@quicinc.com>
Date: Wed, 26 Jul 2023 13:41:40 +0000 (+0530)
Subject: scsi: ufs: ufs-qcom: Check host controller state
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=21f04fb4e8ca4a6a88c76b1ddf9ea94e6c118005;p=linux.git

scsi: ufs: ufs-qcom: Check host controller state

Commit 52a518019ca1 ("scsi: ufs: core: Fix missing clk change notification
on host reset") added UFS clock scaling notification to
ufshcd_host_reset_and_restore(). This invokes hibern8 enter and exit on
Qualcomm platform which fails because controller is in reset state.

Fix this by checking the Host controller state before sending hibern8
command.

__ufshcd_wl_resume()
ufshcd_reset_and_restore()
ufshcd_host_reset_and_restore()
ufshcd_scale_clks()
ufshcd_vops_clk_scale_notify()
ufs_qcom_clk_scale_notify()
ufshcd_uic_hibern8_enter()

Fixes: 52a518019ca1 ("scsi: ufs: core: Fix missing clk change notification on host reset")
Co-developed-by: Manish Pandey <quic_mapa@quicinc.com>
Signed-off-by: Manish Pandey <quic_mapa@quicinc.com>
Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
Link: https://lore.kernel.org/r/20230726134140.7180-3-quic_nitirawa@quicinc.com
Acked-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---

diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index e7164ce7336bd..e894ac548da0a 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -1382,6 +1382,10 @@ static int ufs_qcom_clk_scale_notify(struct ufs_hba *hba,
 	struct ufs_pa_layer_attr *dev_req_params = &host->dev_req_params;
 	int err = 0;
 
+	/* check the host controller state before sending hibern8 cmd */
+	if (!ufshcd_is_hba_active(hba))
+		return 0;
+
 	if (status == PRE_CHANGE) {
 		err = ufshcd_uic_hibern8_enter(hba);
 		if (err)