[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200806194608.bdhvltvwxi3opykk@pengutronix.de>
Date: Thu, 6 Aug 2020 21:46:08 +0200
From: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Ahmad Fatoum <a.fatoum@...gutronix.de>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
Thorsten Scherer <t.scherer@...elmann.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>
Subject: Re: [PATCH] gpio: siox: indicate exclusive support of threaded IRQs
On Thu, Aug 06, 2020 at 08:50:45PM +0200, Thomas Gleixner wrote:
> Linus Walleij <linus.walleij@...aro.org> writes:
> > On Thu, Aug 6, 2020 at 12:20 PM Thomas Gleixner <tglx@...utronix.de> wrote:
> >
> >> So the solution for this driver is either to make the dispatch handler
> >> threaded or use the hard interrupt variant of dispatching the
> >> demultiplexed GPIO interrupts.
> >
> > The struct gpio_irq_chip .threaded bool that the patch
> > sets just instructs the gpio core to issue
> > irq_set_nested_thread(irq, 1) on the child IRQ.
> >
> > This is a driver of type "struct siox_driver" handling the
> > IRQ through the special .get_data callback supplied in the
> > driver struct and it calls handle_nested_irq(irq) so with
> > this fix it percolated up to the parent as intended.
> >
> > So far so good. So I think the patch should be applied.
> >
> > But what is behind this .get_data() callback for siox drivers?
> >
> > The siox driver framework in drivers/siox dispatches calls
> > to .get_data() from a polling thread which is just some ordinary
> > kthread. It looks like this because the SIOX (I think) needs
> > to do polled I/O. (drivers/siox/siox-core.c)
> >
> > So this is a thread but it is not an irq thread from the irq core,
> > however it is treated like such by the driver, and in a way what
> > happens is events, just polled by a thread.
>
> As Uwe just explained.
>
> > So when we call handle_nested_irq() ... we are not really
> > calling that from an irq handler.
> >
> > I don't know if the IRQ core even sees a difference between which
> > thread it gets interfaced with. I suppose it does? :/
>
> handle_nested_irq() does not care. It cares about thread context,
> external reentrancy protection for the same nested interrupt and that
> the nested interrupt has a thread handler.
>
> The latter is what goes belly up because w/o that threaded bit set the
> GPIO core fails to set nested thread. So if a consumer requests an
> interrupt with request_any_context_irq() then that fails to select
> thread mode which means the threaded handler is not set causing
> handle_nested_irq() to fail.
For a caller of request_threaded_irq() that passes a relevant hardirq
handler the hardirq handler is never called but request_threaded_irq()
doesn't fail. The handler is just replaced by irq_nested_primary_handler
in __setup_irq(). Is that a bug? (I didn't test, just read the code, so I
might have missed something.)
> The polling kthread is a slight but clever abomination, but it just
> works because it provides thread context and cannot run concurrently.
I think this is the first time you called any of my code "clever" :-)
> So Ahmad's patch is correct, just the changelog needs polishing.
Trying to be constructive, here is my suggested changelog:
gpio: siox: explicitly only support threaded irqs
The gpio-siox driver uses handle_nested_irq() to implement its
interrupt support. This is only capable to handle threaded irq
actions. For a hardirq action it triggers a NULL pointer oops.
(It calls action->thread_fn which is NULL then.)
So prevent registration of a hardirq action by setting
gpio_irq_chip::threaded to true.
Does this address all your concerns?
Is this bad enough to justify sending this patch to stable?
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists