[PATCH 3/3] serial: max310x: hold the port lock around the CTS change
From: Tapio Reijonen
Date: Fri Nov 20 2026 - 02:34:02 EST
uart_handle_cts_change() has to be called with the port lock held: it
updates the CTS counter and, in software flow control mode, hw_stopped
and the transmitter through start_tx() and stop_tx(), all under the
lock. The interrupt thread calls it without the lock, which lockdep
reports on the first CTS edge.
Take the lock around the call, after the register read, since the read
is a bus transfer that sleeps and must not happen under the spinlock.
Use uart_port_lock_irqsave() for it:
- irqsave, because the delay timer takes the same lock from hardirq
context while this code runs in a thread with interrupts on;
- the serial core accessor rather than spin_lock_irqsave(), because
that is how drivers take the port lock, and start_tx(), which
uart_handle_cts_change() may call, drops and retakes it with
uart_port_unlock() and uart_port_lock().
Fixes: f65444187a66 ("serial: New serial driver MAX310X")
Signed-off-by: Tapio Reijonen <tapio.reijonen@xxxxxxxxxxx>
---
drivers/tty/serial/max310x.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 179f5f4cc7b2f994c1dfd1b498878f4f7d6a3299..b2d887316957c2ca46e83efab08a537fc584b407 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1043,7 +1043,8 @@ static irqreturn_t max310x_port_irq(struct max310x_port *s, int portno)
if (ists & MAX310X_IRQ_CTS_BIT) {
lsr = max310x_port_read(port, MAX310X_LSR_IRQSTS_REG);
- uart_handle_cts_change(port, lsr & MAX310X_LSR_CTS_BIT);
+ scoped_guard(uart_port_lock_irqsave, port)
+ uart_handle_cts_change(port, lsr & MAX310X_LSR_CTS_BIT);
}
if (rxlen)
max310x_handle_rx(port, rxlen);
--
2.47.3