Manivannan Sadhasivam 7bac656875 scsi: ufs: qcom: Power off the PHY if it was already powered on in ufs_qcom_power_up_sequence()
PHY might already be powered on during ufs_qcom_power_up_sequence() in a
couple of cases:

 1. During UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH quirk

 2. Resuming from spm_lvl = 5 suspend

In those cases, it is necessary to call phy_power_off() and phy_exit() in
ufs_qcom_power_up_sequence() function to power off the PHY before calling
phy_init() and phy_power_on().

Case (1) is doing it via ufs_qcom_reinit_notify() callback, but case (2) is
not handled. So to satisfy both cases, call phy_power_off() and phy_exit()
if the phy_count is non-zero. And with this change, the reinit_notify()
callback is no longer needed.

This fixes the below UFS resume failure with spm_lvl = 5:

ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: ufshcd_host_reset_and_restore: Host init failed -5
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: ufshcd_host_reset_and_restore: Host init failed -5
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: ufshcd_host_reset_and_restore: Host init failed -5
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: ufshcd_host_reset_and_restore: Host init failed -5
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: Enabling the controller failed
ufshcd-qcom 1d84000.ufshc: ufshcd_host_reset_and_restore: Host init failed -5
ufs_device_wlun 0:0:0:49488: ufshcd_wl_resume failed: -5
ufs_device_wlun 0:0:0:49488: PM: dpm_run_callback(): scsi_bus_resume returns -5
ufs_device_wlun 0:0:0:49488: PM: failed to resume async: error -5

Cc: stable@vger.kernel.org # 6.3
Fixes: baf5ddac90dc ("scsi: ufs: ufs-qcom: Add support for reinitializing the UFS device")
Reported-by: Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>
Tested-by: Amit Pundir <amit.pundir@linaro.org> # on SM8550-HDK
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Link: https://lore.kernel.org/r/20241219-ufs-qcom-suspend-fix-v3-1-63c4b95a70b9@linaro.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2025-01-02 13:00:16 -05:00
..
2024-11-26 18:05:44 -08:00
2024-11-20 12:55:41 -08:00
2024-11-29 11:43:29 -08:00
2024-11-30 15:47:29 -08:00
2024-11-21 08:28:08 -08:00
2024-11-07 08:25:08 +01:00
2024-11-23 10:44:31 -08:00
2024-11-26 18:05:44 -08:00
2024-11-29 11:43:29 -08:00
2024-11-25 18:31:48 -08:00
2024-11-27 13:25:47 -08:00
2024-11-23 10:44:31 -08:00
2024-11-25 17:12:54 -08:00
2024-11-29 11:43:29 -08:00
2024-11-29 13:06:06 -08:00
2024-11-05 05:33:46 +01:00
2024-11-27 12:23:43 +01:00
2024-11-25 10:31:39 -08:00
2024-11-27 14:24:34 -08:00
2024-11-09 09:14:12 -08:00
2024-11-30 15:47:29 -08:00
2024-11-20 14:05:34 -08:00
2024-11-20 12:51:32 -08:00
2024-11-28 10:15:20 -08:00
2024-11-27 13:11:58 -08:00
2024-11-30 15:47:29 -08:00
2024-12-01 13:38:24 -08:00
2024-11-30 18:23:05 -08:00
2024-11-30 14:33:44 -08:00
2024-11-29 11:43:29 -08:00
2024-11-29 11:43:29 -08:00
2024-12-01 13:38:24 -08:00
2024-11-15 00:32:29 +11:00
2024-11-28 09:40:53 -08:00
2024-11-26 18:36:55 -08:00
2024-11-30 11:18:16 -08:00
2024-11-29 11:43:29 -08:00
2024-11-30 14:45:29 -08:00
2024-11-21 08:28:08 -08:00
2024-11-27 13:38:09 -08:00
2024-11-28 10:06:00 -08:00
2024-11-12 15:48:08 +01:00
2024-11-30 13:41:50 -08:00
2024-11-27 12:57:03 -08:00
2024-11-27 13:11:58 -08:00
2024-11-20 15:13:02 -08:00