linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tty: serial_core: recover uport->cons->cflag on uart_close
@ 2019-06-16 14:57 kpark3469
  2019-06-18  7:51 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: kpark3469 @ 2019-06-16 14:57 UTC (permalink / raw)
  To: gregkh; +Cc: jslaby, linux-serial, linux-kernel, keun-o.park

From: Sahara <keun-o.park@darkmatter.ae>

Since uart_close was converted to use tty_port_close, uart_shutdown
also moved to uart_tty_port_shutdown, which means it does not backup
tty's termios to uart_port.console.cflag when console is closed and
uart_console is true.
By losing this value, serial console was not set correctly especially
after suspend/resume when there is no consumer of console device.
This problem resets console driver's configuration to an unwanted value
and may give a performance regression in the system eventually.
This patch fixes the bug introduced from v4.9 kernel.

Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
Reported-by: Jouni Linnamaa <Jouni.Linnamaa@darkmatter.ae>
Signed-off-by: Sahara <keun-o.park@darkmatter.ae>
---
 drivers/tty/serial/serial_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 83f4dd0bfd74..a52afceb2f4e 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1533,6 +1533,7 @@ static void uart_set_termios(struct tty_struct *tty,
 static void uart_close(struct tty_struct *tty, struct file *filp)
 {
 	struct uart_state *state = tty->driver_data;
+	struct uart_port *uport = uart_port_check(state);
 
 	if (!state) {
 		struct uart_driver *drv = tty->driver->driver_state;
@@ -1548,6 +1549,8 @@ static void uart_close(struct tty_struct *tty, struct file *filp)
 
 	pr_debug("uart_close(%d) called\n", tty->index);
 
+	if (uport && uart_console(uport))
+		uport->cons->cflag = tty->termios.c_cflag;
 	tty_port_close(tty->port, tty, filp);
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tty: serial_core: recover uport->cons->cflag on uart_close
  2019-06-16 14:57 [PATCH] tty: serial_core: recover uport->cons->cflag on uart_close kpark3469
@ 2019-06-18  7:51 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-06-18  7:51 UTC (permalink / raw)
  To: kpark3469; +Cc: jslaby, linux-serial, linux-kernel, keun-o.park

On Sun, Jun 16, 2019 at 06:57:14PM +0400, kpark3469@gmail.com wrote:
> From: Sahara <keun-o.park@darkmatter.ae>

I need a "full" name here please, something you use to sign legal
documents.

> Since uart_close was converted to use tty_port_close, uart_shutdown
> also moved to uart_tty_port_shutdown, which means it does not backup
> tty's termios to uart_port.console.cflag when console is closed and
> uart_console is true.
> By losing this value, serial console was not set correctly especially
> after suspend/resume when there is no consumer of console device.
> This problem resets console driver's configuration to an unwanted value
> and may give a performance regression in the system eventually.
> This patch fixes the bug introduced from v4.9 kernel.
> 
> Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
> Reported-by: Jouni Linnamaa <Jouni.Linnamaa@darkmatter.ae>
> Signed-off-by: Sahara <keun-o.park@darkmatter.ae>

Same here as well.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-18  7:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-16 14:57 [PATCH] tty: serial_core: recover uport->cons->cflag on uart_close kpark3469
2019-06-18  7:51 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).