All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] nvme: reduce firmware activation poll interval
@ 2026-07-15 11:44 guzebing
  2026-07-15 22:49 ` Keith Busch
  0 siblings, 1 reply; 2+ messages in thread
From: guzebing @ 2026-07-15 11:44 UTC (permalink / raw)
  To: kbusch, axboe, hch, sagi; +Cc: linux-nvme, linux-kernel, Guzebing

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) ||


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

* Re: [PATCH v3] nvme: reduce firmware activation poll interval
  2026-07-15 11:44 [PATCH v3] nvme: reduce firmware activation poll interval guzebing
@ 2026-07-15 22:49 ` Keith Busch
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2026-07-15 22:49 UTC (permalink / raw)
  To: guzebing; +Cc: axboe, hch, sagi, linux-nvme, linux-kernel, Guzebing

On Wed, Jul 15, 2026 at 07:44:01PM +0800, guzebing wrote:
> ---
> Changes in v3:
> - Add a common polling delay helper for nvme_fw_act_work() and
>   nvme_wait_ready().

I guess I was expecting the common helper to be the CSTS check and sleep
loop rather than just the sleep. I know the fw_act loop also checks the
ctrl_config in addition to CSTS, but that's fine to put in a common
function too.


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

end of thread, other threads:[~2026-07-15 22:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15 11:44 [PATCH v3] nvme: reduce firmware activation poll interval guzebing
2026-07-15 22:49 ` Keith Busch

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.