[PATCH RFC 3/4] serial: esp32: Deliver and mask receive break interrupts

Vítor Hugo Silva vitorhg20080 at gmail.com
Fri Nov 27 08:55:51 PST 2026


Pass a hardware break to the TTY layer when uart_handle_break()
leaves it unhandled. This lets the line discipline apply the break
handling configured in termios.

Mask the break interrupt together with the RX FIFO interrupt in
stop_rx() so a break cannot restart receive handling. Leave the TX
interrupt mask unchanged.

A mocked interrupt test verified break delivery, handling by the
serial core and the resulting interrupt enable mask.

Signed-off-by: Vítor Hugo Silva <vitorhg20080 at gmail.com>
---
 drivers/tty/serial/esp32_uart.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/esp32_uart.c b/drivers/tty/serial/esp32_uart.c
index 0e7128a..40acff7 100644
--- a/drivers/tty/serial/esp32_uart.c
+++ b/drivers/tty/serial/esp32_uart.c
@@ -317,7 +317,8 @@ static void esp32_uart_rxint(struct uart_port *port)
 		    (esp32_uart_read(port, UART_INT_ST_REG) & UART_BRK_DET_INT)) {
 			esp32_uart_write(port, UART_INT_CLR_REG, UART_BRK_DET_INT);
 			++port->icount.brk;
-			uart_handle_break(port);
+			if (!uart_handle_break(port))
+				tty_insert_flip_char(tty_port, 0, TTY_BREAK);
 		} else {
 			if (uart_handle_sysrq_char(port, (unsigned char)rx))
 				continue;
@@ -403,7 +404,7 @@ static void esp32_uart_stop_rx(struct uart_port *port)
 	u32 int_ena;
 
 	int_ena = esp32_uart_read(port, UART_INT_ENA_REG);
-	int_ena &= ~UART_RXFIFO_FULL_INT;
+	int_ena &= ~(UART_RXFIFO_FULL_INT | UART_BRK_DET_INT);
 	esp32_uart_write(port, UART_INT_ENA_REG, int_ena);
 }
 



More information about the linux-riscv mailing list