public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
	Peter Wang <peter.wang@mediatek.com>,
	vamshi gajjela <vamshigajjela@google.com>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Alok Tiwari <alok.a.tiwari@oracle.com>,
	"ping.gao" <ping.gao@samsung.com>,
	Chenyuan Yang <chenyuan0y@gmail.com>,
	Bean Huo <beanhuo@micron.com>, Can Guo <can.guo@oss.qualcomm.com>,
	"Bao D. Nguyen" <quic_nguyenb@quicinc.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Avri Altman <avri.altman@sandisk.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Stanley Jhu <chu.stanley@gmail.com>
Subject: [PATCH 1/3] ufs: core: Fix ufshcd_mcq_force_compl_one()
Date: Mon, 30 Mar 2026 11:33:03 -0700	[thread overview]
Message-ID: <20260330183311.1941942-2-bvanassche@acm.org> (raw)
In-Reply-To: <20260330183311.1941942-1-bvanassche@acm.org>

There are two issues with the code in ufshcd_mcq_compl_all_cqes_lock():
- The completion queue is processed without checking first whether it is
  empty.
- It is attempted to process hwq->max_entries while there can be at most
  hwq->max_entries - 1 entries on a completion queue.

Fix this by replacing the only ufshcd_mcq_compl_all_cqes_lock() call with
a call to ufshcd_mcq_poll_cqe_lock().

Fixes: ab248643d3d6 ("scsi: ufs: core: Add error handling for MCQ mode")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufs-mcq.c     | 18 ------------------
 drivers/ufs/core/ufshcd-priv.h |  2 --
 drivers/ufs/core/ufshcd.c      |  2 +-
 3 files changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
index 1b3062577945..8ccde4571859 100644
--- a/drivers/ufs/core/ufs-mcq.c
+++ b/drivers/ufs/core/ufs-mcq.c
@@ -322,24 +322,6 @@ static void ufshcd_mcq_process_cqe(struct ufs_hba *hba,
 	}
 }
 
-void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba,
-				    struct ufs_hw_queue *hwq)
-{
-	unsigned long flags;
-	u32 entries = hwq->max_entries;
-
-	spin_lock_irqsave(&hwq->cq_lock, flags);
-	while (entries > 0) {
-		ufshcd_mcq_process_cqe(hba, hwq);
-		ufshcd_mcq_inc_cq_head_slot(hwq);
-		entries--;
-	}
-
-	ufshcd_mcq_update_cq_tail_slot(hwq);
-	hwq->cq_head_slot = hwq->cq_tail_slot;
-	spin_unlock_irqrestore(&hwq->cq_lock, flags);
-}
-
 unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba,
 				       struct ufs_hw_queue *hwq)
 {
diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
index 0a72148cb053..96fcd935790b 100644
--- a/drivers/ufs/core/ufshcd-priv.h
+++ b/drivers/ufs/core/ufshcd-priv.h
@@ -71,8 +71,6 @@ int ufshcd_get_hba_mac(struct ufs_hba *hba);
 int ufshcd_mcq_memory_alloc(struct ufs_hba *hba);
 struct ufs_hw_queue *ufshcd_mcq_req_to_hwq(struct ufs_hba *hba,
 					   struct request *req);
-void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba,
-				    struct ufs_hw_queue *hwq);
 bool ufshcd_cmd_inflight(struct scsi_cmnd *cmd);
 int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag);
 int ufshcd_mcq_abort(struct scsi_cmnd *cmd);
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index cb81aa94d5c4..28b8e7291394 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -5855,7 +5855,7 @@ static bool ufshcd_mcq_force_compl_one(struct request *rq, void *priv)
 	if (blk_mq_is_reserved_rq(rq) || !hwq)
 		return true;
 
-	ufshcd_mcq_compl_all_cqes_lock(hba, hwq);
+	ufshcd_mcq_poll_cqe_lock(hba, hwq);
 
 	/*
 	 * For those cmds of which the cqes are not present in the cq, complete

  reply	other threads:[~2026-03-30 18:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 18:33 [PATCH 0/3] Reduce interrupt latency Bart Van Assche
2026-03-30 18:33 ` Bart Van Assche [this message]
2026-03-31  9:41   ` [PATCH 1/3] ufs: core: Fix ufshcd_mcq_force_compl_one() Peter Wang (王信友)
2026-03-31 19:29     ` Bart Van Assche
2026-04-01 13:10       ` Peter Wang (王信友)
2026-04-01 15:51         ` Bart Van Assche
2026-04-02  7:19           ` Peter Wang (王信友)
2026-03-30 18:33 ` [PATCH 2/3] ufs: core: Introduce ufshcd_mcq_poll_cqe_lock_n() Bart Van Assche
2026-03-31  9:43   ` Peter Wang (王信友)
2026-03-31 19:31     ` Bart Van Assche
2026-04-01 13:11       ` Peter Wang (王信友)
2026-04-01 15:51         ` Bart Van Assche
2026-04-02  7:20   ` Peter Wang (王信友)
2026-03-30 18:33 ` [PATCH 3/3] ufs: qcom: Reduce interrupt latency Bart Van Assche
2026-03-31  7:09   ` Manivannan Sadhasivam
2026-03-31 19:44     ` Bart Van Assche
2026-04-04  3:11       ` Manivannan Sadhasivam
2026-04-06 16:02         ` Bart Van Assche
2026-03-30 18:36 ` [PATCH 0/3] " Bart Van Assche
2026-03-31  2:01   ` Can Guo
2026-04-07  8:20     ` Xiaosen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260330183311.1941942-2-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=adrian.hunter@intel.com \
    --cc=alim.akhtar@samsung.com \
    --cc=alok.a.tiwari@oracle.com \
    --cc=avri.altman@sandisk.com \
    --cc=beanhuo@micron.com \
    --cc=can.guo@oss.qualcomm.com \
    --cc=chenyuan0y@gmail.com \
    --cc=chu.stanley@gmail.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=peter.wang@mediatek.com \
    --cc=ping.gao@samsung.com \
    --cc=quic_nguyenb@quicinc.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=vamshigajjela@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox