All of lore.kernel.org
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: Jinhao Fan <fanjinhao21s@ict.ac.cn>
Cc: qemu-devel <qemu-devel@nongnu.org>,
	kbusch@kernel.org, Kevin Wolf <kwolf@redhat.com>,
	Hanna Reitz <hreitz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH v4] hw/nvme: Use ioeventfd to handle doorbell updates
Date: Wed, 27 Jul 2022 10:21:39 +0200	[thread overview]
Message-ID: <YuD1k54rwj1whnE6@apples> (raw)
In-Reply-To: <42878984-948E-4D65-8CA0-293564640F35@ict.ac.cn>

[-- Attachment #1: Type: text/plain, Size: 2775 bytes --]

On Jul 27 16:16, Jinhao Fan wrote:
> at 3:06 PM, Klaus Jensen <its@irrelevant.dk> wrote:
> 
> > On Jul 26 14:08, Klaus Jensen wrote:
> >> Alright. Forget about the iommu, that was just a coincidence.
> >> 
> >> This patch seems to fix it. I guess it is the
> >> event_notifier_set_handler(..., NULL) that does the trick, but I'd like
> >> to understand why ;)
> >> 
> >> 
> >> diff --git i/hw/nvme/ctrl.c w/hw/nvme/ctrl.c
> >> index 533ad14e7a61..3bc3c6bfbe78 100644
> >> --- i/hw/nvme/ctrl.c
> >> +++ w/hw/nvme/ctrl.c
> >> @@ -4238,7 +4238,9 @@ static void nvme_cq_notifier(EventNotifier *e)
> >>     NvmeCQueue *cq = container_of(e, NvmeCQueue, notifier);
> >>     NvmeCtrl *n = cq->ctrl;
> >> 
> >> -    event_notifier_test_and_clear(&cq->notifier);
> >> +    if (!event_notifier_test_and_clear(e)) {
> >> +        return;
> >> +    }
> >> 
> >>     nvme_update_cq_head(cq);
> >> 
> >> @@ -4275,7 +4277,9 @@ static void nvme_sq_notifier(EventNotifier *e)
> >> {
> >>     NvmeSQueue *sq = container_of(e, NvmeSQueue, notifier);
> >> 
> >> -    event_notifier_test_and_clear(&sq->notifier);
> >> +    if (!event_notifier_test_and_clear(e)) {
> >> +        return;
> >> +    }
> >> 
> 
> Yes, virtio also checks the return value of event_notifier_test_and_clear().
> 
> >>     nvme_process_sq(sq);
> >> }
> >> @@ -4307,6 +4311,8 @@ static void nvme_free_sq(NvmeSQueue *sq, NvmeCtrl *n)
> >>     if (sq->ioeventfd_enabled) {
> >>         memory_region_del_eventfd(&n->iomem,
> >>                                   0x1000 + offset, 4, false, 0, &sq->notifier);
> >> +        event_notifier_set_handler(&sq->notifier, NULL);
> >> +        nvme_sq_notifier(&sq->notifier);
> >>         event_notifier_cleanup(&sq->notifier);
> >>     }
> >>     g_free(sq->io_req);
> >> @@ -4697,6 +4703,8 @@ static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n)
> >>     if (cq->ioeventfd_enabled) {
> >>         memory_region_del_eventfd(&n->iomem,
> >>                                   0x1000 + offset, 4, false, 0, &cq->notifier);
> >> +        event_notifier_set_handler(&cq->notifier, NULL);
> >> +        nvme_cq_notifier(&cq->notifier);
> >>         event_notifier_cleanup(&cq->notifier);
> >>     }
> >>     if (msix_enabled(&n->parent_obj)) {
> > 
> 
> I’m a bit messed up here. I will further check how virtio handles queue deletion today.

Yeah, the API documentation is not exactly exhaustive on the specifics
here, so I kinda inferred this from the virtio code.

If this is the way to do it, then I think I will follow up with a patch
for the event notifier api with a not on how teardown should be done.

Paolo - get_maintainer.pl spits you out for main-loop.h. Any chance you
could shed some light on this?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-07-27  8:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05 14:24 [PATCH v4] hw/nvme: Use ioeventfd to handle doorbell updates Jinhao Fan
2022-07-05 17:11 ` Klaus Jensen
2022-07-05 18:43   ` Keith Busch
2022-07-06 11:34     ` Jinhao Fan
2022-07-07  5:51       ` Klaus Jensen
2022-07-07  8:50         ` Jinhao Fan
2022-07-06 10:57   ` Jinhao Fan
2022-07-09  3:06 ` Jinhao Fan
2022-07-12 12:23   ` Klaus Jensen
2022-07-14  5:35     ` Klaus Jensen
2022-07-25 20:55 ` Klaus Jensen
2022-07-26  7:35   ` Jinhao Fan
2022-07-26  7:41     ` Klaus Jensen
2022-07-26  7:55       ` Jinhao Fan
2022-07-26  9:19         ` Klaus Jensen
2022-07-26 10:09           ` Klaus Jensen
2022-07-26 11:24             ` Klaus Jensen
2022-07-26 11:32               ` Klaus Jensen
2022-07-26 12:08                 ` Klaus Jensen
2022-07-27  7:06                   ` Klaus Jensen
2022-07-27  8:16                     ` Jinhao Fan
2022-07-27  8:21                       ` Klaus Jensen [this message]
2022-07-27 15:09                         ` Jinhao Fan
2022-07-26 12:35 ` 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=YuD1k54rwj1whnE6@apples \
    --to=its@irrelevant.dk \
    --cc=fanjinhao21s@ict.ac.cn \
    --cc=hreitz@redhat.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --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.