[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 08/48] nvme: fix pci doorbell size calculation
From: |
Klaus Jensen |
Subject: |
[PATCH v7 08/48] nvme: fix pci doorbell size calculation |
Date: |
Wed, 15 Apr 2020 07:51:00 +0200 |
From: Klaus Jensen <address@hidden>
The size of the BAR is 0x1000 (main registers) + 8 bytes for each
queue. Currently, the size of the BAR is calculated like so:
n->reg_size = pow2ceil(0x1004 + 2 * (n->params.num_queues + 1) * 4);
Since the 'num_queues' parameter already accounts for the admin queue,
this should in any case not need to be incremented by one. Also, the
size should be initialized to (0x1000).
n->reg_size = pow2ceil(0x1000 + 2 * n->params.num_queues * 4);
This, with the default value of num_queues (64), we will set aside room
for 1 admin queue and 63 I/O queues (4 bytes per doorbell, 2 doorbells
per queue).
Signed-off-by: Klaus Jensen <address@hidden>
---
hw/block/nvme.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index bea37c73732a..03278726422d 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -1363,7 +1363,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)
pcie_endpoint_cap_init(pci_dev, 0x80);
n->num_namespaces = 1;
- n->reg_size = pow2ceil(0x1004 + 2 * (n->params.num_queues + 1) * 4);
+ n->reg_size = pow2ceil(0x1000 + 2 * n->params.num_queues * 4);
n->ns_size = bs_size / (uint64_t)n->num_namespaces;
n->namespaces = g_new0(NvmeNamespace, n->num_namespaces);
--
2.26.0
- [PATCH v7 02/48] nvme: remove superfluous breaks, (continued)
- [PATCH v7 02/48] nvme: remove superfluous breaks, Klaus Jensen, 2020/04/15
- [PATCH v7 06/48] nvme: refactor nvme_addr_read, Klaus Jensen, 2020/04/15
- [PATCH v7 07/48] nvme: add support for the abort command, Klaus Jensen, 2020/04/15
- [PATCH v7 03/48] nvme: move device parameters to separate struct, Klaus Jensen, 2020/04/15
- [PATCH v7 05/48] nvme: use constants in identify, Klaus Jensen, 2020/04/15
- [PATCH v7 08/48] nvme: fix pci doorbell size calculation,
Klaus Jensen <=
- [PATCH v7 09/48] nvme: add max_ioqpairs device parameter, Klaus Jensen, 2020/04/15
- [PATCH v7 04/48] nvme: bump spec data structures to v1.3, Klaus Jensen, 2020/04/15
- [PATCH v7 10/48] nvme: remove redundant cmbloc/cmbsz members, Klaus Jensen, 2020/04/15
- [PATCH v7 01/48] nvme: rename trace events to nvme_dev, Klaus Jensen, 2020/04/15
- [PATCH v7 11/48] nvme: refactor device realization, Klaus Jensen, 2020/04/15