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>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Klaus Jensen" <its@irrelevant.dk>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH 3/3] block/nvme: Pair doorbell registers
Date: Fri,  4 Sep 2020 14:41:30 +0200	[thread overview]
Message-ID: <20200904124130.583838-4-philmd@redhat.com> (raw)
In-Reply-To: <20200904124130.583838-1-philmd@redhat.com>

For each queue doorbell registers are paired as:
- Submission Queue Tail Doorbell
- Completion Queue Head Doorbell

Reflect that in the NVMeRegs structure, and adapt
nvme_create_queue_pair() accordingly.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 block/nvme.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/block/nvme.c b/block/nvme.c
index a216cc407f6..f4f27b6da7d 100644
--- a/block/nvme.c
+++ b/block/nvme.c
@@ -84,7 +84,10 @@ typedef struct {
 /* Memory mapped registers */
 typedef volatile struct {
     NvmeBar ctrl;
-    uint32_t doorbells[];
+    struct {
+        uint32_t sq_tail;
+        uint32_t cq_head;
+    } doorbells[];
 } NVMeRegs;
 
 #define INDEX_ADMIN     0
@@ -244,14 +247,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s,
         error_propagate(errp, local_err);
         goto fail;
     }
-    q->sq.doorbell = &s->regs->doorbells[idx * 2 * s->doorbell_scale];
+    q->sq.doorbell = &s->regs->doorbells[idx * s->doorbell_scale].sq_tail;
 
     nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         goto fail;
     }
-    q->cq.doorbell = &s->regs->doorbells[(idx * 2 + 1) * s->doorbell_scale];
+    q->cq.doorbell = &s->regs->doorbells[idx * s->doorbell_scale].cq_head;
 
     return q;
 fail:
-- 
2.26.2



  parent reply	other threads:[~2020-09-04 12:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 12:41 [PATCH 0/3] block/nvme: Use NvmeBar structure from "block/nvme.h" Philippe Mathieu-Daudé
2020-09-04 12:41 ` [PATCH 1/3] block/nvme: Group controller registers in NVMeRegs structure Philippe Mathieu-Daudé
2020-09-04 12:41 ` [PATCH 2/3] block/nvme: Use generic NvmeBar structure Philippe Mathieu-Daudé
2020-09-04 12:41 ` Philippe Mathieu-Daudé [this message]
2020-09-04 14:57 ` [PATCH 0/3] block/nvme: Use NvmeBar structure from "block/nvme.h" Fam Zheng
2020-09-04 15:28 ` Klaus Jensen
2020-09-07 10:54 ` Kevin Wolf

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=20200904124130.583838-4-philmd@redhat.com \
    --to=philmd@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.