From: Sagi Grimberg <sagi@grimberg.me>
To: linux-nvme@lists.infradead.org, Christoph Hellwig <hch@lst.de>,
Keith Busch <kbusch@kernel.org>,
Chaitanya Kulkarni <kch@nvidia.com>
Cc: Daniel Wagner <dwagner@suse.de>,
Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
Hannes Reinecke <hare@suse.de>
Subject: [PATCH 2/6] nvme: add nvme_crd_msecs helper
Date: Sun, 23 Aug 2026 11:48:58 +0300 [thread overview]
Message-ID: <20260823084903.193188-3-sagi@grimberg.me> (raw)
In-Reply-To: <20260823084903.193188-1-sagi@grimberg.me>
Hide the details of extracting the crd value. We'll need it from other
call-sites.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
drivers/nvme/host/core.c | 8 +-------
drivers/nvme/host/nvme.h | 10 ++++++++++
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 453c1f0b2dd0..a49a86f96dd6 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -321,15 +321,9 @@ static blk_status_t nvme_error_status(u16 status)
static void nvme_retry_req(struct request *req)
{
- unsigned long delay = 0;
- u16 crd;
+ unsigned long delay = nvme_crd_msecs(nvme_req(req));
struct nvme_ns *ns = req->q->queuedata;
- /* The mask and shift result must be <= 3 */
- crd = (nvme_req(req)->status & NVME_STATUS_CRD) >> 11;
- if (crd)
- delay = nvme_req(req)->ctrl->crdt[crd - 1] * 100;
-
nvme_req(req)->retries++;
if (ns)
atomic_long_inc(&ns->retries);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 824651cc898d..6d8f6c541a61 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -921,6 +921,16 @@ static inline enum req_op nvme_req_op(struct nvme_command *cmd)
return nvme_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
}
+static inline unsigned long nvme_crd_msecs(struct nvme_request *req)
+{
+ /* The mask and shift result must be <= 3 */
+ u16 crd = (req->status & NVME_STATUS_CRD) >> 11;
+
+ if (!crd)
+ return 0;
+ return req->ctrl->crdt[crd - 1] * 100;
+}
+
#define NVME_QID_ANY -1
void nvme_init_request(struct request *req, struct nvme_command *cmd);
void nvme_cleanup_cmd(struct request *req);
--
2.43.0
next prev parent reply other threads:[~2026-08-23 8:49 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 8:48 [PATCH 0/6] Support per command retry timer Sagi Grimberg
2026-08-23 8:48 ` [PATCH 1/6] nvme-mpath: No need to protect req->bio with requeue_lock Sagi Grimberg
2026-08-24 11:31 ` Hannes Reinecke
2026-08-24 15:53 ` John Garry
2026-09-02 13:39 ` Christoph Hellwig
2026-08-23 8:48 ` Sagi Grimberg [this message]
2026-08-24 11:32 ` [PATCH 2/6] nvme: add nvme_crd_msecs helper Hannes Reinecke
2026-09-02 13:40 ` Christoph Hellwig
2026-09-06 0:07 ` Sagi Grimberg
2026-08-23 8:48 ` [PATCH 3/6] nvme: add per request retry timer Sagi Grimberg
2026-08-24 13:25 ` Hannes Reinecke
2026-09-02 13:41 ` Christoph Hellwig
2026-09-06 0:09 ` Sagi Grimberg
2026-09-11 22:53 ` Sagi Grimberg
2026-08-23 8:49 ` [PATCH 4/6] nvme-mpath: support controller crd when failing over request Sagi Grimberg
2026-08-24 13:45 ` Hannes Reinecke
2026-08-24 14:23 ` Sagi Grimberg
2026-09-02 13:43 ` Christoph Hellwig
2026-09-06 0:15 ` Sagi Grimberg
2026-08-23 8:49 ` [PATCH 5/6] nvmet: Add support for configurable crdt (command retry delay) attributes Sagi Grimberg
2026-09-02 13:44 ` Christoph Hellwig
2026-09-06 0:20 ` Sagi Grimberg
2026-08-23 8:49 ` [PATCH 6/6] nvme/fault-injection: Support for error injection with custom crd Sagi Grimberg
2026-08-23 8:49 ` [PATCH 7/6 RFC] nvme: test per-command retry delay Sagi Grimberg
2026-08-30 8:23 ` Shin'ichiro Kawasaki
2026-08-30 20:55 ` Sagi Grimberg
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=20260823084903.193188-3-sagi@grimberg.me \
--to=sagi@grimberg.me \
--cc=dwagner@suse.de \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-nvme@lists.infradead.org \
--cc=shinichiro.kawasaki@wdc.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