From 7f460c7d320e5cfb3ec2396a8a8573c9d69977c2 Mon Sep 17 00:00:00 2001 From: Randall Huang Date: Tue, 10 Mar 2020 14:15:06 +0800 Subject: [PATCH] scsi: ufs: re-probing hba when UFS initialization failed. We observed several failures when probing hba. Since there is no error recovery design, the device is not boot into Android. Log as shown below: pwr ctrl cmd 0x2 failed, host upmcrs:0x4 ... ufshcd_change_power_mode: power mode change failed 4 ufshcd_probe_hba: Failed setting power mode, err = 4 Because we do not support removable UFS card, we can introduce a retry design in async_scan(). The UFS can be initlized after re-probing hba. Log as shown below: ufshcd_async_scan failed. Err = 4. Retry 3 qcom_ice 1d90000.ufsice: QC ICE 3.1.79 device found @0xffffff800d9a0000 ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0 ufshcd_print_pwr_info:[RX, TX]: gear=[3, 3], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2 Bug: 151080047 Test: inject failure and boot to Android Change-Id: I76af5c89f91c72aecb1b5824fcada66dadbc5c4a Signed-off-by: Randall Huang Signed-off-by: Alexander Winkowski --- drivers/scsi/ufs/ufshcd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e259b8fc7315..abe9c0d970a1 100755 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -10375,13 +10375,19 @@ static int ufshcd_extcon_unregister(struct ufs_hba *hba) static void ufshcd_async_scan(void *data, async_cookie_t cookie) { struct ufs_hba *hba = (struct ufs_hba *)data; + int ret, retry = 3; /* * Don't allow clock gating and hibern8 enter for faster device * detection. */ ufshcd_hold_all(hba); - ufshcd_probe_hba(hba); + ret = ufshcd_probe_hba(hba); + while (ret && retry) { + pr_err("%s failed. Err = %d. Retry %d\n", __func__, ret, retry); + ret = ufshcd_host_reset_and_restore(hba); + retry--; + } ufshcd_release_all(hba); ufshcd_extcon_register(hba);