drivers/tty/serial/imx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
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.
v2:
- Fixed commit message typo
- Remove reference to patch series it originated from. This is a
stand-alone patch
Signed-off-by: Esben Haabendal <esben@geanix.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/tty/serial/imx.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index e14813250616..09c1678ddfd4 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/dma-mapping.h>
#include <asm/irq.h>
@@ -2010,7 +2011,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_ucrs old_ucr;
unsigned long flags;
- unsigned int ucr1;
+ unsigned int ucr1, usr2;
int locked = 1;
if (sport->port.sysrq)
@@ -2041,8 +2042,8 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count)
* Finally, wait for transmitter to become empty
* 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);
if (locked)
--
2.44.0
On Wed, Apr 10, 2024 at 09:18:32AM +0200, Esben Haabendal wrote: > 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. > > v2: > - Fixed commit message typo > - Remove reference to patch series it originated from. This is a > stand-alone patch The "v2:" stuff needs to go below the --- line, so it doesn't show up in the kernel changelog. The kernel documentation should describe this, right? Please fix up and send a v3. thanks, greg k-h
Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes: > On Wed, Apr 10, 2024 at 09:18:32AM +0200, Esben Haabendal wrote: >> 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. >> >> v2: >> - Fixed commit message typo >> - Remove reference to patch series it originated from. This is a >> stand-alone patch > > The "v2:" stuff needs to go below the --- line, so it doesn't show up in > the kernel changelog. The kernel documentation should describe this, > right? Right. It is described in Documentation/process/submitting-patches.rst. Sorry about that. > Please fix up and send a v3. On its way. /Esben
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: Esben Haabendal <esben@geanix.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
v2:
- Fixed commit message typo
- Remove reference to patch series it originated from. This is a
stand-alone patch
v3:
- Moved this version information into the correct patch section
drivers/tty/serial/imx.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index e14813250616..09c1678ddfd4 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/dma-mapping.h>
#include <asm/irq.h>
@@ -2010,7 +2011,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_ucrs old_ucr;
unsigned long flags;
- unsigned int ucr1;
+ unsigned int ucr1, usr2;
int locked = 1;
if (sport->port.sysrq)
@@ -2041,8 +2042,8 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count)
* Finally, wait for transmitter to become empty
* 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);
if (locked)
--
2.44.0
Esben Haabendal <esben@geanix.com> writes: > 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: Esben Haabendal <esben@geanix.com> > Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> > --- > > v2: > - Fixed commit message typo > - Remove reference to patch series it originated from. This is a > stand-alone patch > > v3: > - Moved this version information into the correct patch section Anything more needed in order to get this merged? /Esben > > drivers/tty/serial/imx.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > index e14813250616..09c1678ddfd4 100644 > --- a/drivers/tty/serial/imx.c > +++ b/drivers/tty/serial/imx.c > @@ -26,6 +26,7 @@ > #include <linux/slab.h> > #include <linux/of.h> > #include <linux/io.h> > +#include <linux/iopoll.h> > #include <linux/dma-mapping.h> > > #include <asm/irq.h> > @@ -2010,7 +2011,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_ucrs old_ucr; > unsigned long flags; > - unsigned int ucr1; > + unsigned int ucr1, usr2; > int locked = 1; > > if (sport->port.sysrq) > @@ -2041,8 +2042,8 @@ imx_uart_console_write(struct console *co, const char *s, unsigned int count) > * Finally, wait for transmitter to become empty > * 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); > > if (locked)
On Thu, May 02, 2024 at 11:14:26AM +0200, Esben Haabendal wrote: > Esben Haabendal <esben@geanix.com> writes: > > > 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: Esben Haabendal <esben@geanix.com> > > Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> > > --- > > > > v2: > > - Fixed commit message typo > > - Remove reference to patch series it originated from. This is a > > stand-alone patch > > > > v3: > > - Moved this version information into the correct patch section > > Anything more needed in order to get this merged? Sorry, but I don't see this in my review queue anymore. If this isn't already accepted, please resend it, sorry about that. greg k-h
© 2016 - 2026 Red Hat, Inc.