Re: [lockdep warning] INFO: inconsistent lock state,serial8250_interrupt(), &port_lock_key

From: Borislav Petkov
Date: Thu Jul 24 2008 - 03:12:11 EST


On Thu, Jul 24, 2008 at 08:53:29AM +0200, Borislav Petkov wrote:
> On Wed, Jul 23, 2008 at 11:36:04AM +0200, Ingo Molnar wrote:
> >
> > * Ingo Molnar <mingo@xxxxxxx> wrote:
> >
> > > =================================
> > > [ INFO: inconsistent lock state ]
> > > 2.6.26-tip-06509-gb4ebc67-dirty #13600
> > > ---------------------------------
> >
> > the upstream component of that is: v2.6.26-6077-gc010b2f
> >
> > i.e. my suspicion is that this got introduced via the recent tty
> > changes.
>
> Hi,
>
> i hit the same warning here. How about the following fix (this is at least what
> i think happens):
> --
>
> serial8250_startup() might unconditionally enable irqs after releasing
> &up->port.lock while we're still servicing an interrupt.

Actually, this explanation is not correct - it should be more like:

serial8250_startup() doesn't disable interrupts while taking the &up->port.lock
which might race against the interrupt handler serial8250_interrupt(), which
when entered, will deadlock waiting for the lock to be released.

>
> Signed-off-by: Borislav Petkov <petkovbb@xxxxxxxxx>
>
> --
> diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
> index 27f34a9..55eca08 100644
> --- a/drivers/serial/8250.c
> +++ b/drivers/serial/8250.c
> @@ -1874,7 +1874,7 @@ static int serial8250_startup(struct uart_port *port)
> * the interrupt is enabled. Delays are necessary to
> * allow register changes to become visible.
> */
> - spin_lock(&up->port.lock);
> + spin_lock_irqsave(&up->port.lock, flags);
> if (up->port.flags & UPF_SHARE_IRQ)
> disable_irq_nosync(up->port.irq);
>
> @@ -1890,7 +1890,7 @@ static int serial8250_startup(struct uart_port *port)
>
> if (up->port.flags & UPF_SHARE_IRQ)
> enable_irq(up->port.irq);
> - spin_unlock(&up->port.lock);
> + spin_unlock_irqrestore(&up->port.lock, flags);
>
> /*
> * If the interrupt is not reasserted, setup a timer to
>
> --
> Regards/Gruß,
> Boris.

--
Regards/Gruß,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/