renesas-drivers-2016-10-04-v4.8 based on renesas-devel-20161003-v4.8
[RFC] tty: serial_core: Move uart_console() check after console registration

The port->console flag is always false, as uart_console() is called
before the serial console has been registered.

Hence for a serial port used as the console, uart_tty_port_shutdown()
will still be called when userspace closes the port, powering it down.
This will lead to a system lock up when the serial console driver writes
to the serial port's registers.

To fix this, move the setting of port->console after the call to
uart_configure_port(), which registers the serial console.

Fixes: 761ed4a94582ab29 ("tty: serial_core: convert uart_close to use tty_port_close")
Reported-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Rob Herring <robh@kernel.org>
---
RFC because of the comment "If this port is a console, then the spinlock
is already initialised", and the pre-existing code calling
uart_console() before uart_configure_port().

Can be reproduced on Renesas boards:
  1. With systemd: hangs during boot,
  2. Without systemd: "telinit n" to switch to a runlevel that doesn't
     run a getty on ttySC0, and trigger kernel output.
1 file changed