Allow the value of CMIC to to be set via a new subsystem specific parameter.
This removes the requirement that all subsystems must have the CMIC bit enabled.

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

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

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 518d02dc6670..ddd3ec15d131 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -8876,7 +8876,10 @@ 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;
+    if (n->subsys->params.cmic) {
+        id->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 6f782ba18826..437b3e64fcfb 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -116,6 +116,7 @@ typedef struct NvmeSubsystem {
             uint16_t nruh;
             uint32_t nrg;
         } fdp;
+        bool         cmic;
     } params;
 } NvmeSubsystem;
 
diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c
index 2ae56f12a596..ea6687c7ee6c 100644
--- a/hw/nvme/subsys.c
+++ b/hw/nvme/subsys.c
@@ -223,6 +223,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", NvmeSubsystem, params.cmic, false),
 };
 
 static void nvme_subsys_class_init(ObjectClass *oc, void *data)
-- 
2.43.5


Reply via email to