Skip to content

Commit e5d6bd2

Browse files
pccgregkh
authored andcommitted
serial: 8250_dw: Do not reclock if already at correct rate
When userspace opens the console, we call set_termios() passing a termios with the console's configured baud rate. Currently this causes dw8250_set_termios() to disable and then re-enable the UART clock at the same frequency as it was originally. This can cause corruption of any concurrent console output. Fix it by skipping the reclocking if we are already at the correct rate. Signed-off-by: Peter Collingbourne <pcc@google.com> Fixes: 4e26b13 ("serial: 8250_dw: clock rate handling for all ACPI platforms") Cc: stable@vger.kernel.org Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240222192635.1050502-1-pcc@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 672448c commit e5d6bd2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/tty/serial/8250/8250_dw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,18 +357,18 @@ static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
357357
long rate;
358358
int ret;
359359

360-
clk_disable_unprepare(d->clk);
361360
rate = clk_round_rate(d->clk, newrate);
362-
if (rate > 0) {
361+
if (rate > 0 && p->uartclk != rate) {
362+
clk_disable_unprepare(d->clk);
363363
/*
364364
* Note that any clock-notifer worker will block in
365365
* serial8250_update_uartclk() until we are done.
366366
*/
367367
ret = clk_set_rate(d->clk, newrate);
368368
if (!ret)
369369
p->uartclk = rate;
370+
clk_prepare_enable(d->clk);
370371
}
371-
clk_prepare_enable(d->clk);
372372

373373
dw8250_do_set_termios(p, termios, old);
374374
}

0 commit comments

Comments
 (0)