From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: Keith Busch <kbusch@kernel.org>, Klaus Jensen <its@irrelevant.dk>,
Jinhao Fan <fanjinhao21s@ict.ac.cn>,
qemu-block@nongnu.org, Klaus Jensen <k.jensen@samsung.com>,
qemu-stable@nongnu.org, qemu-riscv@nongnu.org,
Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH v2 3/3] hw/nvme: fix missing cq eventidx update
Date: Thu, 8 Dec 2022 13:26:42 +0100 [thread overview]
Message-ID: <20221208122642.80574-4-its@irrelevant.dk> (raw)
In-Reply-To: <20221208122642.80574-1-its@irrelevant.dk>
From: Klaus Jensen <k.jensen@samsung.com>
Prior to reading the shadow doorbell cq head, we have to update the
eventidx. Otherwise, we risk that the driver will skip an mmio doorbell
write. This happens on riscv64, as reported by Guenter.
Adding the missing update to the cq eventidx fixes the issue.
Fixes: 3f7fe8de3d49 ("hw/nvme: Implement shadow doorbell buffer support")
Cc: qemu-stable@nongnu.org
Cc: qemu-riscv@nongnu.org
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
hw/nvme/ctrl.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index cfab21b3436e..f6cc766aba4a 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1334,6 +1334,14 @@ static inline void nvme_blk_write(BlockBackend *blk, int64_t offset,
}
}
+static void nvme_update_cq_eventidx(const NvmeCQueue *cq)
+{
+ trace_pci_nvme_update_cq_eventidx(cq->cqid, cq->head);
+
+ pci_dma_write(PCI_DEVICE(cq->ctrl), cq->ei_addr, &cq->head,
+ sizeof(cq->head));
+}
+
static void nvme_update_cq_head(NvmeCQueue *cq)
{
pci_dma_read(PCI_DEVICE(cq->ctrl), cq->db_addr, &cq->head,
@@ -1355,6 +1363,7 @@ static void nvme_post_cqes(void *opaque)
hwaddr addr;
if (n->dbbuf_enabled) {
+ nvme_update_cq_eventidx(cq);
nvme_update_cq_head(cq);
}
--
2.38.1
next prev parent reply other threads:[~2022-12-08 12:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-08 12:26 [PATCH v2 0/3] hw/nvme: shadow doorbells broken on riscv64 Klaus Jensen
2022-12-08 12:26 ` [PATCH v2 1/3] hw/nvme: use QOM accessors Klaus Jensen
2022-12-08 12:35 ` Philippe Mathieu-Daudé
2022-12-08 12:26 ` [PATCH v2 2/3] hw/nvme: rename shadow doorbell related trace events Klaus Jensen
2022-12-08 12:37 ` Philippe Mathieu-Daudé
2022-12-08 12:26 ` Klaus Jensen [this message]
2022-12-08 18:37 ` [PATCH v2 3/3] hw/nvme: fix missing cq eventidx update Guenter Roeck
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=20221208122642.80574-4-its@irrelevant.dk \
--to=its@irrelevant.dk \
--cc=fanjinhao21s@ict.ac.cn \
--cc=k.jensen@samsung.com \
--cc=kbusch@kernel.org \
--cc=linux@roeck-us.net \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-stable@nongnu.org \
/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).