From: Klaus Birkelund <its@irrelevant.dk>
To: Beata Michalska <beata.michalska@linaro.org>
Cc: Kevin Wolf <kwolf@redhat.com>, Keith Busch <kbusch@kernel.org>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH v2 12/20] nvme: bump supported specification version to 1.3
Date: Tue, 26 Nov 2019 09:40:10 +0100 [thread overview]
Message-ID: <20191126084010.GB225199@apples.localdomain> (raw)
In-Reply-To: <CADSWDztth45nn0iAR3B1KpfjbZGKgqif1eKt-+c=v+bWHWFGrQ@mail.gmail.com>
On Mon, Nov 25, 2019 at 12:13:15PM +0000, Beata Michalska wrote:
> On Mon, 18 Nov 2019 at 09:48, Klaus Birkelund <its@irrelevant.dk> wrote:
> >
> > On Tue, Nov 12, 2019 at 03:05:06PM +0000, Beata Michalska wrote:
> > > Hi Klaus,
> > >
> > > On Tue, 15 Oct 2019 at 11:52, Klaus Jensen <its@irrelevant.dk> wrote:
> > > >
> > > > +static uint16_t nvme_identify_ns_descr_list(NvmeCtrl *n, NvmeCmd *c)
> > > > +{
> > > > + static const int len = 4096;
> > > > +
> > > > + struct ns_descr {
> > > > + uint8_t nidt;
> > > > + uint8_t nidl;
> > > > + uint8_t rsvd2[2];
> > > > + uint8_t nid[16];
> > > > + };
> > > > +
> > > > + uint32_t nsid = le32_to_cpu(c->nsid);
> > > > + uint64_t prp1 = le64_to_cpu(c->prp1);
> > > > + uint64_t prp2 = le64_to_cpu(c->prp2);
> > > > +
> > > > + struct ns_descr *list;
> > > > + uint16_t ret;
> > > > +
> > > > + trace_nvme_identify_ns_descr_list(nsid);
> > > > +
> > > > + if (unlikely(nsid == 0 || nsid > n->num_namespaces)) {
> > > > + trace_nvme_err_invalid_ns(nsid, n->num_namespaces);
> > > > + return NVME_INVALID_NSID | NVME_DNR;
> > > > + }
> > > > +
> > > In theory this should abort the command for inactive NSIDs as well.
> > > But I guess this will come later on.
> > >
> >
> > At this point in the series, the device does not support multiple
> > namespaces anyway and num_namespaces is always 1. But this has also been
> > reported seperately in relation the patch adding multiple namespaces and
> > is fixed in v3.
> >
> > > > + list = g_malloc0(len);
> > > > + list->nidt = 0x3;
> > > > + list->nidl = 0x10;
> > > > + *(uint32_t *) &list->nid[12] = cpu_to_be32(nsid);
> > > > +
> > > Might be worth to add some comment here -> as per the NGUID/EUI64 format.
> > > Also those are not specified currently in the namespace identity data structure.
> > >
> >
> > I'll add a comment for why the Namespace UUID is set to this value here.
> > The NGUID/EUI64 fields are not set in the namespace identity data
> > structure as they are not required. See the descriptions of NGUID and
> > EUI64. Here for NGUID:
> >
> > "The controller shall specify a globally unique namespace identifier
> > in this field, the EUI64 field, or a Namespace UUID in the Namespace
> > Identification Descriptor..."
> >
> > Here, I chose to provide it in the Namespace Identification Descriptor
> > (by setting `list->nidt = 0x3`).
> >
> > > > + ret = nvme_dma_read_prp(n, (uint8_t *) list, len, prp1, prp2);
> > > > + g_free(list);
> > > > + return ret;
> > > > +}
> > > > +
> > > > static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd)
> > > > {
> > > > NvmeIdentify *c = (NvmeIdentify *)cmd;
> > > > @@ -934,7 +978,9 @@ static uint16_t nvme_identify(NvmeCtrl *n, NvmeCmd *cmd)
> > > > case 0x01:
> > > > return nvme_identify_ctrl(n, c);
> > > > case 0x02:
> > > > - return nvme_identify_nslist(n, c);
> > > > + return nvme_identify_ns_list(n, c);
> > > > + case 0x03:
> > > > + return nvme_identify_ns_descr_list(n, cmd);
> > > > default:
> > > > trace_nvme_err_invalid_identify_cns(le32_to_cpu(c->cns));
> > > > return NVME_INVALID_FIELD | NVME_DNR;
> > > > @@ -1101,6 +1147,14 @@ static uint16_t nvme_set_feature(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req)
> > > > blk_set_enable_write_cache(n->conf.blk, dw11 & 1);
> > > > break;
> > > > case NVME_NUMBER_OF_QUEUES:
> > > > + if (n->qs_created > 2) {
> > > > + return NVME_CMD_SEQ_ERROR | NVME_DNR;
> > > > + }
> > > > +
> > > I am not sure this is entirely correct as the spec says:
> > > "if any I/O Submission and/or Completion Queues (...)"
> > > so it might be enough to have a single queue created
> > > for this command to be valid.
> > > Also I think that the condition here is to make sure that the number
> > > of queues requested is being set once at init phase. Currently this will
> > > allow the setting to happen if there is no active queue -> so at any
> > > point of time (provided the condition mentioned). I might be wrong here
> > > but it seems that what we need is a single status saying any queue
> > > has been created prior to the Set Feature command at all
> > >
> >
> > Internally, the admin queue pair is counted in qs_created, which is the
> > reason for checking if is above 2. The admin queues are created when the
> > controller is enabled (mmio write to the EN register in CC).
> >
> > I'll add a comment about that - I see why it is unclear.
> >
>
> Ok, so indeed I have missed the fact that the admin queues are being tracked by
> 'qs_created'. Still, I might be wrong, but, it is enough to create I/O
> submission queue and delete it and the code will allow the command to proceed
> Whereas the spec says :
> "If a Set Features command is issued for this feature after creation of
> any I/O Submission and/or I/O Completion Queues, then the Set Features
> command shall fail with status code of Command Sequence Error"
>
> I might be misreading it though but it is not entirely clear to me whether
> this is : at least one queue create ... or created and in use.
>
> But I guess that is really minor.
>
Ohh! I see. Yes you are right. "This feature shall only be issued during
initialization prior to creation of any I/O Submission and/or Completion
Queues.".
To me it looks like the controller shall not allow the Set Feature
command again until after a controller reset. Then we also don't need
the counter, but just a flag to indicate if any I/O queue has been
configured.
I've fixed that up.
next prev parent reply other threads:[~2019-11-26 8:48 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-15 10:38 [PATCH v2 00/20] nvme: support NVMe v1.3d, SGLs and multiple namespaces Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 01/20] nvme: remove superfluous breaks Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 02/20] nvme: move device parameters to separate struct Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 03/20] nvme: add missing fields in the identify controller data structure Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 04/20] nvme: populate the mandatory subnqn and ver fields Klaus Jensen
2019-11-12 15:04 ` Beata Michalska
2019-11-13 6:16 ` Klaus Birkelund
2019-10-15 10:38 ` [PATCH v2 05/20] nvme: allow completion queues in the cmb Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 06/20] nvme: add support for the abort command Klaus Jensen
2019-11-12 15:04 ` Beata Michalska
2019-11-13 6:12 ` Klaus Birkelund
2019-11-15 11:56 ` Beata Michalska
2019-11-18 8:49 ` Klaus Birkelund
2019-10-15 10:38 ` [PATCH v2 07/20] nvme: refactor device realization Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 08/20] nvme: add support for the get log page command Klaus Jensen
2019-11-12 15:04 ` Beata Michalska
2019-11-19 20:01 ` Klaus Birkelund
2019-10-15 10:38 ` [PATCH v2 09/20] nvme: add support for the asynchronous event request command Klaus Jensen
2019-11-12 15:04 ` Beata Michalska
2019-11-19 19:51 ` Klaus Birkelund
2019-11-25 12:44 ` Beata Michalska
2019-10-15 10:38 ` [PATCH v2 10/20] nvme: add logging to error information log page Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 11/20] nvme: add missing mandatory features Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 12/20] nvme: bump supported specification version to 1.3 Klaus Jensen
2019-11-12 15:05 ` Beata Michalska
2019-11-18 9:48 ` Klaus Birkelund
2019-11-25 12:13 ` Beata Michalska
2019-11-26 8:40 ` Klaus Birkelund [this message]
2019-10-15 10:38 ` [PATCH v2 13/20] nvme: refactor prp mapping Klaus Jensen
2019-11-12 15:23 ` Beata Michalska
2019-11-20 9:39 ` Klaus Birkelund
2019-11-25 13:15 ` Beata Michalska
2019-10-15 10:38 ` [PATCH v2 14/20] nvme: allow multiple aios per command Klaus Jensen
2019-11-12 15:25 ` Beata Michalska
2019-11-21 11:57 ` Klaus Birkelund
2019-11-25 13:59 ` Beata Michalska
2019-10-15 10:38 ` [PATCH v2 15/20] nvme: add support for scatter gather lists Klaus Jensen
2019-11-12 15:25 ` Beata Michalska
2019-11-25 6:21 ` Klaus Birkelund
2019-11-25 14:10 ` Beata Michalska
2019-11-26 8:34 ` Klaus Birkelund
2019-10-15 10:38 ` [PATCH v2 16/20] nvme: support multiple namespaces Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 17/20] nvme: bump controller pci device id Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 18/20] nvme: remove redundant NvmeCmd pointer parameter Klaus Jensen
2019-10-15 10:38 ` [PATCH v2 19/20] nvme: make lba data size configurable Klaus Jensen
2019-11-12 15:24 ` Beata Michalska
2019-11-13 7:13 ` Klaus Birkelund
2019-10-15 10:39 ` [PATCH v2 20/20] nvme: handle dma errors Klaus Jensen
2019-10-15 17:19 ` [PATCH v2 00/20] nvme: support NVMe v1.3d, SGLs and multiple namespaces no-reply
2019-10-15 17:26 ` no-reply
2019-10-16 6:29 ` Fam Zheng
2019-10-28 6:09 ` Klaus Birkelund
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=20191126084010.GB225199@apples.localdomain \
--to=its@irrelevant.dk \
--cc=beata.michalska@linaro.org \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).