From 5bb4e70924e3a7d588b4788e343c0c47c3268273 Mon Sep 17 00:00:00 2001 From: hgchu Date: Fri, 12 Jan 2018 09:54:59 +0900 Subject: [PATCH] scsi: ufs: fix error handling sequence Change-Id: Id7a538dba09e8efe5ea43b9d0fa329717c6e78ea Signed-off-by: hgchu --- drivers/scsi/ufs/ufshcd.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index fe59415b5ad1..14fba0757c98 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -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); -- 2.20.1