Skip to content

Commit 93a770b

Browse files
l1kgregkh
authored andcommitted
serial: core: Keep mctrl register state and cached copy in sync
struct uart_port contains a cached copy of the Modem Control signals. It is used to skip register writes in uart_update_mctrl() if the new signal state equals the old signal state. It also avoids a register read to obtain the current state of output signals. When a uart_port is registered, uart_configure_port() changes signal state but neglects to keep the cached copy in sync. That may cause a subsequent register write to be incorrectly skipped. Fix it before it trips somebody up. This behavior has been present ever since the serial core was introduced in 2002: https://git.kernel.org/history/history/c/33c0d1b0c3eb So far it was never an issue because the cached copy is initialized to 0 by kzalloc() and when uart_configure_port() is executed, at most DTR has been set by uart_set_options() or sunsu_console_setup(). Therefore, a stable designation seems unnecessary. Signed-off-by: Lukas Wunner <[email protected]> Link: https://lore.kernel.org/r/bceeaba030b028ed810272d55d5fc6f3656ddddb.1641129752.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 195437d commit 93a770b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/tty/serial/serial_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2389,7 +2389,8 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
23892389
* We probably don't need a spinlock around this, but
23902390
*/
23912391
spin_lock_irqsave(&port->lock, flags);
2392-
port->ops->set_mctrl(port, port->mctrl & TIOCM_DTR);
2392+
port->mctrl &= TIOCM_DTR;
2393+
port->ops->set_mctrl(port, port->mctrl);
23932394
spin_unlock_irqrestore(&port->lock, flags);
23942395

23952396
/*

0 commit comments

Comments
 (0)