linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: siox: indicate exclusive support of threaded IRQs
@ 2020-08-04  9:16 Ahmad Fatoum
  2020-08-05  6:17 ` Uwe Kleine-König
  2020-08-27 22:55 ` Linus Walleij
  0 siblings, 2 replies; 12+ messages in thread
From: Ahmad Fatoum @ 2020-08-04  9:16 UTC (permalink / raw)
  To: Thorsten Scherer, Uwe Kleine-König, Pengutronix Kernel Team,
	Linus Walleij, Bartosz Golaszewski
  Cc: Ahmad Fatoum, linux-gpio, linux-kernel

Generic GPIO consumers like gpio-keys use request_any_context_irq()
to request a threaded handler if irq_settings_is_nested_thread() ==
true or a hardirq handler otherwise.

Drivers using handle_nested_irq() must be sure that the nested
IRQs were requested with threaded handlers, because the IRQ
is handled by calling action->thread_fn().

The gpio-siox driver dispatches IRQs via handle_nested_irq,
but has irq_settings_is_nested_thread() == false.

Set gpio_irq_chip::threaded to remedy this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
I am writing a driver similar to gpio-siox and I ran into a null pointer
dereference, because ->threaded wasn't set. I didn't test this on actual
SIOX hardware.

This patch doesn't fix the case were are driver explicitly calls
request_irq and is combined with a driver that does handle_nested_irq.

Is there a flag, such drivers should additionally set or should we
check action->thread_fn before calling it inside handle_nested_irq?
---
 drivers/gpio/gpio-siox.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
index 26e1fe092304..f8c5e9fc4bac 100644
--- a/drivers/gpio/gpio-siox.c
+++ b/drivers/gpio/gpio-siox.c
@@ -245,6 +245,7 @@ static int gpio_siox_probe(struct siox_device *sdevice)
 	girq->chip = &ddata->ichip;
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_level_irq;
+	girq->threaded = true;
 
 	ret = devm_gpiochip_add_data(dev, &ddata->gchip, NULL);
 	if (ret)
-- 
2.28.0


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

end of thread, other threads:[~2020-09-07 15:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04  9:16 [PATCH] gpio: siox: indicate exclusive support of threaded IRQs Ahmad Fatoum
2020-08-05  6:17 ` Uwe Kleine-König
2020-08-06 10:20   ` Thomas Gleixner
2020-08-06 13:32     ` Linus Walleij
2020-08-06 18:50       ` Thomas Gleixner
2020-08-06 19:46         ` Uwe Kleine-König
2020-08-06 20:33           ` Thomas Gleixner
2020-08-06 21:07             ` Uwe Kleine-König
2020-08-10 13:33               ` Uwe Kleine-König
2020-08-06 15:07     ` Uwe Kleine-König
2020-08-27 22:55 ` Linus Walleij
2020-09-07 15:33   ` Ahmad Fatoum

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