[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 10/16] nvme: factor out device state setup
From: |
Maxim Levitsky |
Subject: |
Re: [PATCH v2 10/16] nvme: factor out device state setup |
Date: |
Tue, 21 Apr 2020 17:55:06 +0300 |
On Wed, 2020-04-15 at 15:01 +0200, Klaus Jensen wrote:
> From: Klaus Jensen <address@hidden>
>
> Signed-off-by: Klaus Jensen <address@hidden>
> Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> hw/block/nvme.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 5f9ebbd6a1d5..45a352b63d89 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -1340,6 +1340,17 @@ static void nvme_check_constraints(NvmeCtrl *n, Error
> **errp)
> }
> }
>
> +static void nvme_init_state(NvmeCtrl *n)
> +{
> + n->num_namespaces = 1;
> + /* add one to max_ioqpairs to account for the admin queue pair */
> + n->reg_size = pow2ceil(NVME_REG_SIZE +
> + 2 * (n->params.max_ioqpairs + 1) * NVME_DB_SIZE);
> + n->namespaces = g_new0(NvmeNamespace, n->num_namespaces);
> + n->sq = g_new0(NvmeSQueue *, n->params.max_ioqpairs + 1);
> + n->cq = g_new0(NvmeCQueue *, n->params.max_ioqpairs + 1);
> +}
> +
> static void nvme_realize(PCIDevice *pci_dev, Error **errp)
> {
> NvmeCtrl *n = NVME(pci_dev);
> @@ -1356,6 +1367,8 @@ static void nvme_realize(PCIDevice *pci_dev, Error
> **errp)
> return;
> }
>
> + nvme_init_state(n);
> +
> bs_size = blk_getlength(n->conf.blk);
> if (bs_size < 0) {
> error_setg(errp, "could not get backing file size");
> @@ -1374,17 +1387,8 @@ static void nvme_realize(PCIDevice *pci_dev, Error
> **errp)
> pci_config_set_class(pci_dev->config, PCI_CLASS_STORAGE_EXPRESS);
> pcie_endpoint_cap_init(pci_dev, 0x80);
>
> - n->num_namespaces = 1;
> -
> - /* add one to max_ioqpairs to account for the admin queue pair */
> - n->reg_size = pow2ceil(NVME_REG_SIZE +
> - 2 * (n->params.max_ioqpairs + 1) * NVME_DB_SIZE);
> n->ns_size = bs_size / (uint64_t)n->num_namespaces;
>
> - n->namespaces = g_new0(NvmeNamespace, n->num_namespaces);
> - n->sq = g_new0(NvmeSQueue *, n->params.max_ioqpairs + 1);
> - n->cq = g_new0(NvmeCQueue *, n->params.max_ioqpairs + 1);
> -
> memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n,
> "nvme", n->reg_size);
> pci_register_bar(pci_dev, 0,
Reviewed-by: Maxim Levitsky <address@hidden>
Best regards,
Maxim Levitsky
- [PATCH v2 06/16] nvme: refactor nvme_addr_read, (continued)
- [PATCH v2 06/16] nvme: refactor nvme_addr_read, Klaus Jensen, 2020/04/15
- [PATCH v2 03/16] nvme: remove superfluous breaks, Klaus Jensen, 2020/04/15
- [PATCH v2 09/16] nvme: factor out property/constraint checks, Klaus Jensen, 2020/04/15
- [PATCH v2 05/16] nvme: use constants in identify, Klaus Jensen, 2020/04/15
- [PATCH v2 07/16] nvme: add max_ioqpairs device parameter, Klaus Jensen, 2020/04/15
- [PATCH v2 04/16] nvme: move device parameters to separate struct, Klaus Jensen, 2020/04/15
- [PATCH v2 10/16] nvme: factor out device state setup, Klaus Jensen, 2020/04/15
- Re: [PATCH v2 10/16] nvme: factor out device state setup,
Maxim Levitsky <=
- [PATCH v2 08/16] nvme: remove redundant cmbloc/cmbsz members, Klaus Jensen, 2020/04/15
- [PATCH v2 02/16] nvme: rename trace events to pci_nvme, Klaus Jensen, 2020/04/15
- [PATCH v2 11/16] nvme: factor out block backend setup, Klaus Jensen, 2020/04/15
- [PATCH v2 14/16] nvme: factor out pci setup, Klaus Jensen, 2020/04/15