* @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;
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);
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);