Re: [PATCH v2 7/9] gpio: 104-idi-48: make use of raw_spinlock variants

From: Julia Cartwright
Date: Wed Mar 22 2017 - 12:11:43 EST


On Wed, Mar 22, 2017 at 08:44:14AM -0400, William Breathitt Gray wrote:
> On Tue, Mar 21, 2017 at 05:43:07PM -0500, Julia Cartwright wrote:
> >The 104-idi-48 gpio driver currently implements an irq_chip for handling
> >interrupts; due to how irq_chip handling is done, it's necessary for the
> >irq_chip methods to be invoked from hardirq context, even on a a
> >real-time kernel. Because the spinlock_t type becomes a "sleeping"
> >spinlock w/ RT kernels, it is not suitable to be used with irq_chips.
> >
> >A quick audit of the operations under the lock reveal that they do only
> >minimal, bounded work, and are therefore safe to do under a raw spinlock.
> >
> >Signed-off-by: Julia Cartwright <julia@xxxxxx>
>
> Hi Julia,
>
> This driver also uses a second spinlock_t, called ack_lock, to prevent
> reentrance into the idi_48_irq_handler function. Should ack_lock also be
> implemented as a raw_spinlock_t?

I saw this lock, and I don't even understand it's purpose.

However, I think I convinced myself that it's harmless. Why? It's only
ever acquired in a handler registered with request_irq(), which, on RT,
is invoked in a context which can sleep.

Thanks for taking a closer look!

Julia