LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
Viresh Kumar <vireshk@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Cornelia Huck <cohuck@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"open list:DRM DRIVER FOR QEMU'S CIRRUS DEVICE"
<virtualization@lists.linux-foundation.org>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Marc Zyngier <maz@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Stratos Mailing List <stratos-dev@op-lists.linaro.org>,
"Enrico Weigelt, metux IT consult" <info@metux.net>,
Jason Wang <jasowang@redhat.com>
Subject: Re: [Stratos-dev] [PATCH V4 2/2] gpio: virtio: Add IRQ support
Date: Fri, 6 Aug 2021 13:14:44 +0530 [thread overview]
Message-ID: <20210806074444.zsxwb2pmgjcq2dl2@vireshk-i7> (raw)
In-Reply-To: <CAK8P3a0kbmPLGCBrjAv7-dW=JWq-pdSBeGUHCxUFmMKvKhCg7w@mail.gmail.com>
On 05-08-21, 15:10, Arnd Bergmann wrote:
> I hope this can still be simplified by working out better which state
> transitions are needed exactly. In particular, I would expect that we
> can get away with not sending a VIRTIO_GPIO_MSG_IRQ_TYPE
> for 'mask' state changes at all, but use that only for forcing 'enabled'
> state changes.
Something like this ?
struct vgpio_irq_line {
u8 type;
bool masked;
bool update_pending;
bool queued;
struct virtio_gpio_irq_request ireq ____cacheline_aligned;
struct virtio_gpio_irq_response ires ____cacheline_aligned;
};
static void virtio_gpio_irq_disable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
irq_line->masked = true;
irq_line->update_pending = true;
}
static void virtio_gpio_irq_enable(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
irq_line->masked = false;
irq_line->update_pending = true;
/* Queue the buffer unconditionally on enable */
virtio_gpio_irq_prepare(vgpio, d->hwirq);
}
static void virtio_gpio_irq_mask(struct irq_data *d)
{
/* Nothing to do here */
}
static void virtio_gpio_irq_unmask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
/* Queue the buffer unconditionally on unmask */
virtio_gpio_irq_prepare(vgpio, d->hwirq);
}
static int virtio_gpio_irq_set_type(struct irq_data *d, unsigned int type)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
switch (type) {
case IRQ_TYPE_NONE:
type = VIRTIO_GPIO_IRQ_TYPE_NONE;
break;
case IRQ_TYPE_EDGE_RISING:
type = VIRTIO_GPIO_IRQ_TYPE_EDGE_RISING;
break;
case IRQ_TYPE_EDGE_FALLING:
type = VIRTIO_GPIO_IRQ_TYPE_EDGE_FALLING;
break;
case IRQ_TYPE_EDGE_BOTH:
type = VIRTIO_GPIO_IRQ_TYPE_EDGE_BOTH;
break;
case IRQ_TYPE_LEVEL_LOW:
type = VIRTIO_GPIO_IRQ_TYPE_LEVEL_LOW;
break;
case IRQ_TYPE_LEVEL_HIGH:
type = VIRTIO_GPIO_IRQ_TYPE_LEVEL_HIGH;
break;
default:
dev_err(&vgpio->vdev->dev, "unsupported irq type: %u\n", type);
return -EINVAL;
}
irq_line->type = type;
irq_line->update_pending = true;
return 0;
}
static void update_irq_type(struct virtio_gpio *vgpio, u16 gpio, u8 type)
{
virtio_gpio_req(vgpio, VIRTIO_GPIO_MSG_IRQ_TYPE, gpio, type, NULL);
}
static void virtio_gpio_irq_bus_lock(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
mutex_lock(&vgpio->irq_lock);
}
static void virtio_gpio_irq_bus_sync_unlock(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct virtio_gpio *vgpio = gpiochip_get_data(gc);
struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
u8 type = irq_line->masked ? VIRTIO_GPIO_IRQ_TYPE_NONE : irq_line->type;
if (irq_line->update_pending) {
irq_line->update_pending = false;
update_irq_type(vgpio, d->hwirq, type);
}
mutex_unlock(&vgpio->irq_lock);
}
static struct irq_chip vgpio_irq_chip = {
.name = "virtio-gpio",
.irq_enable = virtio_gpio_irq_enable,
.irq_disable = virtio_gpio_irq_disable,
.irq_mask = virtio_gpio_irq_mask,
.irq_unmask = virtio_gpio_irq_unmask,
.irq_set_type = virtio_gpio_irq_set_type,
/* These are required to implement irqchip for slow busses */
.irq_bus_lock = virtio_gpio_irq_bus_lock,
.irq_bus_sync_unlock = virtio_gpio_irq_bus_sync_unlock,
};
> One part that I think is missing though is remembering the case
> when an eventq message came in after an interrupt got masked
> when the message was already armed. In this case, the
> virtio_gpio_event_vq() function would not call the irq handler,
> but the subsequent "unmask" callback would need to arrange
> having it called.
I will come back to this.
--
viresh
next prev parent reply other threads:[~2021-08-06 7:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-03 11:36 [PATCH V4 0/2] gpio: Add virtio based driver Viresh Kumar
2021-08-03 11:36 ` [PATCH V4 1/2] gpio: Add virtio-gpio driver Viresh Kumar
2021-08-03 11:36 ` [PATCH V4 2/2] gpio: virtio: Add IRQ support Viresh Kumar
2021-08-03 15:01 ` Arnd Bergmann
2021-08-04 7:05 ` Viresh Kumar
2021-08-04 8:27 ` Arnd Bergmann
2021-08-05 7:05 ` Viresh Kumar
2021-08-05 11:26 ` Viresh Kumar
[not found] ` <0100017b1610f711-c53c79f2-9e28-4c45-bb42-8db09688b18e-000000@email.amazonses.com>
2021-08-05 12:03 ` [Stratos-dev] " Arnd Bergmann
2021-08-05 12:49 ` Viresh Kumar
2021-08-05 13:10 ` Arnd Bergmann
2021-08-06 7:44 ` Viresh Kumar [this message]
[not found] ` <0100017b1a6c0a05-e41dc16c-b326-4017-a63d-a24a6c1fde70-000000@email.amazonses.com>
2021-08-06 8:00 ` Arnd Bergmann
2021-08-09 7:30 ` Viresh Kumar
2021-08-09 7:55 ` Arnd Bergmann
2021-08-09 10:46 ` Viresh Kumar
[not found] ` <0100017b2a85eaf8-08b905fc-89f7-43a4-857e-070ca9691ce1-000000@email.amazonses.com>
2021-08-09 11:19 ` Arnd Bergmann
2021-08-10 7:35 ` 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=20210806074444.zsxwb2pmgjcq2dl2@vireshk-i7 \
--to=viresh.kumar@linaro.org \
--cc=arnd@kernel.org \
--cc=bgolaszewski@baylibre.com \
--cc=cohuck@redhat.com \
--cc=geert@linux-m68k.org \
--cc=info@metux.net \
--cc=jasowang@redhat.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=mst@redhat.com \
--cc=stratos-dev@op-lists.linaro.org \
--cc=tglx@linutronix.de \
--cc=vireshk@kernel.org \
--cc=virtualization@lists.linux-foundation.org \
--subject='Re: [Stratos-dev] [PATCH V4 2/2] gpio: virtio: Add IRQ support' \
/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
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).