All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jinhao Fan <fanjinhao21s@ict.ac.cn>
To: Klaus Jensen <its@irrelevant.dk>
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>
Subject: Re: [PATCH v4] hw/nvme: Use ioeventfd to handle doorbell updates
Date: Wed, 27 Jul 2022 16:16:32 +0800	[thread overview]
Message-ID: <42878984-948E-4D65-8CA0-293564640F35@ict.ac.cn> (raw)
In-Reply-To: <YuDkBkrqXaosJbRM@apples>

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.


  reply	other threads:[~2022-07-27  8:20 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 [this message]
2022-07-27  8:21                       ` Klaus Jensen
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=42878984-948E-4D65-8CA0-293564640F35@ict.ac.cn \
    --to=fanjinhao21s@ict.ac.cn \
    --cc=hreitz@redhat.com \
    --cc=its@irrelevant.dk \
    --cc=kbusch@kernel.org \
    --cc=kwolf@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.