[lkml]   [2021]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 5.10 141/530] serial: stm32: add FIFO flush when port is closed
From: Erwan Le Ray <>

[ Upstream commit 9f77d19207a0e8ba814c8ceb22e90ce7cb2aef64 ]

Transmission complete error is sent when ISR_TC is not set. If port closure
is requested despite data in TDR / TX FIFO has not been sent (because of
flow control), ISR_TC is not set and error message is sent on port closure
but also when a new port is opened.

Flush the data when port is closed, so the error isn't printed twice upon
next port opening.

Fixes: 64c32eab6603 ("serial: stm32: Add support of TC bit status check")
Signed-off-by: Erwan Le Ray <>
Signed-off-by: Greg Kroah-Hartman <>
Signed-off-by: Sasha Levin <>
drivers/tty/serial/stm32-usart.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index 6788fb3af6cb..cb8c2bece6d6 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -689,6 +689,11 @@ static void stm32_usart_shutdown(struct uart_port *port)
if (ret)
dev_err(port->dev, "transmission complete not set\n");

+ /* flush RX & TX FIFO */
+ if (ofs->rqr != UNDEF_REG)
+ port->membase + ofs->rqr);
stm32_usart_clr_bits(port, ofs->cr1, val);

free_irq(port->irq, port);

 \ /
  Last update: 2021-05-12 17:49    [W:1.491 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site