linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] gpiolib: Fix GPIO chip IRQ initialization restriction
@ 2023-06-07  8:18 Jiawen Wu
  2023-06-07 14:12 ` Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jiawen Wu @ 2023-06-07  8:18 UTC (permalink / raw)
  To: linus.walleij, brgl, shreeya.patel, andy.shevchenko, linux-gpio,
	linux-kernel
  Cc: Jiawen Wu

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>
---
v1 -> v2:
- add compiler barrier
---
 drivers/gpio/gpiolib.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a7220e04a93e..9ecf93cbd801 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1792,6 +1792,14 @@ int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
 	gc->to_irq = gpiochip_to_irq;
 	gc->irq.domain = domain;
 
+	/*
+	 * Using barrier() here to prevent compiler from reordering
+	 * gc->irq.initialized before adding irqdomain.
+	 */
+	barrier();
+
+	gc->irq.initialized = true;
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(gpiochip_irqchip_add_domain);
-- 
2.27.0


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

end of thread, other threads:[~2023-06-16  2:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-07  8:18 [PATCH v2] gpiolib: Fix GPIO chip IRQ initialization restriction Jiawen Wu
2023-06-07 14:12 ` Andy Shevchenko
2023-06-15  9:26   ` Michael Walle
2023-06-15  9:34     ` Shreeya Patel
2023-06-15  9:52     ` Jiawen Wu
2023-06-15 10:45       ` Michael Walle
2023-06-15 13:55         ` Andy Shevchenko
2023-06-16  2:11           ` Jiawen Wu
2023-06-16  2:20             ` Jiawen Wu
2023-06-09  7:37 ` Linus Walleij
2023-06-13 12:41 ` Bartosz Golaszewski

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).