All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: "Jason Wang" <jasowang@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Bartosz Golaszewski" <bgolaszewski@baylibre.com>,
	"Vincent Guittot" <vincent.guittot@linaro.org>,
	"Jean-Philippe Brucker" <jean-philippe@linaro.org>,
	"Bill Mills" <bill.mills@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Enrico Weigelt, metux IT consult" <info@metux.net>,
	virtio-dev@lists.oasis-open.org,
	"Geert Uytterhoeven" <geert@linux-m68k.org>
Subject: Re: [PATCH V5 2/2] virtio-gpio: Add support for interrupts
Date: Tue, 20 Jul 2021 13:23:37 +0530	[thread overview]
Message-ID: <20210720075337.k6qxlsru2ot2odb6@vireshk-i7> (raw)
In-Reply-To: <CAK8P3a1FqQ7VzVNWAjvwBv3d84OUa3VwF5a+sHRvrphNuUAWfQ@mail.gmail.com>

On 20-07-21, 09:17, Arnd Bergmann wrote:
> I don't think you can have a message for more than one line here,
> that would mess up the synchronization as then you have to
> keep double accounting of which gpios are already pending
> on each side.

Yes.

> The most sensible way I see this can be done is to have a message
> per line, and have it as a token that is either on the device or the
> driver side at any point. When the driver has sent the token over
> to the device, the irq is armed, and when the device replies, it is
> implicitly masked.

I like the idea in general but at this point I am not very sure how it
will work. Looking at kernel (and qemu) side implementations, what
really transfers between device and driver is a series of buffers
(marked as in or out sgs). Now these are either device writable or
driver. I am not sure if the device is required to write anything here
to the buffer, it can simply return the buffer as is and so we can
make it driver writable only, i.e. only 1 sg element required.

> Ideally this could even replace the VIRTIO_GPIO_MSG_IRQ_TYPE,
> VIRTIO_GPIO_MSG_IRQ_MASK

Maybe yes.

> and VIRTIO_GPIO_MSG_IRQ_UNMASK

I think we would still require some kind of unmasking here as the
driver would have already sent the buffer to the device and wants the
ownership back, otherwise it may hit an interrupt later on.

Although I would like to keep the three routines separate, just to be
robust here. For example what will we do if the user does this (yes it
won't do it, but I am trying to handle the corner cases well):

1. irq-type-edge-falling
2. irq-unmask
3. irq-type-edge-both

Since we would have already sent the buffer at (2), we can't do (3)
without getting the buffer back.

Tying everything with availability of the buffer itself makes it kind
of messy.

> messages with a single message type on the interrupt virtqueue:
> 
> struct virtio_gpio_irq_event {
>       __le16 line;
>       __u8 type;
>       __u8 status;
> }
> 
> When the driver wants an event on a gpio line, it enqueues this
> message to the virtqueue, and then the device either adds the
> corresponding file descriptor to its poll table, or replies immediately
> with one of these status words:
> 
> - request not supported
> - level interrupt is still active (line remains at requested level)
> - edge interrupt has happened since last reply

-- 
viresh


  reply	other threads:[~2021-07-20  7:53 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-16  7:39 [PATCH V5 0/2] virtio: Add specification for virtio-gpio Viresh Kumar
2021-07-16  7:39 ` [PATCH V5 1/2] virtio-gpio: Add the device specification Viresh Kumar
2021-07-16  8:23   ` Arnd Bergmann
2021-07-16 16:26     ` Viresh Kumar
2021-07-16 18:20       ` Arnd Bergmann
2021-07-19  9:29         ` Viresh Kumar
2021-07-19 10:40           ` [virtio-dev] " Arnd Bergmann
2021-07-19 10:50             ` Viresh Kumar
2021-07-19 11:48             ` Geert Uytterhoeven
2021-07-19  7:32       ` Viresh Kumar
2021-07-16  9:13   ` Geert Uytterhoeven
2021-07-16 15:43     ` Viresh Kumar
2021-07-16 15:22   ` Michael S. Tsirkin
2021-07-16 15:41     ` Viresh Kumar
2021-07-16  7:39 ` [virtio-dev] [PATCH V5 2/2] virtio-gpio: Add support for interrupts Viresh Kumar
2021-07-16  9:02   ` Arnd Bergmann
2021-07-16 15:17     ` [virtio-dev] " Viresh Kumar
2021-07-16 16:19       ` Arnd Bergmann
2021-07-16 16:50         ` Viresh Kumar
2021-07-16 18:49           ` Arnd Bergmann
2021-07-20  5:47             ` Viresh Kumar
2021-07-20  7:01               ` Arnd Bergmann
2021-07-20  7:11                 ` Viresh Kumar
2021-07-20  7:22                   ` Arnd Bergmann
2021-07-19 10:24   ` Viresh Kumar
2021-07-19 12:00     ` Arnd Bergmann
2021-07-20  6:11       ` Viresh Kumar
2021-07-20  7:17         ` Arnd Bergmann
2021-07-20  7:53           ` Viresh Kumar [this message]
2021-07-20  8:10             ` Arnd Bergmann
2021-07-20  8:42               ` Viresh Kumar
2021-07-20  9:50             ` Michael S. Tsirkin
2021-07-19 15:11     ` Michael S. Tsirkin
2021-07-20  4:19       ` Viresh Kumar
2021-07-16  9:57 ` [PATCH V5 0/2] virtio: Add specification for virtio-gpio Arnd Bergmann
2021-07-16 16:57   ` Viresh Kumar

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=20210720075337.k6qxlsru2ot2odb6@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=arnd@kernel.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=bill.mills@linaro.org \
    --cc=cohuck@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=info@metux.net \
    --cc=jasowang@redhat.com \
    --cc=jean-philippe@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=mst@redhat.com \
    --cc=vincent.guittot@linaro.org \
    --cc=virtio-dev@lists.oasis-open.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.