All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>, "Fam Zheng" <fam@euphon.net>,
	qemu-block@nongnu.org, "Max Reitz" <mreitz@redhat.com>,
	"Keith Busch" <kbusch@kernel.org>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Klaus Jensen" <its@irrelevant.dk>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH-for-5.2 v2 15/25] block/nvme: Simplify ADMIN queue access
Date: Thu, 29 Oct 2020 10:32:56 +0100	[thread overview]
Message-ID: <20201029093306.1063879-16-philmd@redhat.com> (raw)
In-Reply-To: <20201029093306.1063879-1-philmd@redhat.com>

We don't need to dereference from BDRVNVMeState each time.
Use a NVMeQueuePair pointer on the admin queue.
The nvme_init() becomes easier to review, matching the style
of nvme_add_io_queue().

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>
---
 block/nvme.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/block/nvme.c b/block/nvme.c
index 0902aa55428..eed12f4933c 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -700,6 +700,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
                      Error **errp)
 {
     BDRVNVMeState *s = bs->opaque;
+    NVMeQueuePair *q;
     AioContext *aio_context = bdrv_get_aio_context(bs);
     int ret;
     uint64_t cap;
@@ -781,19 +782,18 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace,
 
     /* Set up admin queue. */
     s->queues = g_new(NVMeQueuePair *, 1);
-    s->queues[INDEX_ADMIN] = nvme_create_queue_pair(s, aio_context, 0,
-                                                          NVME_QUEUE_SIZE,
-                                                          errp);
-    if (!s->queues[INDEX_ADMIN]) {
+    q = nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp);
+    if (!q) {
         ret = -EINVAL;
         goto out;
     }
+    s->queues[INDEX_ADMIN] = q;
     s->queue_count = 1;
     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);
+    regs->asq = cpu_to_le64(q->sq.iova);
+    regs->acq = cpu_to_le64(q->cq.iova);
 
     /* After setting up all control registers we can enable device now. */
     regs->cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << CC_IOCQES_SHIFT) |
-- 
2.26.2



  parent reply	other threads:[~2020-10-29  9:45 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29  9:32 [PATCH-for-5.2 v2 00/25] block/nvme: Fix Aarch64 or big-endian hosts Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 01/25] MAINTAINERS: Cover 'block/nvme.h' file Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 02/25] block/nvme: Use hex format to display offset in trace events Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 03/25] block/nvme: Report warning with warn_report() Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 04/25] block/nvme: Trace controller capabilities Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 05/25] block/nvme: Trace nvme_poll_queue() per queue Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 06/25] block/nvme: Improve nvme_free_req_queue_wait() trace information Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 07/25] block/nvme: Trace queue pair creation/deletion Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 08/25] block/nvme: Move definitions before structure declarations Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 09/25] block/nvme: Use unsigned integer for queue counter/size Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 10/25] block/nvme: Make nvme_identify() return boolean indicating error Philippe Mathieu-Daudé
2020-10-30 14:03   ` Stefan Hajnoczi
2020-10-29  9:32 ` [PATCH-for-5.2 v2 11/25] block/nvme: Make nvme_init_queue() " Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 12/25] block/nvme: Introduce Completion Queue definitions Philippe Mathieu-Daudé
2020-10-30 14:03   ` Stefan Hajnoczi
2020-10-30 14:52     ` Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 13/25] block/nvme: Use definitions instead of magic values in add_io_queue() Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 14/25] block/nvme: Correctly initialize Admin Queue Attributes Philippe Mathieu-Daudé
2020-10-29  9:32 ` Philippe Mathieu-Daudé [this message]
2020-10-29  9:32 ` [PATCH-for-5.2 v2 16/25] block/nvme: Simplify nvme_cmd_sync() Philippe Mathieu-Daudé
2020-10-30 14:25   ` Stefan Hajnoczi
2020-10-29  9:32 ` [PATCH-for-5.2 v2 17/25] block/nvme: Set request_alignment at initialization Philippe Mathieu-Daudé
2020-10-29  9:32 ` [PATCH-for-5.2 v2 18/25] block/nvme: Correct minimum device page size Philippe Mathieu-Daudé
2020-10-29  9:33 ` [PATCH-for-5.2 v2 19/25] block/nvme: Change size and alignment of IDENTIFY response buffer Philippe Mathieu-Daudé
2020-10-29  9:33 ` [PATCH-for-5.2 v2 20/25] block/nvme: Change size and alignment of queue Philippe Mathieu-Daudé
2020-10-29  9:33 ` [PATCH-for-5.2 v2 21/25] block/nvme: Change size and alignment of prp_list_pages Philippe Mathieu-Daudé
2020-10-29  9:33 ` [PATCH-for-5.2 v2 22/25] block/nvme: Align iov's va and size on host page size Philippe Mathieu-Daudé
2020-10-29  9:33 ` [PATCH-for-5.2 v2 23/25] block/nvme: Fix use of write-only doorbells page on Aarch64 arch Philippe Mathieu-Daudé
2020-10-29  9:33 ` [PATCH-for-5.2 v2 24/25] block/nvme: Fix nvme_submit_command() on big-endian host Philippe Mathieu-Daudé
2020-10-30 13:57   ` Stefan Hajnoczi
2020-10-29  9:33 ` [PATCH-for-6.0 v2 25/25] block/nvme: Simplify Completion Queue Command Identifier field use Philippe Mathieu-Daudé
2020-10-30 14:00   ` Stefan Hajnoczi
2020-10-30 14:53     ` Philippe Mathieu-Daudé
2020-11-03 17:14 ` [PATCH-for-5.2 v2 00/25] block/nvme: Fix Aarch64 or big-endian hosts Stefan Hajnoczi

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=20201029093306.1063879-16-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.