Skip to content

Commit f23c52a

Browse files
fabioestevamgregkh
authored andcommitted
serial: imx: Restore original RXTL for console to fix data loss
Commit 7a63778 ("serial: imx: reduce RX interrupt frequency") introduced a regression on the i.MX6UL EVK board. The issue can be reproduced with the following steps: - Open vi on the board. - Paste a text file (~150 characters). - Save the file, then repeat the process. - Compare the sha256sum of the saved files. The checksums do not match due to missing characters or entire lines. Fix this by restoring the RXTL value to 1 when the UART is used as a console. This ensures timely RX interrupts and reliable data reception in console mode. With this change, pasted content is saved correctly, and checksums are always consistent. Cc: stable <[email protected]> Fixes: 7a63778 ("serial: imx: reduce RX interrupt frequency") Signed-off-by: Fabio Estevam <[email protected]> Reviewed-by: Stefan Wahren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d36f0e9 commit f23c52a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/tty/serial/imx.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ struct imx_port {
235235
enum imx_tx_state tx_state;
236236
struct hrtimer trigger_start_tx;
237237
struct hrtimer trigger_stop_tx;
238+
unsigned int rxtl;
238239
};
239240

240241
struct imx_port_ucrs {
@@ -1339,6 +1340,7 @@ static void imx_uart_clear_rx_errors(struct imx_port *sport)
13391340

13401341
#define TXTL_DEFAULT 8
13411342
#define RXTL_DEFAULT 8 /* 8 characters or aging timer */
1343+
#define RXTL_CONSOLE_DEFAULT 1
13421344
#define TXTL_DMA 8 /* DMA burst setting */
13431345
#define RXTL_DMA 9 /* DMA burst setting */
13441346

@@ -1457,7 +1459,7 @@ static void imx_uart_disable_dma(struct imx_port *sport)
14571459
ucr1 &= ~(UCR1_RXDMAEN | UCR1_TXDMAEN | UCR1_ATDMAEN);
14581460
imx_uart_writel(sport, ucr1, UCR1);
14591461

1460-
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
1462+
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, sport->rxtl);
14611463

14621464
sport->dma_is_enabled = 0;
14631465
}
@@ -1482,7 +1484,12 @@ static int imx_uart_startup(struct uart_port *port)
14821484
return retval;
14831485
}
14841486

1485-
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
1487+
if (uart_console(&sport->port))
1488+
sport->rxtl = RXTL_CONSOLE_DEFAULT;
1489+
else
1490+
sport->rxtl = RXTL_DEFAULT;
1491+
1492+
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, sport->rxtl);
14861493

14871494
/* disable the DREN bit (Data Ready interrupt enable) before
14881495
* requesting IRQs
@@ -1948,7 +1955,7 @@ static int imx_uart_poll_init(struct uart_port *port)
19481955
if (retval)
19491956
clk_disable_unprepare(sport->clk_ipg);
19501957

1951-
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
1958+
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, sport->rxtl);
19521959

19531960
uart_port_lock_irqsave(&sport->port, &flags);
19541961

@@ -2040,7 +2047,7 @@ static int imx_uart_rs485_config(struct uart_port *port, struct ktermios *termio
20402047
/* If the receiver trigger is 0, set it to a default value */
20412048
ufcr = imx_uart_readl(sport, UFCR);
20422049
if ((ufcr & UFCR_RXTL_MASK) == 0)
2043-
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
2050+
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, sport->rxtl);
20442051
imx_uart_start_rx(port);
20452052
}
20462053

@@ -2302,7 +2309,7 @@ imx_uart_console_setup(struct console *co, char *options)
23022309
else
23032310
imx_uart_console_get_options(sport, &baud, &parity, &bits);
23042311

2305-
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
2312+
imx_uart_setup_ufcr(sport, TXTL_DEFAULT, sport->rxtl);
23062313

23072314
retval = uart_set_options(&sport->port, co, baud, parity, bits, flow);
23082315

0 commit comments

Comments
 (0)