[RAMEN9610-20555][COMMON] scsi: ufs: Add device reset when return error in query...
authorJaeHun Jung <jh0801.jung@samsung.com>
Fri, 11 Oct 2019 04:54:39 +0000 (13:54 +0900)
committerrobot <robot@samsung.com>
Tue, 15 Oct 2019 17:56:24 +0000 (02:56 +0900)
UFS device is not responsed when return -EAGAIN.
So, It need device reset for working.

================================================================================================
<3>[  715.766410,1] exynos-ufs 13520000.ufs: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0
<6>[  715.768915,1] exynos-ufs 13520000.ufs: UFS link established
<3>[  716.376936,3] exynos-ufs 13520000.ufs: ufshcd_query_flag: Sending flag query for idn 1 failed, err = -11
<6>[  716.578308,1] acpm_noti_mif_callback : req 1794000 KHz
<3>[  716.990135,3] exynos-ufs 13520000.ufs: ufshcd_query_flag: Sending flag query for idn 1 failed, err = -11
<6>[  717.434411,1] acpm_noti_mif_callback : req 419000 KHz
<3>[  717.603532,3] exynos-ufs 13520000.ufs: ufshcd_query_flag: Sending flag query for idn 1 failed, err = -11
<3>[  717.603555,3] exynos-ufs 13520000.ufs: ufshcd_query_flag_retry: query attribute, opcode 6, idn 1, failed with error -11 after 3 retires
<3>[  717.603567,3] exynos-ufs 13520000.ufs: ufshcd_complete_dev_init setting fDeviceInit flag failed with error -11
<3>[  717.603577,3] exynos-ufs 13520000.ufs: ufshcd_probe_hba failed with err -11, retrying:1
....
<3>[  748.447849,3] exynos-ufs 13520000.ufs: UPIU[2] - issue time 717847005 us
<3>[  748.447868,3] exynos-ufs 13520000.ufs: UPIU[2] - Transfer Request Descriptor phys@0x8fc042040
...
<3>[  748.753470,3] exynos-ufs 13520000.ufs: ufshcd_issue_tm_cmd: task management cmd 0x80 timed-out
<3>[  748.753553,3] exynos-ufs 13520000.ufs: ufshcd_abort: no response from device. tag = 2, err -110
<3>[  748.753594,3] exynos-ufs 13520000.ufs: ufshcd_abort: query task failed with err -110
<3>[  748.753636,3] exynos-ufs 13520000.ufs: ufshcd_abort: failed with err -110
<3>[  748.753718,3] exynos-ufs 13520000.ufs: ufshcd_abort: tag:1, cmd:0x2a, lba:0x00bb993c, sct:0x0001, retries 0
<3>[  748.753764,3] exynos-ufs 13520000.ufs: ufshcd_abort: Device abort task at tag 1
=================================================================================================

Change-Id: I73609250b8454d3b0dfd928cb1643992f2117672
Signed-off-by: JaeHun Jung <jh0801.jung@samsung.com>
drivers/scsi/ufs/ufshcd.c

index c2e1940e3f34b7fe609d1f4846a8dac37b7c2c93..704ffb0aef85e6c49c964efe8f90a2c1dc007334 100644 (file)
@@ -6730,15 +6730,16 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
        struct ufs_pa_layer_attr *pwr_info = &hba->max_pwr_info.info;
        struct ufs_vreg_info *info = &hba->vreg_info;
        int re_cnt = 0;
-       int ret, link_startup_fail = 0;
+       int ret, link_startup_fail = 0, device_reset = 0;
        ktime_t start = ktime_get();
        unsigned long flags;
 
 retry:
        /* For deivce power control when link startup fail. */
-       if (link_startup_fail) {
+       if (link_startup_fail || device_reset) {
                ufshcd_vreg_set_lpm(hba);
                ret = ufshcd_vreg_set_hpm(hba);
+               device_reset = 0;
 
                if (gpio_is_valid(info->ufs_power_gpio))
                        dev_info(hba->dev, "%s: UFS power pin: 0x%08x\n", __func__, gpio_get_value(info->ufs_power_gpio));
@@ -6844,9 +6845,15 @@ retry:
 
                /* clear any previous UFS device information */
                memset(&hba->dev_info, 0, sizeof(hba->dev_info));
-               if (!ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG,
-                               QUERY_FLAG_IDN_PWR_ON_WPE, &flag))
+               ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG,
+                               QUERY_FLAG_IDN_PWR_ON_WPE, &flag);
+               if (!ret)
                        hba->dev_info.f_power_on_wp_en = flag;
+               else {
+                       device_reset = 1;
+                       goto out;
+               }
+               device_reset = 0;
 
                if (!hba->is_init_prefetch)
                        ufshcd_init_icc_levels(hba);