scsi: ufs: fix error handling sequence
authorhgchu <hg.chu@samsung.com>
Fri, 12 Jan 2018 00:54:59 +0000 (09:54 +0900)
committerJaeHun Jung <jh0801.jung@samsung.com>
Tue, 8 May 2018 08:20:10 +0000 (17:20 +0900)
Change-Id: Id7a538dba09e8efe5ea43b9d0fa329717c6e78ea
Signed-off-by: hgchu <hg.chu@samsung.com>
drivers/scsi/ufs/ufshcd.c

index fe59415b5ad1eea5dbbc55e174695015bff64fb7..14fba0757c9821cfdcbab94b162d9e2336a857a7 100644 (file)
@@ -4672,7 +4672,7 @@ static void ufshcd_uic_cmd_compl(struct ufs_hba *hba, u32 intr_status)
  * @hba: per adapter instance
  * @completed_reqs: requests to complete
  */
-static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
+static void __ufshcd_transfer_req_compl(struct ufs_hba *hba, int reason,
                                        unsigned long completed_reqs)
 {
        struct ufshcd_lrb *lrbp;
@@ -4688,6 +4688,8 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
                        result = ufshcd_transfer_rsp_status(hba, lrbp);
                        scsi_dma_unmap(cmd);
                        cmd->result = result;
+                               if (reason)
+                                       set_host_byte(cmd, reason);
                        /* Mark completed command as NULL in LRB */
                        lrbp->cmd = NULL;
                        clear_bit_unlock(index, &hba->lrb_in_use);
@@ -5846,6 +5848,17 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba)
        unsigned long flags;
        int retries = MAX_HOST_RESET_RETRIES;
 
+       int tag;
+
+       for_each_set_bit(tag, &hba->outstanding_reqs, hba->nutrs)
+               ufshcd_clear_cmd(hba, tag);
+
+       spin_lock_irqsave(hba->host->host_lock, flags);
+       ufshcd_transfer_req_compl(hba, DID_RESET);
+       spin_unlock_irqrestore(hba->host->host_lock, flags);
+
+       ssleep(1);
+
        do {
                err = ufshcd_host_reset_and_restore(hba);
        } while (err && --retries);