Skip to content

Commit e67c139

Browse files
fugangduangregkh
authored andcommitted
tty: serial: imx: keep console clocks always on
For below code, there has chance to cause deadlock in SMP system: Thread 1: clk_enable_lock(); pr_info("debug message"); clk_enable_unlock(); Thread 2: imx_uart_console_write() clk_enable() clk_enable_lock(); Thread 1: Acuired clk enable_lock -> printk -> console_trylock_spinning Thread 2: console_unlock() -> imx_uart_console_write -> clk_disable -> Acquite clk enable_lock So the patch is to keep console port clocks always on like other console drivers. Fixes: 1cf93e0 ("serial: imx: remove the uart_console() check") Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Link: https://lore.kernel.org/r/20201111025136.29818-1-fugang.duan@nxp.com Cc: stable <stable@vger.kernel.org> [fix up build warning - gregkh] Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d412275 commit e67c139

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

drivers/tty/serial/imx.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,16 +2008,6 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count)
20082008
unsigned int ucr1;
20092009
unsigned long flags = 0;
20102010
int locked = 1;
2011-
int retval;
2012-
2013-
retval = clk_enable(sport->clk_per);
2014-
if (retval)
2015-
return;
2016-
retval = clk_enable(sport->clk_ipg);
2017-
if (retval) {
2018-
clk_disable(sport->clk_per);
2019-
return;
2020-
}
20212011

20222012
if (sport->port.sysrq)
20232013
locked = 0;
@@ -2053,9 +2043,6 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count)
20532043

20542044
if (locked)
20552045
spin_unlock_irqrestore(&sport->port.lock, flags);
2056-
2057-
clk_disable(sport->clk_ipg);
2058-
clk_disable(sport->clk_per);
20592046
}
20602047

20612048
/*
@@ -2156,15 +2143,14 @@ imx_uart_console_setup(struct console *co, char *options)
21562143

21572144
retval = uart_set_options(&sport->port, co, baud, parity, bits, flow);
21582145

2159-
clk_disable(sport->clk_ipg);
21602146
if (retval) {
2161-
clk_unprepare(sport->clk_ipg);
2147+
clk_disable_unprepare(sport->clk_ipg);
21622148
goto error_console;
21632149
}
21642150

2165-
retval = clk_prepare(sport->clk_per);
2151+
retval = clk_prepare_enable(sport->clk_per);
21662152
if (retval)
2167-
clk_unprepare(sport->clk_ipg);
2153+
clk_disable_unprepare(sport->clk_ipg);
21682154

21692155
error_console:
21702156
return retval;

0 commit comments

Comments
 (0)