Re: [PATCH] serial: core: fix console problems on uart_close

From: Geert Uytterhoeven
Date: Tue Oct 25 2016 - 06:40:46 EST


Hi Rob,

On Mon, Oct 24, 2016 at 10:56 PM, Rob Herring <robh@xxxxxxxxxx> wrote:
> Commit 761ed4a94582 ('tty: serial_core: convert uart_close to use
> tty_port_close') started setting the ttyport console flag for serial
> drivers. This is causing crashes, hangs, or garbage output on several
> platforms because the serial shutdown is skipped and IRQs are left
> enabled.

No, for me it hangs because uart_tty_port_shutdown() is _not_ skipped
when the UART is used as a serial console. Writing to the serial port while
it's shut down hangs.

> Partially revert commit 761ed4a94582 and drop reporting UART tty_ports
> as a console leaving the console handling to the serial_core as it was
> before.
>
> Fixes: 761ed4a94582ab29 ("tty: serial_core: convert uart_close to use tty_port_close")
> Reported-by: Niklas SÃderlund <niklas.soderlund+renesas@xxxxxxxxxxxx>
> Reported-by: Mike Galbraith <umgwanakikbuti@xxxxxxxxx>
> Reported-by: Mugunthan V N <mugunthanvnm@xxxxxx>
> Cc: Peter Hurley <peter@xxxxxxxxxxxxxxxxxx>
> Cc: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> Cc: Alan Cox <alan@xxxxxxxxxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Cc: Jiri Slaby <jslaby@xxxxxxxx>
> Cc: linux-serial@xxxxxxxxxxxxxxx
> Signed-off-by: Rob Herring <robh@xxxxxxxxxx>
> ---
> Geert's fix seems to be inadequate for some systems as Mike reported[1].
> This fix works in Mike's case.
>
> Geert, Mugunthan, Can you all test this is enough to fix your issues.

This doesn't work for me, as port->console is still false. It should be true
when used as a serial console, to make sure tty_port_shutdown() skips
an active serial console.

Mike: I see you are using a PC, while I'm using an ARM board (with DT).
Are you using a serial console? If yes, what's the value of port->console
before and after the call to uart_console() that Rob's patch below removes?

Thanks!

> [1] https://www.mail-archive.com/linux-kernel@xxxxxxxxxxxxxxx/msg1254753.html
>
> drivers/tty/serial/serial_core.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
> index 6e4f63627479..664c99aeeca5 100644
> --- a/drivers/tty/serial/serial_core.c
> +++ b/drivers/tty/serial/serial_core.c
> @@ -2746,8 +2746,6 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
> uport->cons = drv->cons;
> uport->minor = drv->tty_driver->minor_start + uport->line;
>
> - port->console = uart_console(uport);
> -
> /*
> * If this port is a console, then the spinlock is already
> * initialised.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds