Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH] ufs: core: Fix the UFSHCD_QUIRK_MCQ_BROKEN_RTC implementation
@ 2025-10-27 15:44 Bart Van Assche
  2025-10-28 13:05 ` Peter Wang (王信友)
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2025-10-27 15:44 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley, Peter Wang,
	Manivannan Sadhasivam, Chenyuan Yang, ping.gao, Alok Tiwari,
	Po-Wen Kao, Stanley Jhu, Alim Akhtar

ufshcd_mcq_sq_cleanup() must return 0 if the command with tag 'task_tag'
is no longer in a submission queue. Check whether or not a command is
still pending by calling ufshcd_mcq_sqe_search().

Fixes: aa9d5d0015a8 ("scsi: ufs: core: Add host quirk UFSHCD_QUIRK_MCQ_BROKEN_RTC")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufs-mcq.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
index d04662b57cd1..cd47b7e438f4 100644
--- a/drivers/ufs/core/ufs-mcq.c
+++ b/drivers/ufs/core/ufs-mcq.c
@@ -36,6 +36,9 @@
 /* Max mcq register polling time in microseconds */
 #define MCQ_POLL_US 500000
 
+static bool ufshcd_mcq_sqe_search(struct ufs_hba *hba, struct ufs_hw_queue *hwq,
+				  int task_tag);
+
 static int rw_queue_count_set(const char *val, const struct kernel_param *kp)
 {
 	return param_set_uint_minmax(val, kp, UFS_MCQ_MIN_RW_QUEUES,
@@ -553,9 +556,6 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag)
 	u32 nexus, id, val;
 	int err;
 
-	if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_RTC)
-		return -ETIMEDOUT;
-
 	if (task_tag != hba->nutrs - UFSHCD_NUM_RESERVED) {
 		if (!cmd)
 			return -EINVAL;
@@ -566,6 +566,10 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag)
 		hwq = hba->dev_cmd_queue;
 	}
 
+	if (hba->quirks & UFSHCD_QUIRK_MCQ_BROKEN_RTC)
+		return ufshcd_mcq_sqe_search(hba, hwq, task_tag) ? -ETIMEDOUT :
+			0;
+
 	id = hwq->id;
 
 	guard(mutex)(&hwq->sq_mutex);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-30 16:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-27 15:44 [PATCH] ufs: core: Fix the UFSHCD_QUIRK_MCQ_BROKEN_RTC implementation Bart Van Assche
2025-10-28 13:05 ` Peter Wang (王信友)
2025-10-28 13:46   ` Bart Van Assche
2025-10-29  7:18     ` Peter Wang (王信友)
2025-10-29 15:50       ` Bart Van Assche
2025-10-30  6:38         ` Peter Wang (王信友)
2025-10-30 16:11           ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox