[PATCH 2/6] nvme: add nvme_crd_msecs helper
Sagi Grimberg
sagi at grimberg.me
Sun Aug 23 01:48:58 PDT 2026
Hide the details of extracting the crd value. We'll need it from other
call-sites.
Signed-off-by: Sagi Grimberg <sagi at 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
More information about the Linux-nvme
mailing list