All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: virtio: convert to immutable irq_chip
@ 2026-10-27 12:55 Francesco Valla
  2026-10-27 13:00 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Francesco Valla @ 2026-10-27 12:55 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult, Viresh Kumar, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-gpio, virtualization, linux-kernel, Francesco Valla

The kernel has been warning about non-immutable irq_chips for quite some
time, printing messages such as the following one during initialization:

  gpio gpiochip6: (virtio2): not an immutable chip, please consider fixing it!

Convert the gpio-virtio irq_chip to immutable and add the relevant
helpers. The exposed name is kept the same as before through the
.irq_print_chip callback.

Signed-off-by: Francesco Valla <francesco@valla.it>
---
 drivers/gpio/gpio-virtio.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
index ed6e0e90fa8a..d443b8c0e813 100644
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/seq_file.h>
 #include <linux/spinlock.h>
 #include <linux/virtio_config.h>
 #include <uapi/linux/virtio_gpio.h>
@@ -243,6 +244,8 @@ static void virtio_gpio_irq_enable(struct irq_data *d)
 	struct virtio_gpio *vgpio = gpiochip_get_data(gc);
 	struct vgpio_irq_line *irq_line = &vgpio->irq_lines[d->hwirq];
 
+	gpiochip_enable_irq(gc, d->hwirq);
+
 	raw_spin_lock(&vgpio->eventq_lock);
 	irq_line->disabled = false;
 	irq_line->masked = false;
@@ -265,6 +268,8 @@ static void virtio_gpio_irq_disable(struct irq_data *d)
 	raw_spin_unlock(&vgpio->eventq_lock);
 
 	irq_line->update_pending = true;
+
+	gpiochip_disable_irq(gc, d->hwirq);
 }
 
 static void virtio_gpio_irq_mask(struct irq_data *d)
@@ -532,11 +537,30 @@ static const char **virtio_gpio_get_names(struct virtio_gpio *vgpio,
 	return names;
 }
 
+static void virtio_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
+{
+	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+
+	seq_puts(p, dev_name(gc->parent));
+}
+
+static const struct irq_chip virtio_gpio_irqchip = {
+	.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,
+	.irq_bus_lock = virtio_gpio_irq_bus_lock,
+	.irq_bus_sync_unlock = virtio_gpio_irq_bus_sync_unlock,
+	.irq_print_chip = virtio_gpio_irq_print_chip,
+	.flags = IRQCHIP_IMMUTABLE,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
 static int virtio_gpio_probe(struct virtio_device *vdev)
 {
 	struct device *dev = &vdev->dev;
 	struct virtio_gpio *vgpio;
-	struct irq_chip *gpio_irq_chip;
 	u32 gpio_names_size;
 	u16 ngpio;
 	int ret, i;
@@ -588,26 +612,13 @@ static int virtio_gpio_probe(struct virtio_device *vdev)
 		if (!vgpio->irq_lines)
 			return -ENOMEM;
 
-		gpio_irq_chip = devm_kzalloc(dev, sizeof(*gpio_irq_chip), GFP_KERNEL);
-		if (!gpio_irq_chip)
-			return -ENOMEM;
-
-		gpio_irq_chip->name = dev_name(dev);
-		gpio_irq_chip->irq_enable = virtio_gpio_irq_enable;
-		gpio_irq_chip->irq_disable = virtio_gpio_irq_disable;
-		gpio_irq_chip->irq_mask = virtio_gpio_irq_mask;
-		gpio_irq_chip->irq_unmask = virtio_gpio_irq_unmask;
-		gpio_irq_chip->irq_set_type = virtio_gpio_irq_set_type;
-		gpio_irq_chip->irq_bus_lock = virtio_gpio_irq_bus_lock;
-		gpio_irq_chip->irq_bus_sync_unlock = virtio_gpio_irq_bus_sync_unlock;
-
 		/* The event comes from the outside so no parent handler */
 		vgpio->gc.irq.parent_handler	= NULL;
 		vgpio->gc.irq.num_parents	= 0;
 		vgpio->gc.irq.parents		= NULL;
 		vgpio->gc.irq.default_type	= IRQ_TYPE_NONE;
 		vgpio->gc.irq.handler		= handle_level_irq;
-		vgpio->gc.irq.chip		= gpio_irq_chip;
+		gpio_irq_chip_set_chip(&vgpio->gc.irq, &virtio_gpio_irqchip);
 
 		for (i = 0; i < ngpio; i++) {
 			vgpio->irq_lines[i].type = VIRTIO_GPIO_IRQ_TYPE_NONE;

---
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
change-id: 20261018-virtio-gpio-irqchip-immutable-9b69717cba4c

Best regards,
--  
Francesco Valla <francesco@valla.it>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: virtio: convert to immutable irq_chip
  2026-10-27 12:55 [PATCH] gpio: virtio: convert to immutable irq_chip Francesco Valla
@ 2026-10-27 13:00 ` sashiko-bot
  2026-10-28  4:53 ` Viresh Kumar
  2026-10-28  9:39 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-10-27 13:00 UTC (permalink / raw)
  To: Francesco Valla; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez

> The kernel has been warning about non-immutable irq_chips for quite some
> time, printing messages such as the following one during initialization:
> 
>   gpio gpiochip6: (virtio2): not an immutable chip, please consider fixing it!
> 
> Convert the gpio-virtio irq_chip to immutable and add the relevant
> helpers. The exposed name is kept the same as before through the
> .irq_print_chip callback.
> 
> Signed-off-by: Francesco Valla <francesco@valla.it>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261027-virtio-gpio-irqchip-immutable-v1-1-f64ed13d4567@valla.it?part=1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: virtio: convert to immutable irq_chip
  2026-10-27 12:55 [PATCH] gpio: virtio: convert to immutable irq_chip Francesco Valla
  2026-10-27 13:00 ` sashiko-bot
@ 2026-10-28  4:53 ` Viresh Kumar
  2026-10-28  9:39 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2026-10-28  4:53 UTC (permalink / raw)
  To: Francesco Valla
  Cc: Enrico Weigelt, metux IT consult, Viresh Kumar, Linus Walleij,
	Bartosz Golaszewski, linux-gpio, virtualization, linux-kernel

On 27-10-26, 13:55, Francesco Valla wrote:
> The kernel has been warning about non-immutable irq_chips for quite some
> time, printing messages such as the following one during initialization:
> 
>   gpio gpiochip6: (virtio2): not an immutable chip, please consider fixing it!
> 
> Convert the gpio-virtio irq_chip to immutable and add the relevant
> helpers. The exposed name is kept the same as before through the
> .irq_print_chip callback.
> 
> Signed-off-by: Francesco Valla <francesco@valla.it>
> ---
>  drivers/gpio/gpio-virtio.c | 41 ++++++++++++++++++++++++++---------------
>  1 file changed, 26 insertions(+), 15 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: virtio: convert to immutable irq_chip
  2026-10-27 12:55 [PATCH] gpio: virtio: convert to immutable irq_chip Francesco Valla
  2026-10-27 13:00 ` sashiko-bot
  2026-10-28  4:53 ` Viresh Kumar
@ 2026-10-28  9:39 ` Bartosz Golaszewski
  2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-10-28  9:39 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult, Viresh Kumar, Linus Walleij,
	Bartosz Golaszewski, Francesco Valla
  Cc: Bartosz Golaszewski, linux-gpio, virtualization, linux-kernel


On Tue, 27 Oct 2026 13:55:24 +0100, Francesco Valla wrote:
> The kernel has been warning about non-immutable irq_chips for quite some
> time, printing messages such as the following one during initialization:
> 
>   gpio gpiochip6: (virtio2): not an immutable chip, please consider fixing it!
> 
> Convert the gpio-virtio irq_chip to immutable and add the relevant
> helpers. The exposed name is kept the same as before through the
> .irq_print_chip callback.
> 
> [...]

Applied, thanks!

[1/1] gpio: virtio: convert to immutable irq_chip
      https://git.kernel.org/brgl/c/c3b94486f0c07562eb894ec6c666656f8cb6eaf0

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-28  9:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-27 12:55 [PATCH] gpio: virtio: convert to immutable irq_chip Francesco Valla
2026-10-27 13:00 ` sashiko-bot
2026-10-28  4:53 ` Viresh Kumar
2026-10-28  9:39 ` Bartosz Golaszewski

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.