All of
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <>
To: Greg Kroah-Hartman <>,
	Jiri Slaby <>, Rob Herring <>
Cc: "Takeshi Kihara" <>,
	"Niklas Söderlund" <>,
	"Yoshihiro Shimoda" <>,
	"Laurent Pinchart" <>,,,
	"Geert Uytterhoeven" <>
Subject: [PATCH/RFC] tty: serial_core: Move uart_console() check after console registration
Date: Thu, 29 Sep 2016 17:31:04 +0200	[thread overview]
Message-ID: <> (raw)

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 <>
Reported-by: Takeshi Kihara <>
Signed-off-by: Geert Uytterhoeven <>
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.
 drivers/tty/serial/serial_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 6e4f63627479db8d..ce8899c13af3d97f 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.
@@ -2761,6 +2759,8 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
 	uart_configure_port(drv, state, uport);
+	port->console = uart_console(uport);
 	num_groups = 2;
 	if (uport->attr_group)

             reply	other threads:[~2016-09-29 15:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29 15:31 Geert Uytterhoeven [this message]
2016-10-03 18:25 ` [PATCH/RFC] tty: serial_core: Move uart_console() check after console registration Rob Herring
2016-10-03 19:42   ` Geert Uytterhoeven
2016-10-03 20:30     ` Rob Herring
2016-10-05  7:50       ` Geert Uytterhoeven

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.