[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 14/25] block/nvme: Use definitions instead of magic values in
From: |
Auger Eric |
Subject: |
Re: [PATCH 14/25] block/nvme: Use definitions instead of magic values in add_io_queue() |
Date: |
Wed, 28 Oct 2020 15:17:38 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
Hi Philippe,
On 10/27/20 2:55 PM, Philippe Mathieu-Daudé wrote:
> Replace magic values by definitions, and simplifiy since the
> number of queues will never reach 64K.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> block/nvme.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/block/nvme.c b/block/nvme.c
> index 9324f0bfdc4..2dfcf8c41d7 100644
> --- a/block/nvme.c
> +++ b/block/nvme.c
> @@ -651,6 +651,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error
> **errp)
> NvmeCmd cmd;
> unsigned queue_size = NVME_QUEUE_SIZE;
>
> + assert(n <= UINT16_MAX);
> q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs),
> n, queue_size, errp);
> if (!q) {
> @@ -659,8 +660,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error
> **errp)
> cmd = (NvmeCmd) {
> .opcode = NVME_ADM_CMD_CREATE_CQ,
> .dptr.prp1 = cpu_to_le64(q->cq.iova),
> - .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)),
> - .cdw11 = cpu_to_le32(0x3),
> + .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
> + .cdw11 = cpu_to_le32(NVME_CQ_IEN | NVME_CQ_PC),
> };
> if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
> error_setg(errp, "Failed to create CQ io queue [%u]", n);
> @@ -669,8 +670,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error
> **errp)
> cmd = (NvmeCmd) {
> .opcode = NVME_ADM_CMD_CREATE_SQ,
> .dptr.prp1 = cpu_to_le64(q->sq.iova),
> - .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)),
> - .cdw11 = cpu_to_le32(0x1 | (n << 16)),
> + .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n),
> + .cdw11 = cpu_to_le32(NVME_SQ_PC | (n << 16)),
> };
> if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
> error_setg(errp, "Failed to create SQ io queue [%u]", n);
>
- Re: [PATCH 08/25] block/nvme: Simplify device reset, (continued)
- [PATCH 12/25] block/nvme: Make nvme_init_queue() return boolean indicating error, Philippe Mathieu-Daudé, 2020/10/27
- [PATCH 13/25] block/nvme: Introduce Completion Queue definitions, Philippe Mathieu-Daudé, 2020/10/27
- [PATCH 14/25] block/nvme: Use definitions instead of magic values in add_io_queue(), Philippe Mathieu-Daudé, 2020/10/27
- [PATCH 16/25] block/nvme: Simplify ADMIN queue access, Philippe Mathieu-Daudé, 2020/10/27
- [PATCH 17/25] block/nvme: Simplify nvme_cmd_sync(), Philippe Mathieu-Daudé, 2020/10/27
- [PATCH 15/25] block/nvme: Correctly initialize Admin Queue Attributes, Philippe Mathieu-Daudé, 2020/10/27