Commit e533e4c6 authored by Esben Haabendal's avatar Esben Haabendal Committed by Greg Kroah-Hartman

serial: imx: Introduce timeout when waiting on transmitter empty

By waiting at most 1 second for USR2_TXDC to be set, we avoid a potential
deadlock.

In case of the timeout, there is not much we can do, so we simply ignore
the transmitter state and optimistically try to continue.
Signed-off-by: default avatarEsben Haabendal <esben@geanix.com>
Acked-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Link: https://lore.kernel.org/r/919647898c337a46604edcabaf13d42d80c0915d.1712837613.git.esben@geanix.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent abcd8632
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -2002,7 +2003,7 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count) ...@@ -2002,7 +2003,7 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count)
struct imx_port *sport = imx_uart_ports[co->index]; struct imx_port *sport = imx_uart_ports[co->index];
struct imx_port_ucrs old_ucr; struct imx_port_ucrs old_ucr;
unsigned long flags; unsigned long flags;
unsigned int ucr1; unsigned int ucr1, usr2;
int locked = 1; int locked = 1;
if (sport->port.sysrq) if (sport->port.sysrq)
...@@ -2033,8 +2034,8 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count) ...@@ -2033,8 +2034,8 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count)
* Finally, wait for transmitter to become empty * Finally, wait for transmitter to become empty
* and restore UCR1/2/3 * and restore UCR1/2/3
*/ */
while (!(imx_uart_readl(sport, USR2) & USR2_TXDC)); read_poll_timeout_atomic(imx_uart_readl, usr2, usr2 & USR2_TXDC,
0, USEC_PER_SEC, false, sport, USR2);
imx_uart_ucrs_restore(sport, &old_ucr); imx_uart_ucrs_restore(sport, &old_ucr);
if (locked) if (locked)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment