git: bd1bd0ba5540 - main - nvme: honor CRTO for the controller ready timeout
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 11 Nov 2026 20:54:34 UTC
The branch main has been updated by seuros:
URL: https://cgit.FreeBSD.org/src/commit/?id=bd1bd0ba5540f773a21c6fc6c8949bd198e7ed9a
commit bd1bd0ba5540f773a21c6fc6c8949bd198e7ed9a
Author: Abdelkader Boudih <seuros@FreeBSD.org>
AuthorDate: 2026-11-11 20:54:01 +0000
Commit: Abdelkader Boudih <seuros@FreeBSD.org>
CommitDate: 2026-11-11 20:54:01 +0000
nvme: honor CRTO for the controller ready timeout
CAP.TO is a 8b field and saturate at 127.5 seconds; a controller
that needs longer reports the real worst case in CRTO.CRWMT.
Waiting only CAP.TO can reset a controller that is still within its declared
recovery time after e.g. an abrupt shutdown.
Taking the larger of CRTO.CRWMT and CAP.TO when CAP.CRWMS show CRTO support.
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D59631
---
sys/dev/nvme/nvme.h | 10 ++++++++++
sys/dev/nvme/nvme_ctrlr.c | 8 ++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index ee39a101f48c..48bd5a10a93e 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -195,6 +195,16 @@ struct sbuf;
#define NVME_AQA_REG_ACQS_SHIFT (16)
#define NVME_AQA_REG_ACQS_MASK (0xFFF)
+#define NVME_CRTO_REG_CRWMT_SHIFT (0)
+#define NVME_CRTO_REG_CRWMT_MASK (0xFFFF)
+#define NVME_CRTO_REG_CRIMT_SHIFT (16)
+#define NVME_CRTO_REG_CRIMT_MASK (0xFFFF)
+
+#define NVME_CRTO_CRWMT(x) \
+ NVMEV(NVME_CRTO_REG_CRWMT, x)
+#define NVME_CRTO_CRIMT(x) \
+ NVMEV(NVME_CRTO_REG_CRIMT, x)
+
#define NVME_PMRCAP_REG_RDS_SHIFT (3)
#define NVME_PMRCAP_REG_RDS_MASK (0x1)
#define NVME_PMRCAP_REG_WDS_SHIFT (4)
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 11c09efc684f..b70ae561c833 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1828,7 +1828,7 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev)
struct make_dev_args md_args;
uint32_t cap_lo;
uint32_t cap_hi;
- uint32_t to, vs, pmrcap;
+ uint32_t crto, to, vs, pmrcap;
int status, timeout_period;
ctrlr->dev = dev;
@@ -1891,7 +1891,11 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev)
ctrlr->page_size = 1 << (NVME_MPS_SHIFT + ctrlr->mps);
/* Get ready timeout value from controller, in units of 500ms. */
- to = NVME_CAP_LO_TO(cap_lo) + 1;
+ if (NVME_CAP_HI_CRWMS(cap_hi)) {
+ crto = nvme_mmio_read_4(ctrlr, crto);
+ to = max(NVME_CRTO_CRWMT(crto), NVME_CAP_LO_TO(cap_lo)) + 1;
+ } else
+ to = NVME_CAP_LO_TO(cap_lo) + 1;
ctrlr->ready_timeout_in_ms = to * 500;
timeout_period = NVME_ADMIN_TIMEOUT_PERIOD;