return ufshcd_compose_devman_upiu(hba, lrbp);
 }
 
+/*
+ * Check with the block layer if the command is inflight
+ * @cmd: command to check.
+ *
+ * Returns true if command is inflight; false if not.
+ */
+bool ufshcd_cmd_inflight(struct scsi_cmnd *cmd)
+{
+       struct request *rq;
+
+       if (!cmd)
+               return false;
+
+       rq = scsi_cmd_to_rq(cmd);
+       if (!blk_mq_request_started(rq))
+               return false;
+
+       return true;
+}
+
 /*
  * Clear the pending command in the controller and wait until
  * the controller confirms that the command has been cleared.
  */
 static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag)
 {
-       unsigned long flags;
        u32 mask = 1U << task_tag;
+       unsigned long flags;
+       int err;
+
+       if (is_mcq_enabled(hba)) {
+               /*
+                * MCQ mode. Clean up the MCQ resources similar to
+                * what the ufshcd_utrl_clear() does for SDB mode.
+                */
+               err = ufshcd_mcq_sq_cleanup(hba, task_tag);
+               if (err) {
+                       dev_err(hba->dev, "%s: failed tag=%d. err=%d\n",
+                               __func__, task_tag, err);
+                       return err;
+               }
+               return 0;
+       }
 
        /* clear outstanding transaction before retry */
        spin_lock_irqsave(hba->host->host_lock, flags);
                         */
                        dev_err(hba->dev, "%s: cmd at tag %d not pending in the device.\n",
                                __func__, tag);
+                       if (is_mcq_enabled(hba)) {
+                               /* MCQ mode */
+                               if (ufshcd_cmd_inflight(lrbp->cmd)) {
+                                       /* sleep for max. 200us same delay as in SDB mode */
+                                       usleep_range(100, 200);
+                                       continue;
+                               }
+                               /* command completed already */
+                               dev_err(hba->dev, "%s: cmd at tag=%d is cleared.\n",
+                                       __func__, tag);
+                               goto out;
+                       }
+
+                       /* Single Doorbell Mode */
                        reg = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
                        if (reg & (1 << tag)) {
                                /* sleep for max. 200us to stabilize */
        WARN_ONCE(tag < 0, "Invalid tag %d\n", tag);
 
        ufshcd_hold(hba, false);
-       reg = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
-       /* If command is already aborted/completed, return FAILED. */
-       if (!(test_bit(tag, &hba->outstanding_reqs))) {
-               dev_err(hba->dev,
-                       "%s: cmd at tag %d already completed, outstanding=0x%lx, doorbell=0x%x\n",
-                       __func__, tag, hba->outstanding_reqs, reg);
-               goto release;
+
+       if (!is_mcq_enabled(hba)) {
+               reg = ufshcd_readl(hba, REG_UTP_TRANSFER_REQ_DOOR_BELL);
+               if (!test_bit(tag, &hba->outstanding_reqs)) {
+                       /* If command is already aborted/completed, return FAILED. */
+                       dev_err(hba->dev,
+                               "%s: cmd at tag %d already completed, outstanding=0x%lx, doorbell=0x%x\n",
+                               __func__, tag, hba->outstanding_reqs, reg);
+                       goto release;
+               }
        }
 
        /* Print Transfer Request of aborted task */
        }
        hba->req_abort_count++;
 
-       if (!(reg & (1 << tag))) {
+       if (!is_mcq_enabled(hba) && !(reg & (1 << tag))) {
+               /* only execute this code in single doorbell mode */
                dev_err(hba->dev,
                "%s: cmd was completed, but without a notifying intr, tag = %d",
                __func__, tag);
                goto release;
        }
 
+       if (is_mcq_enabled(hba))
+               goto release;
+
        /* Skip task abort in case previous aborts failed and report failure */
        if (lrbp->req_abort_skip) {
                dev_err(hba->dev, "%s: skipping abort\n", __func__);