[PATCH] gpiolib: Fix GPIO chip IRQ initialization restriction

Jiawen Wu posted 1 patch 2 years, 8 months ago
There is a newer version of this series
drivers/gpio/gpiolib.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] gpiolib: Fix GPIO chip IRQ initialization restriction
Posted by Jiawen Wu 2 years, 8 months ago
In case of gpio-regmap, IRQ chip is added by regmap-irq and associated with
GPIO chip by gpiochip_irqchip_add_domain(). The initialization flag was not
added in gpiochip_irqchip_add_domain(), causing gpiochip_to_irq() to return
-EPROBE_DEFER.

Fixes: 5467801f1fcb ("gpio: Restrict usage of GPIO chip irq members before initialization")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Cc: shreeya.patel@collabora.com
---
 drivers/gpio/gpiolib.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 04fb05df805b..1b6cd4ffb761 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1789,6 +1789,7 @@ int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
 
 	gc->to_irq = gpiochip_to_irq;
 	gc->irq.domain = domain;
+	gc->irq.initialized = true;
 
 	return 0;
 }
-- 
2.27.0
Re: [PATCH] gpiolib: Fix GPIO chip IRQ initialization restriction
Posted by Andy Shevchenko 2 years, 8 months ago
On Mon, May 29, 2023 at 10:44 AM Jiawen Wu <jiawenwu@trustnetic.com> wrote:
>
> In case of gpio-regmap, IRQ chip is added by regmap-irq and associated with
> GPIO chip by gpiochip_irqchip_add_domain(). The initialization flag was not
> added in gpiochip_irqchip_add_domain(), causing gpiochip_to_irq() to return
> -EPROBE_DEFER.

Makes sense to me.

> Fixes: 5467801f1fcb ("gpio: Restrict usage of GPIO chip irq members before initialization")
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>

> Cc: shreeya.patel@collabora.com

This can be replaced with the --cc option.

...

>         gc->to_irq = gpiochip_to_irq;
>         gc->irq.domain = domain;

I'm wondering if you need the same (compiler) barrier here as in the
other place.

> +       gc->irq.initialized = true;

--
With Best Regards,
Andy Shevchenko