Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755846AbcJSJDd (ORCPT ); Wed, 19 Oct 2016 05:03:33 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:34838 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755325AbcJSJDW (ORCPT ); Wed, 19 Oct 2016 05:03:22 -0400 Subject: Re: [v2] tty: serial_core: Fix serial console crash on port shutdown To: Geert Uytterhoeven , Greg Kroah-Hartman , Jiri Slaby References: <1476808540-2757-1-git-send-email-geert+renesas@glider.be> CC: =?UTF-8?Q?Niklas_S=c3=b6derlund?= , Rob Herring , Peter Hurley , Alan Cox , , From: Mugunthan V N Message-ID: <1b29aa55-39af-838c-f60c-255431001c50@ti.com> Date: Wed, 19 Oct 2016 13:36:36 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1476808540-2757-1-git-send-email-geert+renesas@glider.be> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2210 Lines: 60 On Tuesday 18 October 2016 10:05 PM, Geert Uytterhoeven wrote: > 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 may 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 > Signed-off-by: Geert Uytterhoeven > Acked-by: Rob Herring Fixes some junk characters seen on boot console on TI platforms. Tested-by: Mugunthan V N Regards Mugunthan V N > --- > v2: > - Add Acked-by, > - Reworded one-line summary (incl. magic word "fix"). > > Can easily 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 console output => hang. > --- > 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) > num_groups++; >