[PATCH] serial: sh: Handle HSCIF RX FIFO overflow

Marek Vasut marek.vasut+renesas at mailbox.org
Sun Sep 7 21:16:27 CEST 2025


The HSCIF RX FIFO may overflow when data are streaming from remote end
into the HSCIF while U-Boot is still starting up. In that case, HSFSR
bit RDF is set, but HSFDR field R is zero. This confuses .tstc callback
into considering RX FIFO to be empty, which leads to .getc to be never
invoked, even when user attempts to pass more input onto the command
line.

Fix this by considering the RDF flag in serial_rx_fifo_level(), which
is called from .tstc in case of no errors. If RDF flag is set, trigger
the .getc callback and let it clear the RX FIFO.

Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Nobuhiro Iwamatsu <iwamatsu.nobuhiro at renesas.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
 drivers/serial/serial_sh.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
index e4cc4ee4260..7ab62e0e90b 100644
--- a/drivers/serial/serial_sh.c
+++ b/drivers/serial/serial_sh.c
@@ -112,7 +112,16 @@ static int serial_raw_putc(struct uart_port *port, const char c)
 
 static int serial_rx_fifo_level(struct uart_port *port)
 {
-	return scif_rxfill(port);
+	int ret;
+
+	ret = scif_rxfill(port);
+	if (ret)
+		return ret;
+
+	if (sci_in(port, SCxSR) & SCxSR_RDxF(port))
+		return 1;
+
+	return 0;
 }
 
 static int sh_serial_tstc_generic(struct uart_port *port)
-- 
2.51.0



More information about the U-Boot mailing list