summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé2020-10-29 10:32:55 +0100
committerStefan Hajnoczi2020-11-03 20:06:21 +0100
commit3c363c073e024fae7b09cad916e63dae89ed46cc (patch)
treecf689c017997dce464faec18e252f7650622bd74
parentblock/nvme: Use definitions instead of magic values in add_io_queue() (diff)
downloadqemu-3c363c073e024fae7b09cad916e63dae89ed46cc.tar.gz
qemu-3c363c073e024fae7b09cad916e63dae89ed46cc.tar.xz
qemu-3c363c073e024fae7b09cad916e63dae89ed46cc.zip
block/nvme: Correctly initialize Admin Queue Attributes
From the specification chapter 3.1.8 "AQA - Admin Queue Attributes" the Admin Submission Queue Size field is a 0’s based value: Admin Submission Queue Size (ASQS): Defines the size of the Admin Submission Queue in entries. Enabling a controller while this field is cleared to 00h produces undefined results. The minimum size of the Admin Submission Queue is two entries. The maximum size of the Admin Submission Queue is 4096 entries. This is a 0’s based value. This bug has never been hit because the device initialization uses a single command synchronously :) Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Tested-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20201029093306.1063879-15-philmd@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Tested-by: Eric Auger <eric.auger@redhat.com>
-rw-r--r--block/nvme.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/block/nvme.c b/block/nvme.c
index 7285bd2e27..0902aa5542 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -789,9 +789,9 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
goto out;
}
s->queue_count = 1;
- QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000);
- regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) |
- (NVME_QUEUE_SIZE << AQA_ASQS_SHIFT));
+ QEMU_BUILD_BUG_ON((NVME_QUEUE_SIZE - 1) & 0xF000);
+ regs->aqa = cpu_to_le32(((NVME_QUEUE_SIZE - 1) << AQA_ACQS_SHIFT) |
+ ((NVME_QUEUE_SIZE - 1) << AQA_ASQS_SHIFT));
regs->asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova);
regs->acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova);