qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: Keith Busch <kbusch@kernel.org>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	"Niklas Cassel" <Niklas.Cassel@wdc.com>,
	qemu-block@nongnu.org, "Klaus Jensen" <k.jensen@samsung.com>,
	qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH 4/9] hw/block/nvme: validate command set selected
Date: Thu, 1 Oct 2020 06:14:34 +0200	[thread overview]
Message-ID: <20201001041434.GD681387@apples.localdomain> (raw)
In-Reply-To: <20200930220414.562527-5-kbusch@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 3304 bytes --]

On Sep 30 15:04, Keith Busch wrote:
> Fail to start the controller if the user requests a command set that the
> controller does not support.
> 
> Signed-off-by: Keith Busch <kbusch@kernel.org>

Reviewed-by: Klaus Jensen <k.jensen@samsung.com>

> ---
>  hw/block/nvme.c       | 6 +++++-
>  hw/block/trace-events | 1 +
>  include/block/nvme.h  | 4 ++++
>  3 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 41389b2b09..6c582e6874 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -2049,6 +2049,10 @@ static int nvme_start_ctrl(NvmeCtrl *n)
>          trace_pci_nvme_err_startfail_acq_misaligned(n->bar.acq);
>          return -1;
>      }
> +    if (unlikely(!(NVME_CAP_CSS(n->bar.cap) & (1 << NVME_CC_CSS(n->bar.cc))))) {
> +        trace_pci_nvme_err_startfail_css(NVME_CC_CSS(n->bar.cc));
> +        return -1;
> +    }
>      if (unlikely(NVME_CC_MPS(n->bar.cc) <
>                   NVME_CAP_MPSMIN(n->bar.cap))) {
>          trace_pci_nvme_err_startfail_page_too_small(
> @@ -2750,7 +2754,7 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
>      NVME_CAP_SET_MQES(n->bar.cap, 0x7ff);
>      NVME_CAP_SET_CQR(n->bar.cap, 1);
>      NVME_CAP_SET_TO(n->bar.cap, 0xf);
> -    NVME_CAP_SET_CSS(n->bar.cap, 1);
> +    NVME_CAP_SET_CSS(n->bar.cap, NVME_CAP_CSS_NVM);
>      NVME_CAP_SET_MPSMAX(n->bar.cap, 4);
>  
>      n->bar.vs = NVME_SPEC_VER;
> diff --git a/hw/block/trace-events b/hw/block/trace-events
> index 446cca08e9..7720e1b4d9 100644
> --- a/hw/block/trace-events
> +++ b/hw/block/trace-events
> @@ -133,6 +133,7 @@ pci_nvme_err_startfail_cqent_too_small(uint8_t log2ps, uint8_t maxlog2ps) "nvme_
>  pci_nvme_err_startfail_cqent_too_large(uint8_t log2ps, uint8_t maxlog2ps) "nvme_start_ctrl failed because the completion queue entry size is too large: log2size=%u, max=%u"
>  pci_nvme_err_startfail_sqent_too_small(uint8_t log2ps, uint8_t maxlog2ps) "nvme_start_ctrl failed because the submission queue entry size is too small: log2size=%u, min=%u"
>  pci_nvme_err_startfail_sqent_too_large(uint8_t log2ps, uint8_t maxlog2ps) "nvme_start_ctrl failed because the submission queue entry size is too large: log2size=%u, max=%u"
> +pci_nvme_err_startfail_css(uint8_t css) "nvme_start_ctrl failed because invalid command set selected:%u"
>  pci_nvme_err_startfail_asqent_sz_zero(void) "nvme_start_ctrl failed because the admin submission queue size is zero"
>  pci_nvme_err_startfail_acqent_sz_zero(void) "nvme_start_ctrl failed because the admin completion queue size is zero"
>  pci_nvme_err_startfail(void) "setting controller enable bit failed"
> diff --git a/include/block/nvme.h b/include/block/nvme.h
> index 868cf53f0b..bc20a2ba5e 100644
> --- a/include/block/nvme.h
> +++ b/include/block/nvme.h
> @@ -82,6 +82,10 @@ enum NvmeCapMask {
>  #define NVME_CAP_SET_PMRS(cap, val) (cap |= (uint64_t)(val & CAP_PMR_MASK)\
>                                                              << CAP_PMR_SHIFT)
>  
> +enum NvmeCapCss {
> +    NVME_CAP_CSS_NVM = 1 << 0,
> +};
> +
>  enum NvmeCcShift {
>      CC_EN_SHIFT     = 0,
>      CC_CSS_SHIFT    = 4,
> -- 
> 2.24.1
> 
> 

-- 
One of us - No more doubt, silence or taboo about mental illness.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-10-01  4:18 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-30 22:04 [PATCH 0/9] nvme qemu cleanups and fixes Keith Busch
2020-09-30 22:04 ` [PATCH 1/9] hw/block/nvme: remove pointless rw indirection Keith Busch
2020-10-01  4:05   ` Klaus Jensen
2020-10-01  8:48     ` Klaus Jensen
2020-10-01 15:24       ` Keith Busch
2020-10-01 18:34     ` Klaus Jensen
2020-10-06  1:49   ` Dmitry Fomichev
2020-09-30 22:04 ` [PATCH 2/9] hw/block/nvme: fix log page offset check Keith Busch
2020-09-30 23:18   ` Dmitry Fomichev
2020-10-01  4:05   ` Klaus Jensen
2020-10-01 10:11   ` Philippe Mathieu-Daudé
2020-09-30 22:04 ` [PATCH 3/9] hw/block/nvme: support per-namespace smart log Keith Busch
2020-10-01  4:10   ` Klaus Jensen
2020-10-01 15:20     ` Keith Busch
2020-10-01 17:18       ` Klaus Jensen
2020-10-01 17:30         ` Keith Busch
2020-10-01 17:34           ` Klaus Jensen
2020-10-02  8:48   ` Klaus Jensen
2020-10-06  1:57   ` Dmitry Fomichev
2020-09-30 22:04 ` [PATCH 4/9] hw/block/nvme: validate command set selected Keith Busch
2020-10-01  4:14   ` Klaus Jensen [this message]
2020-09-30 22:04 ` [PATCH 5/9] hw/block/nvme: support for admin-only command set Keith Busch
2020-10-01  0:11   ` Dmitry Fomichev
2020-10-01  4:17   ` Klaus Jensen
2020-09-30 22:04 ` [PATCH 6/9] hw/block/nvme: reject io commands if only admin command set selected Keith Busch
2020-09-30 23:11   ` Dmitry Fomichev
2020-09-30 22:04 ` [PATCH 7/9] hw/block/nvme: add nsid to get/setfeat trace events Keith Busch
2020-09-30 22:04 ` [PATCH 8/9] hw/block/nvme: add trace event for requests with non-zero status code Keith Busch
2020-09-30 23:21   ` Dmitry Fomichev
2020-10-01 15:25   ` Philippe Mathieu-Daudé
2020-09-30 22:04 ` [PATCH 9/9] hw/block/nvme: report actual LBA data shift in LBAF Keith Busch
2020-10-01  9:48   ` Klaus Jensen
2020-10-01 18:46 ` [PATCH 0/9] nvme qemu cleanups and fixes Klaus Jensen
2020-10-13  9:04 ` Klaus Jensen
2020-10-13 17:48   ` Keith Busch
2020-10-13 18:36     ` Klaus Jensen

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=20201001041434.GD681387@apples.localdomain \
    --to=its@irrelevant.dk \
    --cc=Niklas.Cassel@wdc.com \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=philmd@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).