2023-05-29 08:02:40

by Jiawen Wu

[permalink] [raw]
Subject: [PATCH] gpiolib: Fix GPIO chip IRQ initialization restriction

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 <[email protected]>
Cc: [email protected]
---
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



2023-05-31 03:59:30

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH] gpiolib: Fix GPIO chip IRQ initialization restriction

On Mon, May 29, 2023 at 10:44 AM Jiawen Wu <[email protected]> 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 <[email protected]>

> Cc: [email protected]

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