Home Home > GIT Browse > SLE12-SP4
diff options
authorTakashi Iwai <tiwai@suse.de>2019-07-16 16:23:44 +0200
committerTakashi Iwai <tiwai@suse.de>2019-07-16 16:23:53 +0200
commite97eb16c0d193055d76308549fc364ed64747bac (patch)
parenta2a1151f04a720ddcbdc44d948bbb4ce1cc300d5 (diff)
tty: serial_core: Set port active bit in uart_port_activate
2 files changed, 74 insertions, 0 deletions
diff --git a/patches.drivers/tty-serial_core-Set-port-active-bit-in-uart_port_act.patch b/patches.drivers/tty-serial_core-Set-port-active-bit-in-uart_port_act.patch
new file mode 100644
index 0000000000..9d43cc9041
--- /dev/null
+++ b/patches.drivers/tty-serial_core-Set-port-active-bit-in-uart_port_act.patch
@@ -0,0 +1,73 @@
+From 13b18d35909707571af9539f7731389fbf0feb31 Mon Sep 17 00:00:00 2001
+From: Serge Semin <fancer.lancer@gmail.com>
+Date: Wed, 8 May 2019 13:44:41 +0300
+Subject: [PATCH] tty: serial_core: Set port active bit in uart_port_activate
+Git-commit: 13b18d35909707571af9539f7731389fbf0feb31
+Patch-mainline: v5.3-rc1
+References: bsc#1051510
+A bug was introduced by commit b3b576461864 ("tty: serial_core: convert
+uart_open to use tty_port_open"). It caused a constant warning printed
+into the system log regarding the tty and port counter mismatch:
+[ 21.644197] ttyS ttySx: tty_port_close_start: tty->count = 1 port count = 2
+in case if session hangup was detected so the warning is printed starting
+from the second open-close iteration.
+Particularly the problem was discovered in situation when there is a
+serial tty device without hardware back-end being setup. It is considered
+by the tty-serial subsystems as a hardware problem with session hang up.
+In this case uart_startup() will return a positive value with TTY_IO_ERROR
+flag set in corresponding tty_struct instance. The same value will get
+passed to be returned from the activate() callback and then being returned
+from tty_port_open(). But since in this case tty_port_block_til_ready()
+isn't called the TTY_PORT_ACTIVE flag isn't set (while the method had been
+called before tty_port_open conversion was introduced and the rest of the
+subsystem code expected the bit being set in this case), which prevents the
+uart_hangup() method to perform any cleanups including the tty port
+counter setting to zero. So the next attempt to open/close the tty device
+will discover the counters mismatch.
+In order to fix the problem we need to manually set the TTY_PORT_ACTIVE
+flag in case if uart_startup() returned a positive value. In this case
+the hang up procedure will perform a full set of cleanup actions including
+the port ref-counter resetting.
+Fixes: b3b576461864 "tty: serial_core: convert uart_open to use tty_port_open"
+Signed-off-by: Serge Semin <fancer.lancer@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+ drivers/tty/serial/serial_core.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
+index 83f4dd0bfd74..4223cb496764 100644
+--- a/drivers/tty/serial/serial_core.c
++++ b/drivers/tty/serial/serial_core.c
+@@ -1777,6 +1777,7 @@ static int uart_port_activate(struct tty_port *port, struct tty_struct *tty)
+ {
+ struct uart_state *state = container_of(port, struct uart_state, port);
+ struct uart_port *uport;
++ int ret;
+ uport = uart_port_check(state);
+ if (!uport || uport->flags & UPF_DEAD)
+@@ -1787,7 +1788,11 @@ static int uart_port_activate(struct tty_port *port, struct tty_struct *tty)
+ /*
+ * Start up the serial port.
+ */
+- return uart_startup(tty, state, 0);
++ ret = uart_startup(tty, state, 0);
++ if (ret > 0)
++ tty_port_set_active(port, 1);
++ return ret;
+ }
+ static const char *uart_type(struct uart_port *port)
diff --git a/series.conf b/series.conf
index 0ac33eb842..1ea8782fef 100644
--- a/series.conf
+++ b/series.conf
@@ -22918,6 +22918,7 @@
+ patches.drivers/tty-serial_core-Set-port-active-bit-in-uart_port_act.patch