Skip to content

Commit cfab87c

Browse files
Vijaya Krishna Nivarthigregkh
authored andcommitted
serial: core: Introduce callback for start_rx and do stop_rx in suspend only if this callback implementation is present.
In suspend sequence there is a need to perform stop_rx during suspend sequence to prevent any asynchronous data over rx line. However this can cause problem to drivers which dont do re-start_rx during set_termios. Add new callback start_rx and perform stop_rx only when implementation of start_rx is present. Also add call to start_rx in resume sequence so that drivers who come across this problem can make use of this framework. Fixes: c9d2325 ("serial: core: Do stop_rx in suspend path for console if console_suspend is disabled") Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Vijaya Krishna Nivarthi <quic_vnivarth@quicinc.com> Link: https://lore.kernel.org/r/1654627965-1461-2-git-send-email-quic_vnivarth@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e74024b commit cfab87c

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

drivers/tty/serial/serial_core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,11 +2214,12 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
22142214
/*
22152215
* Nothing to do if the console is not suspending
22162216
* except stop_rx to prevent any asynchronous data
2217-
* over RX line. Re-start_rx, when required, is
2218-
* done by set_termios in resume sequence
2217+
* over RX line. However ensure that we will be
2218+
* able to Re-start_rx later.
22192219
*/
22202220
if (!console_suspend_enabled && uart_console(uport)) {
2221-
uport->ops->stop_rx(uport);
2221+
if (uport->ops->start_rx)
2222+
uport->ops->stop_rx(uport);
22222223
goto unlock;
22232224
}
22242225

@@ -2310,6 +2311,8 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
23102311
if (console_suspend_enabled)
23112312
uart_change_pm(state, UART_PM_STATE_ON);
23122313
uport->ops->set_termios(uport, &termios, NULL);
2314+
if (!console_suspend_enabled && uport->ops->start_rx)
2315+
uport->ops->start_rx(uport);
23132316
if (console_suspend_enabled)
23142317
console_start(uport->cons);
23152318
}

include/linux/serial_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct uart_ops {
4545
void (*unthrottle)(struct uart_port *);
4646
void (*send_xchar)(struct uart_port *, char ch);
4747
void (*stop_rx)(struct uart_port *);
48+
void (*start_rx)(struct uart_port *);
4849
void (*enable_ms)(struct uart_port *);
4950
void (*break_ctl)(struct uart_port *, int ctl);
5051
int (*startup)(struct uart_port *);

0 commit comments

Comments
 (0)