All of lore.kernel.org
 help / color / mirror / Atom feed
From: "André Przywara" <andre.przywara@arm.com>
To: Oleksandr <olekstysh@gmail.com>, Julien Grall <julien@xen.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Oleksandr Andrushchenko" <andr2000@gmail.com>,
	"Bertrand Marquis" <Bertrand.Marquis@arm.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	alex.bennee@linaro.org, "Artem Mygaiev" <joculator@gmail.com>
Subject: Re: Virtio in Xen on Arm (based on IOREQ concept)
Date: Tue, 21 Jul 2020 18:02:55 +0100	[thread overview]
Message-ID: <b5faad02-34a5-eb58-1da9-f7852a817281@arm.com> (raw)
In-Reply-To: <e7bbc9d6-648e-4d2a-e981-15743a628b1f@gmail.com>

On 21/07/2020 17:09, Oleksandr wrote:
> 
> On 21.07.20 17:58, André Przywara wrote:
>> On 21/07/2020 15:52, Oleksandr wrote:
>>> On 21.07.20 17:32, André Przywara wrote:
>>>> On 21/07/2020 14:43, Julien Grall wrote:
>>> Hello Andre, Julien
>>>
>>>
>>>>> (+ Andre)
>>>>>
>>>>> Hi Oleksandr,
>>>>>
>>>>> On 21/07/2020 13:26, Oleksandr wrote:
>>>>>> On 20.07.20 23:38, Stefano Stabellini wrote:
>>>>>>> For instance, what's your take on notifications with virtio-mmio?
>>>>>>> How
>>>>>>> are they modelled today? Are they good enough or do we need MSIs?
>>>>>> Notifications are sent from device (backend) to the driver (frontend)
>>>>>> using interrupts. Additional DM function was introduced for that
>>>>>> purpose xendevicemodel_set_irq_level() which results in
>>>>>> vgic_inject_irq() call.
>>>>>>
>>>>>> Currently, if device wants to notify a driver it should trigger the
>>>>>> interrupt by calling that function twice (high level at first, then
>>>>>> low level).
>>>>> This doesn't look right to me. Assuming the interrupt is trigger when
>>>>> the line is high-level, the backend should only issue the hypercall
>>>>> once
>>>>> to set the level to high. Once the guest has finish to process all the
>>>>> notifications the backend would then call the hypercall to lower the
>>>>> interrupt line.
>>>>>
>>>>> This means the interrupts should keep firing as long as the interrupt
>>>>> line is high.
>>>>>
>>>>> It is quite possible that I took some shortcut when implementing the
>>>>> hypercall, so this should be corrected before anyone start to rely on
>>>>> it.
>>>> So I think the key question is: are virtio interrupts level or edge
>>>> triggered? Both QEMU and kvmtool advertise virtio-mmio interrupts as
>>>> edge-triggered.
>>>>   From skimming through the virtio spec I can't find any explicit
>>>> mentioning of the type of IRQ, but the usage of MSIs indeed hints at
>>>> using an edge property. Apparently reading the PCI ISR status register
>>>> clears it, which again sounds like edge. For virtio-mmio the driver
>>>> needs to explicitly clear the interrupt status register, which again
>>>> says: edge (as it's not the device clearing the status).
>>>>
>>>> So the device should just notify the driver once, which would cause one
>>>> vgic_inject_irq() call. It would be then up to the driver to clear up
>>>> that status, by reading PCI ISR status or writing to virtio-mmio's
>>>> interrupt-acknowledge register.
>>>>
>>>> Does that make sense?
>>> When implementing Xen backend, I didn't have an already working example
>>> so only guessed. I looked how kvmtool behaved when actually triggering
>>> the interrupt on Arm [1].
>>>
>>> Taking into the account that Xen PoC on Arm advertises [2] the same irq
>>> type (TYPE_EDGE_RISING) as kvmtool [3] I decided to follow the model of
>>> triggering an interrupt. Could you please explain, is this wrong?
>> Yes, kvmtool does a double call needlessly (on x86, ppc and arm, mips is
>> correct).
>> I just chased it down in the kernel, a KVM_IRQ_LINE ioctl with level=low
>> is ignored when the target IRQ is configured as edge (which it is,
>> because the DT says so), check vgic_validate_injection() in the kernel.
>>
>> So you should only ever need one call to set the line "high" (actually:
>> trigger the edge pulse).
> 
> Got it, thanks for the explanation. Have just removed an extra action
> (setting low level) and checked.
> 

Just for the records: the KVM API documentation explicitly mentions:
"Note that edge-triggered interrupts require the level to be set to 1
and then back to 0." So kvmtool is just following the book.

Setting it to 0 still does nothing *on ARM*, and the x86 IRQ code is far
to convoluted to easily judge what's really happening here. For MSIs at
least it's equally ignored.

So I guess a clean implementation in Xen does not need two calls, but
some folks with understanding of x86 IRQ handling in Xen should confirm.

Cheers,
Andre.


  reply	other threads:[~2020-07-21 17:04 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-17 14:11 Virtio in Xen on Arm (based on IOREQ concept) Oleksandr Tyshchenko
2020-07-17 15:00 ` Roger Pau Monné
2020-07-17 18:34   ` Oleksandr
2020-07-20  9:17     ` Roger Pau Monné
2020-07-20  9:40       ` Julien Grall
2020-07-20 10:20         ` Roger Pau Monné
2020-07-20 20:37           ` Stefano Stabellini
2020-07-21 12:31             ` Julien Grall
2020-07-21 13:25               ` Roger Pau Monné
2020-07-21 13:32                 ` Julien Grall
2020-07-21 13:40                   ` Roger Pau Monné
2020-07-21 14:09               ` Alex Bennée
2020-07-21 16:14                 ` Stefano Stabellini
2020-07-20 10:56       ` Oleksandr
2020-07-20 11:09         ` Roger Pau Monné
2020-07-20 20:40           ` Stefano Stabellini
2020-07-21 12:43             ` Oleksandr
2020-07-20 20:38     ` Stefano Stabellini
2020-07-21 12:26       ` Oleksandr
2020-07-21 13:43         ` Julien Grall
2020-07-21 14:32           ` André Przywara
2020-07-21 14:52             ` Oleksandr
2020-07-21 14:58               ` André Przywara
2020-07-21 16:09                 ` Oleksandr
2020-07-21 17:02                   ` André Przywara [this message]
2020-07-21 13:22       ` Julien Grall
2020-07-21 14:15         ` Alex Bennée
2020-07-21 14:40           ` Julien Grall
2020-07-21 16:42             ` Stefano Stabellini
2020-07-21 14:27     ` Julien Grall
2020-07-21 17:24       ` Oleksandr
2020-07-21 18:16       ` Oleksandr
2020-07-21 21:12         ` Julien Grall
2020-07-22  8:21           ` Roger Pau Monné
2020-07-22 10:47             ` Julien Grall
2020-07-22 11:10               ` Roger Pau Monné
2020-07-22 11:17                 ` Julien Grall
2020-07-22 11:37                   ` Roger Pau Monné

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=b5faad02-34a5-eb58-1da9-f7852a817281@arm.com \
    --to=andre.przywara@arm.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=alex.bennee@linaro.org \
    --cc=andr2000@gmail.com \
    --cc=joculator@gmail.com \
    --cc=julien@xen.org \
    --cc=olekstysh@gmail.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 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.