diff mbox series

hw/nvme: add knob for CTRATT.MEM

Message ID 20240924-add-ctratt-mem-knob-v1-1-0674de9b88b4@samsung.com (mailing list archive)
State New, archived
Headers show
Series hw/nvme: add knob for CTRATT.MEM | expand

Commit Message

Klaus Jensen Sept. 24, 2024, 6:35 a.m. UTC
From: Klaus Jensen <k.jensen@samsung.com>

Add a boolean prop (ctratt.mem) for setting CTRATT.MEM and default it to
unset (false) to keep existing behavior of the device intact.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/nvme/ctrl.c | 7 ++++++-
 hw/nvme/nvme.h | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)


---
base-commit: 3245de3f3d002bc9ce2ecae61e8d86cb9e375808
change-id: 20240924-add-ctratt-mem-knob-ae4431251cb1

Best regards,

Comments

Arun Kumar Sept. 24, 2024, 1:18 a.m. UTC | #1
Hi Klaus,

LGTM.

On 24/09/24 08:35AM, Klaus Jensen wrote:
>From: Klaus Jensen <k.jensen@samsung.com>
>
>Add a boolean prop (ctratt.mem) for setting CTRATT.MEM and default it to
>unset (false) to keep existing behavior of the device intact.
>
>Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>---
> hw/nvme/ctrl.c | 7 ++++++-
> hw/nvme/nvme.h | 4 ++++
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
>diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
>index f36c45931821..8556f3e61fa0 100644
>--- a/hw/nvme/ctrl.c
>+++ b/hw/nvme/ctrl.c
>@@ -8492,7 +8492,11 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
>     id->cntlid = cpu_to_le16(n->cntlid);
>
>     id->oaes = cpu_to_le32(NVME_OAES_NS_ATTR);
>-    ctratt = NVME_CTRATT_ELBAS | NVME_CTRATT_MEM;
>+
>+    ctratt = NVME_CTRATT_ELBAS;
>+    if (n->params.ctratt.mem) {
>+        ctratt |= NVME_CTRATT_MEM;
>+    }
>
>     id->rab = 6;
>
>@@ -8751,6 +8755,7 @@ static Property nvme_props[] = {
>                      false),
>     DEFINE_PROP_UINT16("mqes", NvmeCtrl, params.mqes, 0x7ff),
>     DEFINE_PROP_UINT16("spdm_port", PCIDevice, spdm_port, 0),
>+    DEFINE_PROP_BOOL("ctratt.mem", NvmeCtrl, params.ctratt.mem, false),
>     DEFINE_PROP_END_OF_LIST(),
> };
>
>diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
>index 781985754d0d..bd3c6ba33a67 100644
>--- a/hw/nvme/nvme.h
>+++ b/hw/nvme/nvme.h
>@@ -538,6 +538,10 @@ typedef struct NvmeParams {
>     uint32_t  sriov_max_vq_per_vf;
>     uint32_t  sriov_max_vi_per_vf;
>     bool     msix_exclusive_bar;
>+
>+    struct {
>+        bool mem;
>+    } ctratt;
> } NvmeParams;
>
> typedef struct NvmeCtrl {
>
>---
>base-commit: 3245de3f3d002bc9ce2ecae61e8d86cb9e375808
>change-id: 20240924-add-ctratt-mem-knob-ae4431251cb1
>
>Best regards,
>-- 
>Klaus Jensen <k.jensen@samsung.com>
>
>
Minwoo Im Sept. 26, 2024, 4:27 a.m. UTC | #2
On 24-09-24 08:35:40, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Add a boolean prop (ctratt.mem) for setting CTRATT.MEM and default it to
> unset (false) to keep existing behavior of the device intact.
> 
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>

Reviewed-by: Minwoo Im <minwoo.im@samsung.com>
Klaus Jensen Sept. 30, 2024, 10:43 a.m. UTC | #3
On Sep 24 08:35, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Add a boolean prop (ctratt.mem) for setting CTRATT.MEM and default it to
> unset (false) to keep existing behavior of the device intact.
> 
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>  hw/nvme/ctrl.c | 7 ++++++-
>  hw/nvme/nvme.h | 4 ++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index f36c45931821..8556f3e61fa0 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -8492,7 +8492,11 @@ static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
>      id->cntlid = cpu_to_le16(n->cntlid);
>  
>      id->oaes = cpu_to_le32(NVME_OAES_NS_ATTR);
> -    ctratt = NVME_CTRATT_ELBAS | NVME_CTRATT_MEM;
> +
> +    ctratt = NVME_CTRATT_ELBAS;
> +    if (n->params.ctratt.mem) {
> +        ctratt |= NVME_CTRATT_MEM;
> +    }
>  
>      id->rab = 6;
>  
> @@ -8751,6 +8755,7 @@ static Property nvme_props[] = {
>                       false),
>      DEFINE_PROP_UINT16("mqes", NvmeCtrl, params.mqes, 0x7ff),
>      DEFINE_PROP_UINT16("spdm_port", PCIDevice, spdm_port, 0),
> +    DEFINE_PROP_BOOL("ctratt.mem", NvmeCtrl, params.ctratt.mem, false),
>      DEFINE_PROP_END_OF_LIST(),
>  };
>  
> diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
> index 781985754d0d..bd3c6ba33a67 100644
> --- a/hw/nvme/nvme.h
> +++ b/hw/nvme/nvme.h
> @@ -538,6 +538,10 @@ typedef struct NvmeParams {
>      uint32_t  sriov_max_vq_per_vf;
>      uint32_t  sriov_max_vi_per_vf;
>      bool     msix_exclusive_bar;
> +
> +    struct {
> +        bool mem;
> +    } ctratt;
>  } NvmeParams;
>  
>  typedef struct NvmeCtrl {
> 
> ---
> base-commit: 3245de3f3d002bc9ce2ecae61e8d86cb9e375808
> change-id: 20240924-add-ctratt-mem-knob-ae4431251cb1
> 
> Best regards,
> -- 
> Klaus Jensen <k.jensen@samsung.com>
> 
> 

Applied to nvme-next.
diff mbox series

Patch

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index f36c45931821..8556f3e61fa0 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -8492,7 +8492,11 @@  static void nvme_init_ctrl(NvmeCtrl *n, PCIDevice *pci_dev)
     id->cntlid = cpu_to_le16(n->cntlid);
 
     id->oaes = cpu_to_le32(NVME_OAES_NS_ATTR);
-    ctratt = NVME_CTRATT_ELBAS | NVME_CTRATT_MEM;
+
+    ctratt = NVME_CTRATT_ELBAS;
+    if (n->params.ctratt.mem) {
+        ctratt |= NVME_CTRATT_MEM;
+    }
 
     id->rab = 6;
 
@@ -8751,6 +8755,7 @@  static Property nvme_props[] = {
                      false),
     DEFINE_PROP_UINT16("mqes", NvmeCtrl, params.mqes, 0x7ff),
     DEFINE_PROP_UINT16("spdm_port", PCIDevice, spdm_port, 0),
+    DEFINE_PROP_BOOL("ctratt.mem", NvmeCtrl, params.ctratt.mem, false),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h
index 781985754d0d..bd3c6ba33a67 100644
--- a/hw/nvme/nvme.h
+++ b/hw/nvme/nvme.h
@@ -538,6 +538,10 @@  typedef struct NvmeParams {
     uint32_t  sriov_max_vq_per_vf;
     uint32_t  sriov_max_vi_per_vf;
     bool     msix_exclusive_bar;
+
+    struct {
+        bool mem;
+    } ctratt;
 } NvmeParams;
 
 typedef struct NvmeCtrl {