Skip to contentSkip to conversation

fix serial console resume-from-suspend

PATCH New Peter Hurley 2 participants 3 messages Jul 9, 2014 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fix serial console resume-from-suspend

Greg,

This v2 respin removes the dependency on the patch to which Alan objected (regarding not hanging up remote serial console modems).

This patch fixes bugzilla #69751, where the serial console is garbled after resume from suspend.

Although this was originally reported as a regression, this bug is actually caused when a user-space process (such as setserial or stty) opens and then closes the associated tty. The resultant tty port shutdown caused the console termios settings to be lost, and thus uninitialized when the console was subsequently suspended and then resumed (and there was not an associated open tty).

This patch preserves the cflag settings from the associated tty as the console cflags (which reflect the current line settings anyway). The console cflags are already used to restore the console line settings if there is not an associated open tty.

The side-effect of this patch is that the serial console line settings are persistent. Originally, only the first-time initialization of the associated port inherited the console line settings; now, each time the associated port is initialized to the most recent line settings.

Peter Hurley (1):
serial: core: Preserve termios c_cflag for console resume

 drivers/tty/serial/serial_core.c | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
2.0.0
#1 lore raw

PATCH v2 1/1 serial: core: Preserve termios c_cflag for console resume

When a tty is opened for the serial console, the termios c_cflag settings are inherited from the console line settings. However, if the tty is subsequently closed, the termios settings are lost. This results in a garbled console if the console is later suspended and resumed.

Preserve the termios c_cflag for the serial console when the tty is shutdown; this reflects the most recent line settings.

Fixes Bugzilla #69751, 'serial console does not wake from S3'
Cc Alan Cox <[email protected]>
---
 drivers/tty/serial/serial_core.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/tty/serial/serial_core.c +3 -0
index b68550d..aab7190 100644
@@ -239,6 +239,9 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state)
 		/*
 		 * Turn off DTR and RTS early.
 		 */
+		if (uart_console(uport) && tty)
+			uport->cons->cflag = tty->termios.c_cflag;
+
 		if (!tty || (tty->termios.c_cflag & HUPCL))
 			uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
 
Signature · 1 line
2.0.0
Acked-by Alan Cox on v2 1/1
#2 lore raw

Re: [PATCH v2] serial: core: Preserve termios c_cflag for console resume

Quoted 6 lines · On Wed, 9 Jul 2014 09:21:14 -0400 Peter Hurley <[email protected]>…

When a tty is opened for the serial console, the termios c_cflag settings are inherited from the console line settings. However, if the tty is subsequently closed, the termios settings are lost. This results in a garbled console if the console is later suspended and resumed.

Quoted 7 lines

Preserve the termios c_cflag for the serial console when the tty is shutdown; this reflects the most recent line settings.

Fixes Bugzilla #69751, 'serial console does not wake from S3'
Cc Alan Cox <[email protected]>