tty: Don't block on IO when ldisc change is pending
authorDmitry Safonov <dima@arista.com>
Thu, 1 Nov 2018 00:24:48 +0000 (00:24 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Dec 2019 07:52:28 +0000 (08:52 +0100)
commit50e9fda8654bf1c4a9239c253f99350b392842c1
tree71460816f5d6bb1e1a69a417c09196e8c88c3bca
parent01e5d17964947f52808a2908a972918223c4b4d0
tty: Don't block on IO when ldisc change is pending

[ Upstream commit c96cf923a98d1b094df9f0cf97a83e118817e31b ]

There might be situations where tty_ldisc_lock() has blocked, but there
is already IO on tty and it prevents line discipline changes.
It might theoretically turn into dead-lock.

Basically, provide more priority to pending tty_ldisc_lock() than to
servicing reads/writes over tty.

User-visible issue was reported by Mikulas where on pa-risc with
Debian 5 reboot took either 80 seconds, 3 minutes or 3:25 after proper
locking in tty_reopen().

Cc: Jiri Slaby <jslaby@suse.com>
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/n_hdlc.c
drivers/tty/n_r3964.c
drivers/tty/n_tty.c
drivers/tty/tty_ldisc.c
include/linux/tty.h