Re: [PATCH 01/13] serial: linflexuart: Fix locking in set_termios

From: Larisa Ileana Grigore

Date: Wed Feb 18 2026 - 06:59:18 EST


On 2/16/2026 10:16 PM, Frank Li wrote:
On Mon, Feb 16, 2026 at 04:01:53PM +0100, Larisa Grigore wrote:
From: Radu Pirea <radu-nicolae.pirea@xxxxxxx>

Take the port->lock when set_termios is called, otherwise if characters
are sent while IP is in init mode, the IP will hang in an uncertain
state.

According to patch, you move it before read(UARTCR). can explain why hang?

Frank

Hello Frank,

Thanks for the review! This change was made to not let anyone send characters (for example calling `linflex_console_putchar`) while LINFlexD is entering INIT mode. The INIT mode is entered when setting LINFLEXD_LINCR1_INIT in LINCR1. UARTCR should also be protected with a lock since it can be modified from different other places.
I will update the commit description.

Regards,
Larisa

Fixes: 09864c1cdf5c ("tty: serial: Add linflexuart driver for S32V234")
Signed-off-by: Radu Pirea <radu-nicolae.pirea@xxxxxxx>
Signed-off-by: Larisa Grigore <larisa.grigore@xxxxxxxxxxx>
---
drivers/tty/serial/fsl_linflexuart.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/fsl_linflexuart.c b/drivers/tty/serial/fsl_linflexuart.c
index e70a56de1fce..5a410e2d56ac 100644
--- a/drivers/tty/serial/fsl_linflexuart.c
+++ b/drivers/tty/serial/fsl_linflexuart.c
@@ -407,6 +407,8 @@ linflex_set_termios(struct uart_port *port, struct ktermios *termios,
unsigned long cr, old_cr, cr1;
unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;

+ uart_port_lock_irqsave(port, &flags);
+
cr = readl(port->membase + UARTCR);
old_cr = cr;

@@ -475,8 +477,6 @@ linflex_set_termios(struct uart_port *port, struct ktermios *termios,
cr &= ~LINFLEXD_UARTCR_PCE;
}

- uart_port_lock_irqsave(port, &flags);
-
port->read_status_mask = 0;

if (termios->c_iflag & INPCK)
--
2.47.0