nvme: reduce firmware activation poll interval
PATCH v3 1/1 nvme: reduce firmware activation poll interval
From: Guzebing <[email protected]>
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.
---
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/[email protected]/
v1: https://lore.kernel.org/linux-nvme/[email protected]/
drivers/nvme/host/core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +12 -2
@@ -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) ||
Keith Busch
maintainerQuoted 4 lines · guzebing
---
Changes in v3:
- Add a common polling delay helper fornvme_fw_act_work()andnvme_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.