[PATCH v2] scsi: ufs: core: Process abort completed command in MCQ mode

From: SEO HOYOUNG
Date: Thu Nov 09 2023 - 20:33:55 EST


In MCQ mode, the case where OCS is updated to aborted is as follows
1. when abort processing is completed
2. When a duplicate command occurs

In case of 1 situation, cmd should be re-request.
So in the case of cmd whose abort processing is completed in MCQ mode,
the ufs driver needs to update to scsi with DID_REQUEUE.

v1->v2: change the method of determinging mcq and legacy mode.
check cqe value for checking mcq mode

Signed-off-by: SEO HOYOUNG <hy50.seo@xxxxxxxxxxx>
---
drivers/ufs/core/ufshcd.c | 8 +++++++-
include/ufs/ufshci.h | 1 +
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 68d7da02944f..9a730a794b66 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -5307,6 +5307,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
enum utp_ocs ocs;
u8 upiu_flags;
u32 resid;
+ u8 eec;

upiu_flags = lrbp->ucd_rsp_ptr->header.flags;
resid = be32_to_cpu(lrbp->ucd_rsp_ptr->sr.residual_transfer_count);
@@ -5371,7 +5372,12 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
}
break;
case OCS_ABORTED:
- result |= DID_ABORT << 16;
+ if (cqe) {
+ eec = le32_to_cpu(cqe->status) & MASK_EEC;
+ result |= eec ? (DID_ABORT << 16) : (DID_REQUEUE << 16);
+ } else {
+ result |= DID_ABORT << 16;
+ }
break;
case OCS_INVALID_COMMAND_STATUS:
result |= DID_REQUEUE << 16;
diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h
index d5accacae6bc..9aefc7e6d0fc 100644
--- a/include/ufs/ufshci.h
+++ b/include/ufs/ufshci.h
@@ -465,6 +465,7 @@ enum utp_ocs {

enum {
MASK_OCS = 0x0F,
+ MASK_EEC = 0xF0,
};

/* The maximum length of the data byte count field in the PRDT is 256KB */
--
2.26.0