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>,
Peter Wang <peter.wang@mediatek.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
vamshi gajjela <vamshigajjela@google.com>,
Alok Tiwari <alok.a.tiwari@oracle.com>,
Chenyuan Yang <chenyuan0y@gmail.com>,
"ping.gao" <ping.gao@samsung.com>
Subject: [PATCH v2 1/2] ufs: core: Introduce ufshcd_mcq_poll_n_cqe_lock()
Date: Thu, 2 Apr 2026 10:14:01 -0700 [thread overview]
Message-ID: <20260402171404.3008494-2-bvanassche@acm.org> (raw)
In-Reply-To: <20260402171404.3008494-1-bvanassche@acm.org>
Introduce a new function for processing completions that accepts an
upper limit for the number of completions to poll. Tell
ufshcd_mcq_poll_cqe_lock() to poll at most hwq->max_entries. This is
sufficient to poll all pending completions since there are never more
than hwq->max_entries - 1 completions on a completion queue. This patch
prepares for reducing the interrupt latency.
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufs-mcq.c | 14 +++++++++++---
include/ufs/ufshcd.h | 3 +++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
index 1b3062577945..e6081b97ed74 100644
--- a/drivers/ufs/core/ufs-mcq.c
+++ b/drivers/ufs/core/ufs-mcq.c
@@ -340,15 +340,16 @@ void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba,
spin_unlock_irqrestore(&hwq->cq_lock, flags);
}
-unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba,
- struct ufs_hw_queue *hwq)
+unsigned long ufshcd_mcq_poll_n_cqe_lock(struct ufs_hba *hba,
+ struct ufs_hw_queue *hwq,
+ unsigned int max_compl)
{
unsigned long completed_reqs = 0;
unsigned long flags;
spin_lock_irqsave(&hwq->cq_lock, flags);
ufshcd_mcq_update_cq_tail_slot(hwq);
- while (!ufshcd_mcq_is_cq_empty(hwq)) {
+ while (!ufshcd_mcq_is_cq_empty(hwq) && completed_reqs < max_compl) {
ufshcd_mcq_process_cqe(hba, hwq);
ufshcd_mcq_inc_cq_head_slot(hwq);
completed_reqs++;
@@ -360,6 +361,13 @@ unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba,
return completed_reqs;
}
+EXPORT_SYMBOL_GPL(ufshcd_mcq_poll_n_cqe_lock);
+
+unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba,
+ struct ufs_hw_queue *hwq)
+{
+ return ufshcd_mcq_poll_n_cqe_lock(hba, hwq, hwq->max_entries);
+}
EXPORT_SYMBOL_GPL(ufshcd_mcq_poll_cqe_lock);
void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba)
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index cfbc75d8df83..aa5f9b31ea86 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -1475,6 +1475,9 @@ void ufshcd_mcq_config_mac(struct ufs_hba *hba, u32 max_active_cmds);
unsigned int ufshcd_mcq_queue_cfg_addr(struct ufs_hba *hba);
u32 ufshcd_mcq_read_cqis(struct ufs_hba *hba, int i);
void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i);
+unsigned long ufshcd_mcq_poll_n_cqe_lock(struct ufs_hba *hba,
+ struct ufs_hw_queue *hwq,
+ unsigned int max_compl);
unsigned long ufshcd_mcq_poll_cqe_lock(struct ufs_hba *hba,
struct ufs_hw_queue *hwq);
void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba);
next prev parent reply other threads:[~2026-04-02 17:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 17:14 [PATCH v2 0/2] ufs-qcom: Reduce interrupt latency Bart Van Assche
2026-04-02 17:14 ` Bart Van Assche [this message]
2026-05-13 6:50 ` [PATCH v2 1/2] ufs: core: Introduce ufshcd_mcq_poll_n_cqe_lock() Peter Wang (王信友)
2026-05-13 19:26 ` Bart Van Assche
2026-05-14 7:34 ` Peter Wang (王信友)
2026-05-14 16:20 ` Bart Van Assche
2026-04-02 17:14 ` [PATCH v2 2/2] ufs: qcom: Reduce interrupt latency Bart Van Assche
2026-04-30 16:23 ` Martin K. Petersen
2026-04-30 16:21 ` [PATCH v2 0/2] ufs-qcom: " Martin K. Petersen
2026-04-30 17:21 ` Bart Van Assche
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=20260402171404.3008494-2-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alok.a.tiwari@oracle.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chenyuan0y@gmail.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.com \
--cc=peter.wang@mediatek.com \
--cc=ping.gao@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.