Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@meta.com>
To: <linux-nvme@lists.infradead.org>, <hch@lst.de>
Cc: Keith Busch <kbusch@kernel.org>
Subject: [PATCH] nvme: fix cns check
Date: Wed, 9 Oct 2024 14:40:35 -0700	[thread overview]
Message-ID: <20241009214035.3851406-1-kbusch@meta.com> (raw)

From: Keith Busch <kbusch@kernel.org>

The 1.1 spec defined two bits for the Identify CNS field, so such an
implementation wouldn't be expected to check the full byte for a
decoding it. Provide a different helper function to make these
decisions as the existing check only separates the single-bit from the
two-bit spec versions.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 drivers/nvme/host/core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 10eca7660ca7c..0f7ff5f417f17 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1412,6 +1412,11 @@ static bool nvme_ctrl_limited_cns(struct nvme_ctrl *ctrl)
 	return ctrl->vs < NVME_VS(1, 1, 0);
 }
 
+static bool nvme_ctrl_byte_cns(struct nvme_ctrl *ctrl)
+{
+	return ctrl->vs >= NVME_VS(1, 2, 0);
+}
+
 static int nvme_identify_ctrl(struct nvme_ctrl *dev, struct nvme_id_ctrl **id)
 {
 	struct nvme_command c = { };
@@ -3113,7 +3118,7 @@ static int nvme_init_non_mdts_limits(struct nvme_ctrl *ctrl)
 		ctrl->max_zeroes_sectors = 0;
 
 	if (ctrl->subsys->subtype != NVME_NQN_NVME ||
-	    nvme_ctrl_limited_cns(ctrl) ||
+	    !nvme_ctrl_byte_cns(ctrl) ||
 	    test_bit(NVME_CTRL_SKIP_ID_CNS_CS, &ctrl->flags))
 		return 0;
 
-- 
2.43.5



             reply	other threads:[~2024-10-09 21:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09 21:40 Keith Busch [this message]
2024-10-10  7:56 ` [PATCH] nvme: fix cns check Christoph Hellwig
2024-10-10 15:11   ` Keith Busch
2024-10-11  8:09     ` Christoph Hellwig
2024-10-15 14:36       ` Keith Busch
2024-10-15 15:16         ` Christoph Hellwig
2024-10-15 15:20           ` Keith Busch

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=20241009214035.3851406-1-kbusch@meta.com \
    --to=kbusch@meta.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    /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