diff mbox series

[2/3] hw/nvme/ctrl: fix endian conversion for nsid in ctrl list

Message ID 20210517100736.17063-3-anaidu.gollu@samsung.com
State New
Headers show
Series adding ctrl list (cns 0x13) support and random fixes | expand

Commit Message

Gollu Appalanaidu May 17, 2021, 10:07 a.m. UTC
In Identify Ctrl List of the CNS 0x12 and 0x13 no endian conversion
for the nsid field.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
---
 hw/nvme/ctrl.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Klaus Jensen May 31, 2021, 8:53 p.m. UTC | #1
On May 17 15:37, Gollu Appalanaidu wrote:
>In Identify Ctrl List of the CNS 0x12 and 0x13 no endian conversion
>for the nsid field.
>
>Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
>---
> hw/nvme/ctrl.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
>diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
>index d08a3350e2..813a72c655 100644
>--- a/hw/nvme/ctrl.c
>+++ b/hw/nvme/ctrl.c
>@@ -4255,6 +4255,7 @@ static uint16_t nvme_identify_ctrl_list(NvmeCtrl *n, NvmeRequest *req,
>                                         bool attached)
> {
>     NvmeIdentify *c = (NvmeIdentify *)&req->cmd;
>+    uint32_t nsid = le32_to_cpu(c->nsid);
>     uint16_t min_id = le16_to_cpu(c->ctrlid);
>     uint16_t list[NVME_CONTROLLER_LIST_SIZE] = {};
>     uint16_t *ids = &list[1];
>@@ -4265,11 +4266,11 @@ static uint16_t nvme_identify_ctrl_list(NvmeCtrl *n, NvmeRequest *req,
>     trace_pci_nvme_identify_ctrl_list(c->cns, min_id);
>
>     if (attached) {
>-        if (c->nsid == NVME_NSID_BROADCAST) {
>+        if (nsid == NVME_NSID_BROADCAST) {
>             return NVME_INVALID_FIELD | NVME_DNR;
>         }
>
>-        ns = nvme_subsys_ns(n->subsys, c->nsid);
>+        ns = nvme_subsys_ns(n->subsys, nsid);
>         if (!ns) {
>             return NVME_INVALID_FIELD | NVME_DNR;
>         }
>@@ -4281,7 +4282,7 @@ static uint16_t nvme_identify_ctrl_list(NvmeCtrl *n, NvmeRequest *req,
>             continue;
>         }
>
>-        if (attached && !nvme_ns(ctrl, c->nsid)) {
>+        if (attached && !nvme_ns(ctrl, nsid)) {
>             continue;
>         }
>
>-- 
>2.17.1
>

I know that the endianness conversion was missing before your patch, but 
please squash this up into patch 1.
diff mbox series

Patch

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index d08a3350e2..813a72c655 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -4255,6 +4255,7 @@  static uint16_t nvme_identify_ctrl_list(NvmeCtrl *n, NvmeRequest *req,
                                         bool attached)
 {
     NvmeIdentify *c = (NvmeIdentify *)&req->cmd;
+    uint32_t nsid = le32_to_cpu(c->nsid);
     uint16_t min_id = le16_to_cpu(c->ctrlid);
     uint16_t list[NVME_CONTROLLER_LIST_SIZE] = {};
     uint16_t *ids = &list[1];
@@ -4265,11 +4266,11 @@  static uint16_t nvme_identify_ctrl_list(NvmeCtrl *n, NvmeRequest *req,
     trace_pci_nvme_identify_ctrl_list(c->cns, min_id);
 
     if (attached) {
-        if (c->nsid == NVME_NSID_BROADCAST) {
+        if (nsid == NVME_NSID_BROADCAST) {
             return NVME_INVALID_FIELD | NVME_DNR;
         }
 
-        ns = nvme_subsys_ns(n->subsys, c->nsid);
+        ns = nvme_subsys_ns(n->subsys, nsid);
         if (!ns) {
             return NVME_INVALID_FIELD | NVME_DNR;
         }
@@ -4281,7 +4282,7 @@  static uint16_t nvme_identify_ctrl_list(NvmeCtrl *n, NvmeRequest *req,
             continue;
         }
 
-        if (attached && !nvme_ns(ctrl, c->nsid)) {
+        if (attached && !nvme_ns(ctrl, nsid)) {
             continue;
         }