@@ -699,6 +699,12 @@ int ufshcd_mcq_abort(struct scsi_cmnd *cmd)
return FAILED;
}
+ /*
+ * In MCQ mode, set this variable so that the ISR posted by
+ * the host controller can be skipped.
+ */
+ lrbp->abort_initiated_by = UFS_SCSI_ABORT;
+
/*
* The command is not in the submission queue, and it is not
* in the completion queue either. Query the device to see if
@@ -5537,6 +5537,27 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,
ufshcd_update_monitor(hba, lrbp);
ufshcd_add_command_trace(hba, task_tag, UFS_CMD_COMP);
cmd->result = ufshcd_transfer_rsp_status(hba, lrbp, cqe);
+
+ /*
+ * Let the SCSI layer decide how to handle the ufshcd_abort
+ * situation, neither releasing nor notifying scsi_done in MCQ
+ * mode. SDB mode should release because outstanding_reqs is
+ * clear by ISR.
+ */
+ if (lrbp->abort_initiated_by == UFS_SCSI_ABORT) {
+ ocs = ufshcd_get_tr_ocs(lrbp, cqe);
+ if ((hba->mcq_enabled) && (ocs == OCS_ABORTED))
+ return;
+
+ if ((!hba->mcq_enabled) &&
+ ((ocs == OCS_INVALID_COMMAND_STATUS) ||
+ ((hba->quirks & UFSHCD_QUIRK_OCS_ABORTED) &&
+ (ocs == OCS_ABORTED)))) {
+ ufshcd_release_scsi_cmd(hba, lrbp);
+ return;
+ }
+ }
+
ufshcd_release_scsi_cmd(hba, lrbp);
/* Do not touch lrbp after scsi done */
scsi_done(cmd);
@@ -7673,6 +7694,12 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
goto release;
}
+ /*
+ * In SDB mode, set this variable so that the ISR posted by
+ * the host controller clear UTRLCLR can be skipped.
+ */
+ lrbp->abort_initiated_by = UFS_SCSI_ABORT;
+
err = ufshcd_try_to_abort_task(hba, tag);
if (err) {
dev_err(hba->dev, "%s: failed with err %d\n", __func__, err);
@@ -148,6 +148,7 @@ enum ufs_pm_level {
enum ufs_abort_by {
UFS_NO_ABORT,
UFS_ERR_HANDLER,
+ UFS_SCSI_ABORT
};
struct ufs_pm_lvl_states {