From: Auger Eric <eric.auger@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>,
Keith Busch <kbusch@kernel.org>,
Stefan Hajnoczi <stefanha@redhat.com>,
Klaus Jensen <its@irrelevant.dk>
Subject: Re: [PATCH 10/25] block/nvme: Use unsigned integer for queue counter/size
Date: Wed, 28 Oct 2020 11:48:39 +0100 [thread overview]
Message-ID: <a8a844e5-1171-bb2d-035b-8f3e5060c456@redhat.com> (raw)
In-Reply-To: <20201027135547.374946-11-philmd@redhat.com>
Hi,
On 10/27/20 2:55 PM, Philippe Mathieu-Daudé wrote:
> We can not have negative queue count/size/index, use unsigned type.
> Rename 'nr_queues' as 'queue_count' to match the spec naming.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thanks
Eric
> ---
> block/nvme.c | 38 ++++++++++++++++++--------------------
> block/trace-events | 10 +++++-----
> 2 files changed, 23 insertions(+), 25 deletions(-)
>
> diff --git a/block/nvme.c b/block/nvme.c
> index 30075e230ca..8b0fd59c6ea 100644
> --- a/block/nvme.c
> +++ b/block/nvme.c
> @@ -104,7 +104,7 @@ struct BDRVNVMeState {
> * [1..]: io queues.
> */
> NVMeQueuePair **queues;
> - int nr_queues;
> + unsigned queue_count;
> size_t page_size;
> /* How many uint32_t elements does each doorbell entry take. */
> size_t doorbell_scale;
> @@ -161,7 +161,7 @@ static QemuOptsList runtime_opts = {
> };
>
> static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q,
> - int nentries, int entry_bytes, Error **errp)
> + unsigned nentries, size_t entry_bytes, Error **errp)
> {
> size_t bytes;
> int r;
> @@ -206,7 +206,7 @@ static void nvme_free_req_queue_cb(void *opaque)
>
> static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
> AioContext *aio_context,
> - int idx, int size,
> + unsigned idx, size_t size,
> Error **errp)
> {
> int i, r;
> @@ -623,7 +623,7 @@ static bool nvme_poll_queues(BDRVNVMeState *s)
> bool progress = false;
> int i;
>
> - for (i = 0; i < s->nr_queues; i++) {
> + for (i = 0; i < s->queue_count; i++) {
> if (nvme_poll_queue(s->queues[i])) {
> progress = true;
> }
> @@ -644,10 +644,10 @@ static void nvme_handle_event(EventNotifier *n)
> static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
> {
> BDRVNVMeState *s = bs->opaque;
> - int n = s->nr_queues;
> + unsigned n = s->queue_count;
> NVMeQueuePair *q;
> NvmeCmd cmd;
> - int queue_size = NVME_QUEUE_SIZE;
> + unsigned queue_size = NVME_QUEUE_SIZE;
>
> q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs),
> n, queue_size, errp);
> @@ -661,7 +661,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
> .cdw11 = cpu_to_le32(0x3),
> };
> if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
> - error_setg(errp, "Failed to create CQ io queue [%d]", n);
> + error_setg(errp, "Failed to create CQ io queue [%u]", n);
> goto out_error;
> }
> cmd = (NvmeCmd) {
> @@ -671,12 +671,12 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
> .cdw11 = cpu_to_le32(0x1 | (n << 16)),
> };
> if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) {
> - error_setg(errp, "Failed to create SQ io queue [%d]", n);
> + error_setg(errp, "Failed to create SQ io queue [%u]", n);
> goto out_error;
> }
> s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1);
> s->queues[n] = q;
> - s->nr_queues++;
> + s->queue_count++;
> return true;
> out_error:
> nvme_free_queue_pair(q);
> @@ -785,7 +785,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
> ret = -EINVAL;
> goto out;
> }
> - s->nr_queues = 1;
> + 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));
> @@ -895,10 +895,9 @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable,
>
> static void nvme_close(BlockDriverState *bs)
> {
> - int i;
> BDRVNVMeState *s = bs->opaque;
>
> - for (i = 0; i < s->nr_queues; ++i) {
> + for (unsigned i = 0; i < s->queue_count; ++i) {
> nvme_free_queue_pair(s->queues[i]);
> }
> g_free(s->queues);
> @@ -1123,7 +1122,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs,
> };
>
> trace_nvme_prw_aligned(s, is_write, offset, bytes, flags, qiov->niov);
> - assert(s->nr_queues > 1);
> + assert(s->queue_count > 1);
> req = nvme_get_free_req(ioq);
> assert(req);
>
> @@ -1233,7 +1232,7 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs)
> .ret = -EINPROGRESS,
> };
>
> - assert(s->nr_queues > 1);
> + assert(s->queue_count > 1);
> req = nvme_get_free_req(ioq);
> assert(req);
> nvme_submit_command(ioq, req, &cmd, nvme_rw_cb, &data);
> @@ -1285,7 +1284,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs,
> cmd.cdw12 = cpu_to_le32(cdw12);
>
> trace_nvme_write_zeroes(s, offset, bytes, flags);
> - assert(s->nr_queues > 1);
> + assert(s->queue_count > 1);
> req = nvme_get_free_req(ioq);
> assert(req);
>
> @@ -1328,7 +1327,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs,
> return -ENOTSUP;
> }
>
> - assert(s->nr_queues > 1);
> + assert(s->queue_count > 1);
>
> buf = qemu_try_memalign(s->page_size, s->page_size);
> if (!buf) {
> @@ -1408,7 +1407,7 @@ static void nvme_detach_aio_context(BlockDriverState *bs)
> {
> BDRVNVMeState *s = bs->opaque;
>
> - for (int i = 0; i < s->nr_queues; i++) {
> + for (unsigned i = 0; i < s->queue_count; i++) {
> NVMeQueuePair *q = s->queues[i];
>
> qemu_bh_delete(q->completion_bh);
> @@ -1429,7 +1428,7 @@ static void nvme_attach_aio_context(BlockDriverState *bs,
> aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_IDX],
> false, nvme_handle_event, nvme_poll_cb);
>
> - for (int i = 0; i < s->nr_queues; i++) {
> + for (unsigned i = 0; i < s->queue_count; i++) {
> NVMeQueuePair *q = s->queues[i];
>
> q->completion_bh =
> @@ -1446,11 +1445,10 @@ static void nvme_aio_plug(BlockDriverState *bs)
>
> static void nvme_aio_unplug(BlockDriverState *bs)
> {
> - int i;
> BDRVNVMeState *s = bs->opaque;
> assert(s->plugged);
> s->plugged = false;
> - for (i = INDEX_IO(0); i < s->nr_queues; i++) {
> + for (unsigned i = INDEX_IO(0); i < s->queue_count; i++) {
> NVMeQueuePair *q = s->queues[i];
> qemu_mutex_lock(&q->lock);
> nvme_kick(q);
> diff --git a/block/trace-events b/block/trace-events
> index f6a0f99df1a..8368f4acb0b 100644
> --- a/block/trace-events
> +++ b/block/trace-events
> @@ -136,13 +136,13 @@ qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s
> # nvme.c
> nvme_controller_capability_raw(uint64_t value) "0x%08"PRIx64
> nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64
> -nvme_kick(void *s, int queue) "s %p queue %d"
> +nvme_kick(void *s, unsigned q_index) "s %p q #%u"
> nvme_dma_flush_queue_wait(void *s) "s %p"
> nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "cmd_specific %d sq_head %d sqid %d cid %d status 0x%x"
> -nvme_process_completion(void *s, int index, int inflight) "s %p queue %d inflight %d"
> -nvme_process_completion_queue_plugged(void *s, int index) "s %p queue %d"
> -nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d"
> -nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d"
> +nvme_process_completion(void *s, unsigned q_index, int inflight) "s %p q #%u inflight %d"
> +nvme_process_completion_queue_plugged(void *s, unsigned q_index) "s %p q #%u"
> +nvme_complete_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d"
> +nvme_submit_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d"
> nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x"
> nvme_handle_event(void *s) "s %p"
> nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u"
>
next prev parent reply other threads:[~2020-10-28 10:49 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-27 13:55 [PATCH 00/25] block/nvme: Fix Aarch64 host Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 01/25] MAINTAINERS: Cover 'block/nvme.h' file Philippe Mathieu-Daudé
2020-10-28 15:47 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 02/25] block/nvme: Use hex format to display offset in trace events Philippe Mathieu-Daudé
2020-10-28 10:21 ` Auger Eric
2020-10-28 15:47 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 03/25] block/nvme: Report warning with warn_report() Philippe Mathieu-Daudé
2020-10-27 14:45 ` Keith Busch
2020-10-27 15:33 ` Philippe Mathieu-Daudé
2020-10-27 15:54 ` Philippe Mathieu-Daudé
2020-10-28 10:22 ` Auger Eric
2020-10-28 15:47 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 04/25] block/nvme: Trace controller capabilities Philippe Mathieu-Daudé
2020-10-28 10:20 ` Auger Eric
2020-10-28 10:25 ` Philippe Mathieu-Daudé
2020-10-28 10:36 ` Auger Eric
2020-10-27 13:55 ` [PATCH 05/25] block/nvme: Trace nvme_poll_queue() per queue Philippe Mathieu-Daudé
2020-10-28 10:31 ` Auger Eric
2020-10-28 15:48 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 06/25] block/nvme: Improve nvme_free_req_queue_wait() trace information Philippe Mathieu-Daudé
2020-10-28 10:32 ` Auger Eric
2020-10-28 15:48 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 07/25] block/nvme: Trace queue pair creation/deletion Philippe Mathieu-Daudé
2020-10-28 10:28 ` Auger Eric
2020-10-28 15:48 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 08/25] block/nvme: Simplify device reset Philippe Mathieu-Daudé
2020-10-27 14:54 ` Keith Busch
2020-10-27 14:58 ` Keith Busch
2020-10-27 15:53 ` Philippe Mathieu-Daudé
2020-10-27 16:55 ` Keith Busch
2020-10-28 15:02 ` Stefan Hajnoczi
2020-10-28 15:10 ` Keith Busch
2020-10-27 13:55 ` [PATCH 09/25] block/nvme: Move definitions before structure declarations Philippe Mathieu-Daudé
2020-10-28 10:44 ` Auger Eric
2020-10-28 15:49 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 10/25] block/nvme: Use unsigned integer for queue counter/size Philippe Mathieu-Daudé
2020-10-28 10:48 ` Auger Eric [this message]
2020-10-28 15:49 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 11/25] block/nvme: Make nvme_identify() return boolean indicating error Philippe Mathieu-Daudé
2020-10-28 11:03 ` Auger Eric
2020-10-28 15:07 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 12/25] block/nvme: Make nvme_init_queue() " Philippe Mathieu-Daudé
2020-10-28 11:10 ` Auger Eric
2020-10-28 15:11 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 13/25] block/nvme: Introduce Completion Queue definitions Philippe Mathieu-Daudé
2020-10-28 11:18 ` Auger Eric
2020-10-28 15:10 ` Stefan Hajnoczi
2020-10-28 15:16 ` Stefan Hajnoczi
2020-10-28 18:24 ` Philippe Mathieu-Daudé
2020-10-29 9:02 ` Philippe Mathieu-Daudé
2020-10-30 11:46 ` Stefan Hajnoczi
2020-10-30 14:51 ` Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 14/25] block/nvme: Use definitions instead of magic values in add_io_queue() Philippe Mathieu-Daudé
2020-10-28 14:17 ` Auger Eric
2020-10-28 15:16 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 15/25] block/nvme: Correctly initialize Admin Queue Attributes Philippe Mathieu-Daudé
2020-10-28 14:21 ` Auger Eric
2020-10-28 15:17 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 16/25] block/nvme: Simplify ADMIN queue access Philippe Mathieu-Daudé
2020-10-28 14:25 ` Auger Eric
2020-10-28 15:19 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 17/25] block/nvme: Simplify nvme_cmd_sync() Philippe Mathieu-Daudé
2020-10-28 14:27 ` Auger Eric
2020-10-28 15:21 ` Stefan Hajnoczi
2020-10-29 7:35 ` Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 18/25] block/nvme: Pass AioContext argument to nvme_add_io_queue() Philippe Mathieu-Daudé
2020-10-28 14:30 ` Auger Eric
2020-10-28 15:30 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 19/25] block/nvme: Set request_alignment at initialization Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 20/25] block/nvme: Correct minimum device page size Philippe Mathieu-Daudé
2020-10-27 13:55 ` [PATCH 21/25] block/nvme: Change size and alignment of IDENTIFY response buffer Philippe Mathieu-Daudé
2020-10-28 15:35 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 22/25] block/nvme: Change size and alignment of queue Philippe Mathieu-Daudé
2020-10-28 15:37 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 23/25] block/nvme: Change size and alignment of prp_list_pages Philippe Mathieu-Daudé
2020-10-28 15:38 ` Stefan Hajnoczi
2020-10-27 13:55 ` [PATCH 24/25] block/nvme: Align iov's va and size on host page size Philippe Mathieu-Daudé
2020-10-28 15:41 ` Stefan Hajnoczi
2020-10-27 13:55 ` [RFC PATCH 25/25] block/nvme: Fix use of write-only doorbells page on Aarch64 arch Philippe Mathieu-Daudé
2020-10-28 15:47 ` Stefan Hajnoczi
2020-10-28 16:12 ` Auger Eric
2020-10-28 18:10 ` [PATCH 00/25] block/nvme: Fix Aarch64 host Auger Eric
2020-10-29 9:08 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a8a844e5-1171-bb2d-035b-8f3e5060c456@redhat.com \
--to=eric.auger@redhat.com \
--cc=fam@euphon.net \
--cc=its@irrelevant.dk \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).