lkml.org 
[lkml]   [2020]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: UART/TTY console deadlock
On (20/07/02 14:12), Sergey Senozhatsky wrote:
> Date: Thu, 2 Jul 2020 14:12:13 +0900
> From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> To: Tony Lindgren <tony@atomide.com>
> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>, Petr Mladek
> <pmladek@suse.com>, Andy Shevchenko <andy.shevchenko@gmail.com>, Raul
> Rangel <rrangel@google.com>, Sergey Senozhatsky
> <sergey.senozhatsky.work@gmail.com>, linux-kernel
> <linux-kernel@vger.kernel.org>, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org>, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com>, kurt@linutronix.de, "S, Shirish"
> <Shirish.S@amd.com>, Peter Zijlstra <peterz@infradead.org>, John Ogness
> <john.ogness@linutronix.de>, Steven Rostedt <rostedt@goodmis.org>
> Subject: Re: UART/TTY console deadlock
> Message-ID: <20200702051213.GB3450@jagdpanzerIV.localdomain>
>
> On (20/06/30 11:02), Tony Lindgren wrote:
> > This conditional disable for irq_shared does not look nice to me
> > from the other device point of view :)
> >
> > Would it be possible to just set up te dummy interrupt handler
> > for the startup, then change it back afterwards? See for example
> > omap8250_no_handle_irq().
>
> I think we can do it. serial8250_do_startup() and irq handler take
> port->lock, so they should be synchronized.

Hmm, hold on. Why does it disable IRQ in the first place? IRQ handlers
should grab the port->lock. So if there is already running IRQ, then
serial8250_do_startup() will wait until IRQ handler unlocks the port->lock.
If serial8250_do_startup() grabs the port->lock first, then IRQ will wait
for serial8250_do_startup() to unlock it. serial8250_do_startup() does
not release the port->unlock until its done:

spin_lock_irqsave(&port->lock, flags);

wait_for_xmitr(up, UART_LSR_THRE);
serial_port_out_sync(port, UART_IER, UART_IER_THRI);
udelay(1); /* allow THRE to set */
iir1 = serial_port_in(port, UART_IIR);
serial_port_out(port, UART_IER, 0);
serial_port_out_sync(port, UART_IER, UART_IER_THRI);
udelay(1); /* allow a working UART time to re-assert THRE */
iir = serial_port_in(port, UART_IIR);
serial_port_out(port, UART_IER, 0);

spin_unlock_irqrestore(&port->lock, flags);

so IRQ will not see the inconsistent device state.

What exactly is the purpose of disable_irq_nosync()? Can we just remove
disable_irq_nosync()/enable_irq() instead? Are there any IRQ handlers
that don't acquire the port->lock?

-ss

\
 
 \ /
  Last update: 2020-07-02 07:40    [W:0.170 / U:5.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site