qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alan Adamson <alan.adamson@oracle.com>
To: qemu-devel@nongnu.org
Cc: alan.adamson@oracle.com, foss@defmacro.it, kbusch@kernel.org,
	its@irrelevant.dk, qemu-block@nongnu.org
Subject: [PATCH v3 1/1] hw/nvme: CMIC.MCTRS should be set automatically for multi-controller subsystems or by parameter
Date: Thu,  1 May 2025 11:45:05 -0700	[thread overview]
Message-ID: <20250501184505.3630283-2-alan.adamson@oracle.com> (raw)
In-Reply-To: <20250501184505.3630283-1-alan.adamson@oracle.com>

If there are multiple controllers in a subsystem, CMIC.MCTRS should be set to on
for all controllers. For single controller subsystems, CMIC.MCTRS will be off by
default. A new subsystem specific parameter will allow setting CMIC.MCTRS for
single controller subsystems.

New NVMe Subsystem QEMU Parameter (See NVMe Specification for details):
    <subsystem>,cmic-mctrs=BOOLEAN (default: off)

Signed-off-by: Alan Adamson <alan.adamson@oracle.com>
---
 hw/nvme/ctrl.c   | 15 ++++++++++++++-
 hw/nvme/nvme.h   |  2 ++
 hw/nvme/subsys.c |  1 +
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index fd935507bc02..72e45f3a7f78 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -8880,7 +8880,20 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
     id->psd[0].enlat = cpu_to_le32(0x10);
     id->psd[0].exlat = cpu_to_le32(0x4);
 
-    id->cmic |= NVME_CMIC_MULTI_CTRL;
+    n->subsys->total_ctrls++;
+
+    /* Check if there are more than 2 controllers or cmic.mctrs is enabled */
+    if (n->subsys->params.cmic_mctrs || (n->subsys->total_ctrls > 2)) {
+        id->cmic |= NVME_CMIC_MULTI_CTRL;
+    } else if (n->subsys->total_ctrls == 2) {
+        /*
+         * When the 2nd controller on this subsys is inited, CMIC.MCTRS
+         * needs to be set. Also need to go back and set CMIC.MCTRS
+         * on the first controller.
+         */
+        id->cmic |= NVME_CMIC_MULTI_CTRL;
+        n->subsys->ctrls[0]->id_ctrl.cmic |= NVME_CMIC_MULTI_CTRL;
+    }
     ctratt |= NVME_CTRATT_ENDGRPS;
 
     id->endgidmax = cpu_to_le16(0x1);
diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index b5c9378ea4e5..061e7046550b 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -116,7 +116,9 @@ typedef struct NvmeSubsystem {
             uint16_t nruh;
             uint32_t nrg;
         } fdp;
+        bool         cmic_mctrs;
     } params;
+    uint8_t          total_ctrls;
 } NvmeSubsystem;
 
 int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp);
diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c
index 38271d78c8bd..c644fdf0be5e 100644
--- a/hw/nvme/subsys.c
+++ b/hw/nvme/subsys.c
@@ -216,6 +216,7 @@ static const Property nvme_subsystem_props[] = {
                      NVME_DEFAULT_RU_SIZE),
     DEFINE_PROP_UINT32("fdp.nrg", NvmeSubsystem, params.fdp.nrg, 1),
     DEFINE_PROP_UINT16("fdp.nruh", NvmeSubsystem, params.fdp.nruh, 0),
+    DEFINE_PROP_BOOL("cmic.mctrs", NvmeSubsystem, params.cmic_mctrs, false),
 };
 
 static void nvme_subsys_class_init(ObjectClass *oc, const void *data)
-- 
2.43.5



  reply	other threads:[~2025-05-01 18:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-01 18:45 [PATCH v3 0/1] hw/nvme: CMIC.MCTRS should be set automatically for multi-controller subsystems or by parameter Alan Adamson
2025-05-01 18:45 ` Alan Adamson [this message]
2025-05-20 23:08   ` [PATCH v3 1/1] " alan.adamson

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=20250501184505.3630283-2-alan.adamson@oracle.com \
    --to=alan.adamson@oracle.com \
    --cc=foss@defmacro.it \
    --cc=its@irrelevant.dk \
    --cc=kbusch@kernel.org \
    --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).