diff mbox series

[v7,10/48] nvme: remove redundant cmbloc/cmbsz members

Message ID 20200415055140.466900-11-its@irrelevant.dk (mailing list archive)
State New, archived
Headers show
Series nvme: support NVMe v1.3d, SGLs and multiple namespaces | expand

Commit Message

Klaus Jensen April 15, 2020, 5:51 a.m. UTC
From: Klaus Jensen <k.jensen@samsung.com>

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

Comments

Philippe Mathieu-Daudé April 15, 2020, 7:10 a.m. UTC | #1
On 4/15/20 7:51 AM, Klaus Jensen wrote:
> From: Klaus Jensen <k.jensen@samsung.com>
> 
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>   hw/block/nvme.c | 7 ++-----
>   hw/block/nvme.h | 2 --
>   2 files changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index f45909dad480..123539a5d0ae 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -63,7 +63,7 @@ static inline bool nvme_addr_is_cmb(NvmeCtrl *n, hwaddr addr)
>   
>   static void nvme_addr_read(NvmeCtrl *n, hwaddr addr, void *buf, int size)
>   {
> -    if (n->cmbsz && nvme_addr_is_cmb(n, addr)) {
> +    if (n->bar.cmbsz && nvme_addr_is_cmb(n, addr)) {
>           memcpy(buf, (void *)&n->cmbuf[addr - n->ctrl_mem.addr], size);
>           return;
>       }
> @@ -157,7 +157,7 @@ static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVector *iov, uint64_t prp1,
>       if (unlikely(!prp1)) {
>           trace_nvme_dev_err_invalid_prp();
>           return NVME_INVALID_FIELD | NVME_DNR;
> -    } else if (n->cmbsz && prp1 >= n->ctrl_mem.addr &&
> +    } else if (n->bar.cmbsz && prp1 >= n->ctrl_mem.addr &&
>                  prp1 < n->ctrl_mem.addr + int128_get64(n->ctrl_mem.size)) {
>           qsg->nsg = 0;
>           qemu_iovec_init(iov, num_prps);
> @@ -1443,9 +1443,6 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
>           NVME_CMBSZ_SET_SZU(n->bar.cmbsz, 2); /* MBs */
>           NVME_CMBSZ_SET_SZ(n->bar.cmbsz, n->params.cmb_size_mb);
>   
> -        n->cmbloc = n->bar.cmbloc;
> -        n->cmbsz = n->bar.cmbsz;
> -
>           n->cmbuf = g_malloc0(NVME_CMBSZ_GETSIZE(n->bar.cmbsz));
>           memory_region_init_io(&n->ctrl_mem, OBJECT(n), &nvme_cmb_ops, n,
>                                 "nvme-cmb", NVME_CMBSZ_GETSIZE(n->bar.cmbsz));
> diff --git a/hw/block/nvme.h b/hw/block/nvme.h
> index 98f5b9479244..ad1786953be9 100644
> --- a/hw/block/nvme.h
> +++ b/hw/block/nvme.h
> @@ -88,8 +88,6 @@ typedef struct NvmeCtrl {
>       uint32_t    num_namespaces;
>       uint32_t    max_q_ents;
>       uint64_t    ns_size;
> -    uint32_t    cmbsz;
> -    uint32_t    cmbloc;
>       uint8_t     *cmbuf;
>       uint64_t    irq_status;
>       uint64_t    host_timestamp;                 /* Timestamp sent by the host */
> 

"hw/block/nvme.h" should not pull in "block/nvme.h", both should include 
a common "hw/block/nvme_spec.h" (or better named). Not related to this 
patch although.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Klaus Jensen April 15, 2020, 7:19 a.m. UTC | #2
On Apr 15 09:10, Philippe Mathieu-Daudé wrote:
> 
> "hw/block/nvme.h" should not pull in "block/nvme.h", both should include a
> common "hw/block/nvme_spec.h" (or better named). Not related to this patch
> although.
> 

Hmm. It does pull in the "include/block/nvme.h" which is basically the
"nvme_spec.h" you are talking about. That file holds all spec related
structs that are shared between the VFIO based nvme driver
(block/nvme.c) and the emulated device (hw/block/nvme.c).

Isn't that what is intended?
Philippe Mathieu-Daudé April 15, 2020, 7:48 a.m. UTC | #3
On 4/15/20 9:19 AM, Klaus Birkelund Jensen wrote:
> On Apr 15 09:10, Philippe Mathieu-Daudé wrote:
>>
>> "hw/block/nvme.h" should not pull in "block/nvme.h", both should include a
>> common "hw/block/nvme_spec.h" (or better named). Not related to this patch
>> although.
>>
> 
> Hmm. It does pull in the "include/block/nvme.h" which is basically the
> "nvme_spec.h" you are talking about. That file holds all spec related
> structs that are shared between the VFIO based nvme driver
> (block/nvme.c) and the emulated device (hw/block/nvme.c).
> 
> Isn't that what is intended?

You are correct, "include/block/nvme.h" contains the spec definitions. I 
was expecting to see (QEMU) block-related structure in it, but they aren't.
diff mbox series

Patch

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index f45909dad480..123539a5d0ae 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -63,7 +63,7 @@  static inline bool nvme_addr_is_cmb(NvmeCtrl *n, hwaddr addr)
 
 static void nvme_addr_read(NvmeCtrl *n, hwaddr addr, void *buf, int size)
 {
-    if (n->cmbsz && nvme_addr_is_cmb(n, addr)) {
+    if (n->bar.cmbsz && nvme_addr_is_cmb(n, addr)) {
         memcpy(buf, (void *)&n->cmbuf[addr - n->ctrl_mem.addr], size);
         return;
     }
@@ -157,7 +157,7 @@  static uint16_t nvme_map_prp(QEMUSGList *qsg, QEMUIOVector *iov, uint64_t prp1,
     if (unlikely(!prp1)) {
         trace_nvme_dev_err_invalid_prp();
         return NVME_INVALID_FIELD | NVME_DNR;
-    } else if (n->cmbsz && prp1 >= n->ctrl_mem.addr &&
+    } else if (n->bar.cmbsz && prp1 >= n->ctrl_mem.addr &&
                prp1 < n->ctrl_mem.addr + int128_get64(n->ctrl_mem.size)) {
         qsg->nsg = 0;
         qemu_iovec_init(iov, num_prps);
@@ -1443,9 +1443,6 @@  static void nvme_realize(PCIDevice *pci_dev, Error **errp)
         NVME_CMBSZ_SET_SZU(n->bar.cmbsz, 2); /* MBs */
         NVME_CMBSZ_SET_SZ(n->bar.cmbsz, n->params.cmb_size_mb);
 
-        n->cmbloc = n->bar.cmbloc;
-        n->cmbsz = n->bar.cmbsz;
-
         n->cmbuf = g_malloc0(NVME_CMBSZ_GETSIZE(n->bar.cmbsz));
         memory_region_init_io(&n->ctrl_mem, OBJECT(n), &nvme_cmb_ops, n,
                               "nvme-cmb", NVME_CMBSZ_GETSIZE(n->bar.cmbsz));
diff --git a/hw/block/nvme.h b/hw/block/nvme.h
index 98f5b9479244..ad1786953be9 100644
--- a/hw/block/nvme.h
+++ b/hw/block/nvme.h
@@ -88,8 +88,6 @@  typedef struct NvmeCtrl {
     uint32_t    num_namespaces;
     uint32_t    max_q_ents;
     uint64_t    ns_size;
-    uint32_t    cmbsz;
-    uint32_t    cmbloc;
     uint8_t     *cmbuf;
     uint64_t    irq_status;
     uint64_t    host_timestamp;                 /* Timestamp sent by the host */