[PATCH] nvme-pci: ignore bogus CRTO according to NVME 2.0 spec
Felix Yan
felixonmars at archlinux.org
Fri Sep 8 08:54:42 PDT 2023
NVME 2.0 spec section 3.1.3 suggests that "Software should not rely on
0h being returned". Here we should safeguard timeout reads when CRTO is 0 and
fallback to the old NVME 1.4 compatible field.
Fixes 4TB SSD initialization issues with MAXIO MAP1602 controller, including
Lexar NM790, AIGO P7000Z, Fanxiang S790, Acer Predator GM7, etc.
----------
nvme nvme1: Device not ready; aborting initialisation, CSTS=0x0
----------
Signed-off-by: Felix Yan <felixonmars at archlinux.org>
---
drivers/nvme/host/core.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index f3a01b79148c..8ec28b1016ca 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2255,11 +2255,17 @@ int nvme_enable_ctrl(struct nvme_ctrl *ctrl)
return ret;
}
- if (ctrl->cap & NVME_CAP_CRMS_CRIMS) {
- ctrl->ctrl_config |= NVME_CC_CRIME;
- timeout = NVME_CRTO_CRIMT(crto);
+ if (crto == 0) {
+ timeout = NVME_CAP_TIMEOUT(ctrl->cap);
+ dev_warn(ctrl->device, "Ignoring bogus CRTO (0), falling back to NVME_CAP_TIMEOUT (%u)\n",
+ timeout);
} else {
- timeout = NVME_CRTO_CRWMT(crto);
+ if (ctrl->cap & NVME_CAP_CRMS_CRIMS) {
+ ctrl->ctrl_config |= NVME_CC_CRIME;
+ timeout = NVME_CRTO_CRIMT(crto);
+ } else {
+ timeout = NVME_CRTO_CRWMT(crto);
+ }
}
} else {
timeout = NVME_CAP_TIMEOUT(ctrl->cap);
--
2.42.0
More information about the Linux-nvme
mailing list