From: guzebing <guzebing1612@gmail.com>
To: kbusch@kernel.org, axboe@kernel.dk, hch@lst.de, sagi@grimberg.me
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Guzebing <guzebing@bytedance.com>
Subject: [PATCH v3] nvme: reduce firmware activation poll interval
Date: Wed, 15 Jul 2026 19:44:01 +0800 [thread overview]
Message-ID: <20260715114401.1084214-1-guzebing1612@gmail.com> (raw)
From: Guzebing <guzebing@bytedance.com>
nvme_fw_act_work() polls the controller processing-paused status every
100 ms while firmware activation is pending. Some devices can complete
online activation in only a few hundred milliseconds, so the fixed
100 ms interval can add up to 100 ms of latency before the driver
observes completion.
nvme_wait_ready() already uses a 1 to 2 ms delay between CSTS reads.
Use the same delay in nvme_fw_act_work() for consistency, and add a
common helper for both paths.
Signed-off-by: Guzebing <guzebing@bytedance.com>
---
Changes in v3:
- Add a common polling delay helper for nvme_fw_act_work() and
nvme_wait_ready().
Changes in v2:
- Drop the module parameter and use a fixed 1 to 2 ms poll interval.
v2: https://lore.kernel.org/linux-nvme/20260714092846.3381169-1-guzebing1612@gmail.com/
v1: https://lore.kernel.org/linux-nvme/20260627010610.47768-1-guzebing1612@gmail.com/
drivers/nvme/host/core.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 453c1f0b2dd09..499fe36792266 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2688,6 +2688,16 @@ const struct block_device_operations nvme_bdev_ops = {
.pr_ops = &nvme_pr_ops,
};
+/*
+ * Wait between CSTS reads in nvme_wait_ready() and nvme_fw_act_work().
+ * A 1 to 2 ms interval avoids excessive register reads while allowing
+ * changes in controller status to be detected promptly.
+ */
+static void nvme_busy_wait(void)
+{
+ usleep_range(1000, 2000);
+}
+
static int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
u32 timeout, const char *op)
{
@@ -2701,7 +2711,7 @@ static int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
if ((csts & mask) == val)
break;
- usleep_range(1000, 2000);
+ nvme_busy_wait();
if (fatal_signal_pending(current))
return -EINTR;
if (time_after(jiffies, timeout_jiffies)) {
@@ -4813,7 +4823,7 @@ static void nvme_fw_act_work(struct work_struct *work)
nvme_try_sched_reset(ctrl);
return;
}
- msleep(100);
+ nvme_busy_wait();
}
if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_CONNECTING) ||
next reply other threads:[~2026-07-15 11:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 11:44 guzebing [this message]
2026-07-15 22:49 ` Keith Busch
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=20260715114401.1084214-1-guzebing1612@gmail.com \
--to=guzebing1612@gmail.com \
--cc=axboe@kernel.dk \
--cc=guzebing@bytedance.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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
all inboxes | Powered by JetHome®