linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] tty: serial: 8250: always call tx_chars under spinlock
@ 2020-12-09  9:17 Steffen Trumtrar
  2020-12-09  9:17 ` [PATCH 2/2] tty: serial: 8250: wait till transmitter is empty Steffen Trumtrar
  2020-12-09 11:23 ` [PATCH 1/2] tty: serial: 8250: always call tx_chars under spinlock Johan Hovold
  0 siblings, 2 replies; 7+ messages in thread
From: Steffen Trumtrar @ 2020-12-09  9:17 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial

In most cases serial8250_tx_chars is called with spinlock held.
Fix the remaining location, too.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/tty/serial/8250/8250_port.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index b0af13074cd3..3310c2b70138 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1559,6 +1559,7 @@ static void serial8250_stop_tx(struct uart_port *port)
 static inline void __start_tx(struct uart_port *port)
 {
 	struct uart_8250_port *up = up_to_u8250p(port);
+	unsigned long flags;
 
 	if (up->dma && !up->dma->tx_dma(up))
 		return;
@@ -1569,8 +1570,11 @@ static inline void __start_tx(struct uart_port *port)
 
 			lsr = serial_in(up, UART_LSR);
 			up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
-			if (lsr & UART_LSR_THRE)
+			if (lsr & UART_LSR_THRE) {
+				spin_lock_irqsave(&port->lock, flags);
 				serial8250_tx_chars(up);
+				spin_unlock_irqrestore(&port->lock, flags);
+			}
 		}
 	}
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-01-05  7:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09  9:17 [PATCH 1/2] tty: serial: 8250: always call tx_chars under spinlock Steffen Trumtrar
2020-12-09  9:17 ` [PATCH 2/2] tty: serial: 8250: wait till transmitter is empty Steffen Trumtrar
2020-12-09 11:26   ` Johan Hovold
2021-01-04 11:47     ` Steffen Trumtrar
2020-12-09 11:23 ` [PATCH 1/2] tty: serial: 8250: always call tx_chars under spinlock Johan Hovold
2021-01-04 11:42   ` Steffen Trumtrar
     [not found]   ` <87ft3hdj3n.fsf@pengutronix.de>
2021-01-05  7:33     ` Steffen Trumtrar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).