From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>,
Klaus Jensen <k.jensen@samsung.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>,
Jesper Devantier <foss@defmacro.it>,
qemu-block@nongnu.org
Subject: [PULL 05/11] hw/nvme: split nvme_init_sq/nvme_init_cq into helpers
Date: Tue, 7 Jul 2026 00:44:17 +0200 [thread overview]
Message-ID: <20260706224426.14156-6-its@irrelevant.dk> (raw)
In-Reply-To: <20260706224426.14156-1-its@irrelevant.dk>
From: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
We will make a benefit from this split in later patches.
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/ctrl.c | 59 +++++++++++++++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 22 deletions(-)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index d2096eb49d97..386a698ba858 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -4869,18 +4869,14 @@ static uint16_t nvme_del_sq(NvmeCtrl *n, NvmeRequest *req)
return NVME_SUCCESS;
}
-static void nvme_init_sq(NvmeSQueue *sq, NvmeCtrl *n, uint64_t dma_addr,
- uint16_t sqid, uint16_t cqid, uint16_t size)
+static void __nvme_init_sq(NvmeSQueue *sq)
{
+ NvmeCtrl *n = sq->ctrl;
+ uint16_t sqid = sq->sqid;
+ uint16_t cqid = sq->cqid;
int i;
NvmeCQueue *cq;
- sq->ctrl = n;
- sq->dma_addr = dma_addr;
- sq->sqid = sqid;
- sq->size = size;
- sq->cqid = cqid;
- sq->head = sq->tail = 0;
sq->io_req = g_new0(NvmeRequest, sq->size);
QTAILQ_INIT(&sq->req_list);
@@ -4910,6 +4906,18 @@ static void nvme_init_sq(NvmeSQueue *sq, NvmeCtrl *n, uint64_t dma_addr,
n->sq[sqid] = sq;
}
+static void nvme_init_sq(NvmeSQueue *sq, NvmeCtrl *n, uint64_t dma_addr,
+ uint16_t sqid, uint16_t cqid, uint16_t size)
+{
+ sq->ctrl = n;
+ sq->dma_addr = dma_addr;
+ sq->sqid = sqid;
+ sq->size = size;
+ sq->cqid = cqid;
+ sq->head = sq->tail = 0;
+ __nvme_init_sq(sq);
+}
+
static uint16_t nvme_create_sq(NvmeCtrl *n, NvmeRequest *req)
{
NvmeSQueue *sq;
@@ -5570,25 +5578,16 @@ static uint16_t nvme_del_cq(NvmeCtrl *n, NvmeRequest *req)
return NVME_SUCCESS;
}
-static void nvme_init_cq(NvmeCQueue *cq, NvmeCtrl *n, uint64_t dma_addr,
- uint16_t cqid, uint16_t vector, uint16_t size,
- uint16_t irq_enabled)
+static void __nvme_init_cq(NvmeCQueue *cq)
{
+ NvmeCtrl *n = cq->ctrl;
PCIDevice *pci = PCI_DEVICE(n);
+ uint16_t cqid = cq->cqid;
- if (msix_present(pci) && irq_enabled) {
- msix_vector_use(pci, vector);
+ if (msix_present(pci) && cq->irq_enabled) {
+ msix_vector_use(pci, cq->vector);
}
- cq->ctrl = n;
- cq->cqid = cqid;
- cq->size = size;
- cq->dma_addr = dma_addr;
- cq->phase = 1;
- cq->irq_enabled = irq_enabled;
- cq->vector = vector;
- cq->head = cq->tail = 0;
- QTAILQ_INIT(&cq->req_list);
QTAILQ_INIT(&cq->sq_list);
if (n->dbbuf_enabled) {
cq->db_addr = n->dbbuf_dbs + (cqid << 3) + (1 << 2);
@@ -5605,6 +5604,22 @@ static void nvme_init_cq(NvmeCQueue *cq, NvmeCtrl *n, uint64_t dma_addr,
&DEVICE(cq->ctrl)->mem_reentrancy_guard);
}
+static void nvme_init_cq(NvmeCQueue *cq, NvmeCtrl *n, uint64_t dma_addr,
+ uint16_t cqid, uint16_t vector, uint16_t size,
+ uint16_t irq_enabled)
+{
+ cq->ctrl = n;
+ cq->cqid = cqid;
+ cq->size = size;
+ cq->dma_addr = dma_addr;
+ cq->phase = 1;
+ cq->irq_enabled = irq_enabled;
+ cq->vector = vector;
+ cq->head = cq->tail = 0;
+ QTAILQ_INIT(&cq->req_list);
+ __nvme_init_cq(cq);
+}
+
static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeRequest *req)
{
NvmeCQueue *cq;
--
2.53.0
next prev parent reply other threads:[~2026-07-06 22:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 22:44 [PULL 00/11] hw/nvme queue Klaus Jensen
2026-07-06 22:44 ` [PULL 01/11] hw/nvme: fix FDP set FDP events Klaus Jensen
2026-07-08 9:37 ` Peter Maydell
2026-07-06 22:44 ` [PULL 02/11] hw/nvme: ensure sgl forward progress Klaus Jensen
2026-07-06 22:44 ` [PULL 03/11] tests/functional/migration: add VM launch/configure hooks Klaus Jensen
2026-07-06 22:44 ` [PULL 04/11] hw/nvme: add migration blockers for non-supported cases Klaus Jensen
2026-07-08 10:11 ` Peter Maydell
2026-07-08 10:18 ` Peter Maydell
2026-07-08 10:23 ` Alexander Mikhalitsyn
2026-07-08 10:27 ` Klaus Jensen
2026-07-08 10:32 ` Alexander Mikhalitsyn
2026-07-06 22:44 ` Klaus Jensen [this message]
2026-07-06 22:44 ` [PULL 06/11] hw/nvme: set CQE.sq_id earlier in nvme_process_sq Klaus Jensen
2026-07-06 22:44 ` [PULL 07/11] hw/nvme: unmap req->sg earlier in nvme_enqueue_req_completion Klaus Jensen
2026-07-06 22:44 ` [PULL 08/11] hw/nvme: add basic live migration support Klaus Jensen
2026-07-06 22:44 ` [PULL 09/11] tests/functional/x86_64: add migration test for NVMe device Klaus Jensen
2026-07-06 22:44 ` [PULL 10/11] tests/qtest/nvme-test: add migration test with full CQ Klaus Jensen
2026-07-06 22:44 ` [PULL 11/11] hw/nvme: add namespace hotplug support Klaus Jensen
2026-07-07 17:11 ` [PULL 00/11] hw/nvme queue 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=20260706224426.14156-6-its@irrelevant.dk \
--to=its@irrelevant.dk \
--cc=aleksandr.mikhalitsyn@futurfusion.io \
--cc=foss@defmacro.it \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=peter.maydell@linaro.org \
--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.