/* Link Hibernation delay, msecs */
#define LINK_H8_DELAY 20
+/* UFS link setup retries */
+#define UFS_LINK_SETUP_RETRIES 5
#define ufshcd_toggle_vreg(_dev, _vreg, _on) \
({ \
} else {
ret = __ufshcd_hba_enable(hba);
}
+ if (ret)
+ dev_err(hba->dev, "Host controller enable failed\n");
+
return ret;
}
/* scale up clocks to max frequency before full reinitialization */
ufshcd_scale_clks(hba, true);
- err = ufshcd_hba_enable(hba);
- if (err)
- goto out;
-
/* Establish the link again and restore the device */
err = ufshcd_probe_hba(hba);
- if (!err && (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL))
- err = -EIO;
-out:
- if (err)
- dev_err(hba->dev, "%s: Host init failed %d\n", __func__, err);
+ if (!err && (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL)) {
+ dev_err(hba->dev, "%s: failed\n", __func__);
+ err = -EIO;
+ }
return err;
}
ktime_t start = ktime_get();
retry:
+ ret = ufshcd_hba_enable(hba);
+ if (ret)
+ goto out;
+
ret = ufshcd_link_startup(hba);
if (ret)
goto out;
if (!hba->is_init_prefetch)
ufshcd_init_icc_levels(hba);
+ scsi_scan_host(hba->host);
+
/* Add required well known logical units to scsi mid layer */
- if (ufshcd_scsi_add_wlus(hba))
- goto out;
+ ret = ufshcd_scsi_add_wlus(hba);
+ if (ret) {
+ dev_warn(hba->dev, "%s failed to add w-lus %d\n",
+ __func__, ret);
+ ret = 0;
+ }
/* Initialize devfreq after UFS device is detected */
if (ufshcd_is_clkscaling_supported(hba)) {
hba->clk_scaling.is_allowed = true;
}
- scsi_scan_host(hba->host);
pm_runtime_put_sync(hba->dev);
}
hba->is_init_prefetch = true;
out:
- if (ret) {
+ if (ret && re_cnt++ < UFS_LINK_SETUP_RETRIES) {
+ dev_err(hba->dev, "%s failed with err %d, retrying:%d\n",
+ __func__, ret, re_cnt);
goto retry;
}
+ }
/*
* If we failed to initialize the device or the device is not
* present, turn off the power/clocks etc.
goto exit_gating;
}
- /* Host controller enable */
- err = ufshcd_hba_enable(hba);
- if (err) {
- dev_err(hba->dev, "Host controller enable failed\n");
- ufshcd_print_host_regs(hba);
- ufshcd_print_host_state(hba);
- goto out_remove_scsi_host;
- }
-
if (ufshcd_is_clkscaling_supported(hba)) {
char wq_name[sizeof("ufs_clkscaling_00")];