OSDN Git Service

hw/nvme: Remove reg_size variable and update BAR0 size calculation
authorŁukasz Gieryk <lukasz.gieryk@linux.intel.com>
Mon, 9 May 2022 14:16:14 +0000 (16:16 +0200)
committerKlaus Jensen <k.jensen@samsung.com>
Thu, 23 Jun 2022 21:24:29 +0000 (23:24 +0200)
commit3bfcc51737a939d909e42fb7a93c11b68549a613
treef2adcccc29050b3186b413202c27e3e264f50810
parentdecc02614f90ff5583807d89888fec47dfec23e1
hw/nvme: Remove reg_size variable and update BAR0 size calculation

The n->reg_size parameter unnecessarily splits the BAR0 size calculation
in two phases; removed to simplify the code.

With all the calculations done in one place, it seems the pow2ceil,
applied originally to reg_size, is unnecessary. The rounding should
happen as the last step, when BAR size includes Nvme registers, queue
registers, and MSIX-related space.

Finally, the size of the mmio memory region is extended to cover the 1st
4KiB padding (see the map below). Access to this range is handled as
interaction with a non-existing queue and generates an error trace, so
actually nothing changes, while the reg_size variable is no longer needed.

    --------------------
    |      BAR0        |
    --------------------
    [Nvme Registers    ]
    [Queues            ]
    [power-of-2 padding] - removed in this patch
    [4KiB padding (1)  ]
    [MSIX TABLE        ]
    [4KiB padding (2)  ]
    [MSIX PBA          ]
    [power-of-2 padding]

Signed-off-by: Łukasz Gieryk <lukasz.gieryk@linux.intel.com>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
hw/nvme/ctrl.c
hw/nvme/nvme.h