From: Keith Busch <kbusch@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@meta.com>, linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme: fix cns check
Date: Tue, 15 Oct 2024 08:36:15 -0600 [thread overview]
Message-ID: <Zw5930diGlfHACzF@kbusch-mbp> (raw)
In-Reply-To: <20241011080925.GE2749@lst.de>
On Fri, Oct 11, 2024 at 10:09:25AM +0200, Christoph Hellwig wrote:
> So yes, something like this is probably fine. But maybe we'll want to
> struture it in a way that is easier to read instead of having two
> helpers to decide which CNS value is supported. Maybe something
> like:
>
> static bool nvme_identify_cns_allowed(struct nvme_ctrl *ctrl, u8 cns)
> {
> switch (ctrl->vs) {
> default:
> /*
> * Starting with NVMe 1.2 the CNS field occupies a full
> * byte.
> */
> return true;
> case NVME_VS(1, 1, 0):
> /*
> * NVMe 1.1 expanded the CNS value to two bytes, which
> * means values larger than that could get truncated
> * and treated as an incorrect value.
> *
> * Qemu implemented 1.0 behavior for controllers claiming
> * 1.1 compliance, so they need to be quirked here.
> */
> if (!(ctrl->quirks & NVME_QUIRK_IDENTIFY_CNS))
> return !(cns & ~0x02);
> fallthrough;
> case NVME_VS(1, 0, 0):
> /*
> * NVMe 1.0 only used a single for the CNS value.
> * (That's where the name comes from:
> * Controller or Namespace Structure)
> */
> return !(cns & ~0x01);
> }
> }
I like this idea, and the spec makes it seem safe enough to assume the
tertiary version number is always 0 for 1.0 and 1.1 controllers. So
yeah, this looks good to me.
next prev parent reply other threads:[~2024-10-15 14:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 21:40 [PATCH] nvme: fix cns check Keith Busch
2024-10-10 7:56 ` Christoph Hellwig
2024-10-10 15:11 ` Keith Busch
2024-10-11 8:09 ` Christoph Hellwig
2024-10-15 14:36 ` Keith Busch [this message]
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=Zw5930diGlfHACzF@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@meta.com \
--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