]> git.baikalelectronics.ru Git - kernel.git/commit
serial: core: fix console port-lock regression
authorJohan Hovold <johan@kernel.org>
Wed, 9 Sep 2020 14:31:01 +0000 (16:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Sep 2020 11:22:44 +0000 (13:22 +0200)
commit922d9a8dbde4659c4ce9c01c4a23a4d5fc4f72f1
treeec315e0d7910463dc7e7f46d84fe92d145e7d17e
parent87ac759e9e46b0609a16bbbccbc25255e1fb8717
serial: core: fix console port-lock regression

Fix the port-lock initialisation regression introduced by commit
0ec22c5292df ("serial: core: Allow detach and attach serial device for
console") by making sure that the lock is again initialised during
console setup.

The console may be registered before the serial controller has been
probed in which case the port lock needs to be initialised during
console setup by a call to uart_set_options(). The console-detach
changes introduced a regression in several drivers by effectively
removing that initialisation by not initialising the lock when the port
is used as a console (which is always the case during console setup).

Add back the early lock initialisation and instead use a new
console-reinit flag to handle the case where a console is being
re-attached through sysfs.

The question whether the console-detach interface should have been added
in the first place is left for another discussion.

Note that the console-enabled check in uart_set_options() is not
redundant because of kgdboc, which can end up reinitialising an already
enabled console (see commit 2fa90dd9619c ("serial_core: Don't
re-initialize a previously initialized spinlock.")).

Fixes: 0ec22c5292df ("serial: core: Allow detach and attach serial device for console")
Cc: stable <stable@vger.kernel.org> # 5.7
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20200909143101.15389-3-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/serial_core.c
include/linux/serial_core.h