Skip to contentSkip to conversation

update CQ entry and dump CQE in MCQ mode

PATCH Applied [email protected] 3 participants 5 messages Oct 16, 2025 – Oct 22, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover update CQ entry and dump CQE in MCQ mode

From: Peter Wang <[email protected]>

Update the CQ entry format for UFS 4.1 compatibility and add support for logging CQ entries in MCQ mode, enhancing debugging capabilities.

Changes since v1:
1. Add big-endian support for cq_entry.
2. Move CQE dumping outside of the dump function.

Peter Wang (2):
ufs: core: update CQ Entry to UFS 4.1 format
ufs: core: support dumping CQ entry in MCQ Mode

 drivers/ufs/core/ufshcd.c |  9 ++++++---
 include/ufs/ufshci.h      | 22 +++++++++++++++++++---
 2 files changed, 25 insertions(+), 6 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH v2 1/2 ufs: core: update CQ Entry to UFS 4.1 format

From: Peter Wang <[email protected]>

Update the completion queue (CQ) entry format with UFS 4.1 specifications. UFS 4.1 introduces new members in reserved record DW5. This patch also refines the DW4 with detailed members defined in UFS 4.0. Modify the code to incorporate these changes by updating the overall_status in the CQ entry structure.

---
 drivers/ufs/core/ufshcd.c |  4 ++--
 include/ufs/ufshci.h      | 22 +++++++++++++++++++---
 2 files changed, 21 insertions(+), 5 deletions(-)
drivers/ufs/core/ufshcd.c +2 -2
index ff7a3d60b11d..d779cc777a17 100644
@@ -858,7 +858,7 @@ static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp,
 				      struct cq_entry *cqe)
 {
 	if (cqe)
-		return le32_to_cpu(cqe->status) & MASK_OCS;
+		return cqe->overall_status & MASK_OCS;
 
 	return lrbp->utr_descriptor_ptr->header.ocs & MASK_OCS;
 }
@@ -5643,7 +5643,7 @@ void ufshcd_compl_one_cqe(struct ufs_hba *hba, int task_tag,
 		scsi_done(cmd);
 	} else {
 		if (cqe) {
-			ocs = le32_to_cpu(cqe->status) & MASK_OCS;
+			ocs = cqe->overall_status & MASK_OCS;
 			lrbp->utr_descriptor_ptr->header.ocs = ocs;
 		}
 		complete(&hba->dev_cmd.complete);
include/ufs/ufshci.h +19 -3
index 612500a7088f..fee8f899a569 100644
@@ -567,10 +567,26 @@ struct cq_entry {
 	__le16  prd_table_offset;
 
 	/* DW 4 */
-	__le32 status;
+	u8 overall_status;
+	u8 extended_error_code;
+	__le16 reserved_1;
 
-	/* DW 5-7 */
-	__le32 reserved[3];
+	/* DW 5 */
+	u8 task_tag;
+	u8 lun;
+#if defined(__BIG_ENDIAN)
+	u8 ext_iid:4;
+	u8 iid:4;
+#elif defined(__LITTLE_ENDIAN)
+	u8 iid:4;
+	u8 ext_iid:4;
+#else
+#error
+#endif
+	u8 reserved_2;
+
+	/* DW 6-7 */
+	__le32 reserved_3[2];
 };
 
 static_assert(sizeof(struct cq_entry) == 32);
Signature · 1 line
2.45.2
#2 lore raw

PATCH v2 2/2 ufs: core: support dumping CQ entry in MCQ Mode

In reply to [email protected]

From: Peter Wang <[email protected]>

Enhance the ufshcd_print_tr function to support dumping completion queue (CQ) entries in MCQ mode when an error occurs. This addition provides more detailed debugging information by including the CQ entry data in the error logs, aiding in the diagnosis of issues in MCQ mode.

---
 drivers/ufs/core/ufshcd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +4 -1
index d779cc777a17..c7d28d87ad85 100644
@@ -5535,8 +5535,11 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
 	} /* end of switch */
 
 	if ((host_byte(result) != DID_OK) &&
-	    (host_byte(result) != DID_REQUEUE) && !hba->silence_err_logs)
+	    (host_byte(result) != DID_REQUEUE) && !hba->silence_err_logs) {
+		if (cqe)
+			ufshcd_hex_dump("UPIU CQE: ", cqe, sizeof(struct cq_entry));
 		ufshcd_print_tr(hba, lrbp->task_tag, true);
+	}
 	return result;
 }
 
Signature · 1 line
2.45.2
#4 lore raw
In reply to [email protected]

Peter,

Quoted 2 lines

Update the CQ entry format for UFS 4.1 compatibility and add support for logging CQ entries in MCQ mode, enhancing debugging capabilities.

Applied to 6.19/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen