From: John Levon <levon@movementarian.org>
To: Klaus Jensen <its@irrelevant.dk>
Cc: Keith Busch <kbusch@kernel.org>,
Jinhao Fan <fanjinhao21s@ict.ac.cn>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] hw/nvme: Implement shadow doorbell buffer support
Date: Wed, 15 Jun 2022 11:11:51 +0100 [thread overview]
Message-ID: <YqmwZ/FGIROp5ds7@movementarian.org> (raw)
In-Reply-To: <YqmnTmxpYOeupgnt@apples>
On Wed, Jun 15, 2022 at 11:33:02AM +0200, Klaus Jensen wrote:
> > BTW I'm surprised that this patch has just this:
> >
> > +static void nvme_update_sq_eventidx(const NvmeSQueue *sq)
> > +{
> > + pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &sq->tail,
> > + sizeof(sq->tail));
> > +}
> >
> > Isn't this racy against the driver? Compare
> > https://github.com/spdk/spdk/blob/master/lib/nvmf/vfio_user.c#L1317
> >
> > thanks
> > john
>
> QEMU has full memory barriers on dma read/write, so I believe this is
> safe?
But don't you need to re-read the tail still, for example:
driver device
eventidx is 3
write 4 to tail
read tail of 4
write 5 to tail
read eventidx of 3
nvme_dbbuf_need_event (1)
set eventidx to 4
go to sleep
at (1), our tail update of 4->5 doesn't straddle the eventidx, so we don't send
any MMIO, and the device won't wake up. This is why the above code checks the
tail twice for any concurrent update.
regards
john
next prev parent reply other threads:[~2022-06-15 10:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-08 1:36 [PATCH 0/2] hw/nvme: Add shadow doorbell buffer support Jinhao Fan
2022-06-08 1:36 ` [PATCH 1/2] hw/nvme: Implement " Jinhao Fan
2022-06-08 20:55 ` Klaus Jensen
2022-06-09 1:49 ` Jinhao Fan
2022-06-09 14:29 ` Keith Busch
2022-06-09 15:52 ` John Levon
2022-06-09 17:27 ` Klaus Jensen
2022-06-09 17:50 ` John Levon
2022-06-12 11:40 ` Jinhao Fan
2022-06-13 21:15 ` Keith Busch
2022-06-14 7:24 ` Jinhao Fan
2022-06-14 15:41 ` Keith Busch
2022-06-15 3:58 ` Jinhao Fan
2022-06-15 9:38 ` Klaus Jensen
2022-06-15 14:52 ` Jinhao Fan
2022-06-15 8:48 ` Klaus Jensen
2022-06-15 9:07 ` John Levon
2022-06-15 9:33 ` Klaus Jensen
2022-06-15 10:11 ` John Levon [this message]
2022-06-15 11:22 ` Jinhao Fan
2022-06-15 11:45 ` John Levon
2022-06-08 1:36 ` [PATCH 2/2] hw/nvme: Add trace events for shadow doorbell buffer Jinhao Fan
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=YqmwZ/FGIROp5ds7@movementarian.org \
--to=levon@movementarian.org \
--cc=fanjinhao21s@ict.ac.cn \
--cc=its@irrelevant.dk \
--cc=kbusch@kernel.org \
--cc=qemu-devel@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).