Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 7bac656

Browse files
Mani-Sadhasivammartinkpetersen
authored andcommitted
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: [email protected] # 6.3 Fixes: baf5dda ("scsi: ufs: ufs-qcom: Add support for reinitializing the UFS device") Reported-by: Ram Kumar Dwivedi <[email protected]> Tested-by: Amit Pundir <[email protected]> # on SM8550-HDK Reviewed-by: Bart Van Assche <[email protected]> Tested-by: Neil Armstrong <[email protected]> # on SM8550-QRD Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent f103396 commit 7bac656

File tree

4 files changed

+5
-17
lines changed

4 files changed

+5
-17
lines changed

drivers/ufs/core/ufshcd-priv.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,6 @@ static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba,
237237
hba->vops->config_scaling_param(hba, p, data);
238238
}
239239

240-
static inline void ufshcd_vops_reinit_notify(struct ufs_hba *hba)
241-
{
242-
if (hba->vops && hba->vops->reinit_notify)
243-
hba->vops->reinit_notify(hba);
244-
}
245-
246240
static inline int ufshcd_vops_mcq_config_resource(struct ufs_hba *hba)
247241
{
248242
if (hba->vops && hba->vops->mcq_config_resource)

drivers/ufs/core/ufshcd.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8858,7 +8858,6 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params)
88588858
ufshcd_device_reset(hba);
88598859
ufs_put_device_desc(hba);
88608860
ufshcd_hba_stop(hba);
8861-
ufshcd_vops_reinit_notify(hba);
88628861
ret = ufshcd_hba_enable(hba);
88638862
if (ret) {
88648863
dev_err(hba->dev, "Host controller enable failed\n");

drivers/ufs/host/ufs-qcom.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
368368
if (ret)
369369
return ret;
370370

371+
if (phy->power_count) {
372+
phy_power_off(phy);
373+
phy_exit(phy);
374+
}
375+
371376
/* phy initialization - calibrate the phy */
372377
ret = phy_init(phy);
373378
if (ret) {
@@ -1579,13 +1584,6 @@ static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
15791584
}
15801585
#endif
15811586

1582-
static void ufs_qcom_reinit_notify(struct ufs_hba *hba)
1583-
{
1584-
struct ufs_qcom_host *host = ufshcd_get_variant(hba);
1585-
1586-
phy_power_off(host->generic_phy);
1587-
}
1588-
15891587
/* Resources */
15901588
static const struct ufshcd_res_info ufs_res_info[RES_MAX] = {
15911589
{.name = "ufs_mem",},
@@ -1825,7 +1823,6 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
18251823
.device_reset = ufs_qcom_device_reset,
18261824
.config_scaling_param = ufs_qcom_config_scaling_param,
18271825
.program_key = ufs_qcom_ice_program_key,
1828-
.reinit_notify = ufs_qcom_reinit_notify,
18291826
.mcq_config_resource = ufs_qcom_mcq_config_resource,
18301827
.get_hba_mac = ufs_qcom_get_hba_mac,
18311828
.op_runtime_config = ufs_qcom_op_runtime_config,

include/ufs/ufshcd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ struct ufs_pwr_mode_info {
329329
* @program_key: program or evict an inline encryption key
330330
* @fill_crypto_prdt: initialize crypto-related fields in the PRDT
331331
* @event_notify: called to notify important events
332-
* @reinit_notify: called to notify reinit of UFSHCD during max gear switch
333332
* @mcq_config_resource: called to configure MCQ platform resources
334333
* @get_hba_mac: reports maximum number of outstanding commands supported by
335334
* the controller. Should be implemented for UFSHCI 4.0 or later
@@ -381,7 +380,6 @@ struct ufs_hba_variant_ops {
381380
void *prdt, unsigned int num_segments);
382381
void (*event_notify)(struct ufs_hba *hba,
383382
enum ufs_event_type evt, void *data);
384-
void (*reinit_notify)(struct ufs_hba *);
385383
int (*mcq_config_resource)(struct ufs_hba *hba);
386384
int (*get_hba_mac)(struct ufs_hba *hba);
387385
int (*op_runtime_config)(struct ufs_hba *hba);

0 commit comments

Comments
 (0)