From: Felix Yan <felixonmars@archlinux.org>
To: kbusch@kernel.org, highenthalpyh@gmail.com,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: xuwd1@hotmail.com, Felix Yan <felixonmars@archlinux.org>
Subject: [PATCH] nvme-pci: ignore bogus CRTO according to NVME 2.0 spec
Date: Fri, 8 Sep 2023 18:54:42 +0300 [thread overview]
Message-ID: <20230908155442.31423-1-felixonmars@archlinux.org> (raw)
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@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
next reply other threads:[~2023-09-08 15:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 15:54 Felix Yan [this message]
2023-09-08 16:51 ` Keith Busch
2023-09-08 17:03 ` Felix Yan
2023-09-11 23:00 ` Keith Busch
2023-09-11 23:16 ` Keith Busch
2023-09-12 6:26 ` Felix Yan
2023-09-12 15:44 ` Keith Busch
2023-09-12 19:07 ` Felix Yan
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=20230908155442.31423-1-felixonmars@archlinux.org \
--to=felixonmars@archlinux.org \
--cc=highenthalpyh@gmail.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=xuwd1@hotmail.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
all inboxes | Powered by JetHome®