From: Au Dang When SCI0 (PORT_SCI) is the system console on RZ/G2UL, the board can hang at the serial console output stage during boot. ftrace shows the following sequence: 1. sci_transmit_chars() is draining the TX kfifo through TXI interrupts with SCSCR=0xf0 (TE=1, TIE=1, RE=1, RIE=1). 2. serial_console_write() runs in the middle of that drain. It saves SCSCR=0xf0, switches to polling by writing SCSCR=0x30 (TE=1, TIE=0) and outputs the characters with sci_poll_put_char(). 3. It then restores SCSCR=0xf0 in a single write. TE is 1 both before and after, so there is no TE transition. 4. sci_start_tx() is then called repeatedly with SCSCR unchanged, but no TXI is ever raised again, so the drain never resumes and the console hangs. The RZ/G2UL User's Manual (section 23.3.6, "SCI Initialization") notes that changing SCR.TE from 1 to 0 or from 0 to 1 while SCR.TIE is 1 generates a TXI interrupt request. Without a TE transition, the TXI that would restart the drain is never generated. For PORT_SCI, restore SCSCR in two steps: first with TE cleared, then with the full saved value. This forces the TE 1->0->1 transition while TIE is being re-enabled, so TXI fires and the interrupted drain resumes. Signed-off-by: Au Dang Signed-off-by: Biju Das --- v1->v2: * No change. --- drivers/tty/serial/sh-sci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index aa179c787487..993f330e6881 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -3445,10 +3445,14 @@ static void serial_console_write(struct console *co, const char *s, cpu_relax(); /* restore the SCSCR */ - if (sci_port->ops->finish_console_write) + if (sci_port->ops->finish_console_write) { sci_port->ops->finish_console_write(port, ctrl); - else + } else { + if (to_sci_port(port)->type == PORT_SCI) + sci_port->ops->write_reg(port, regs->control, ctrl & ~SCSCR_TE); + sci_port->ops->write_reg(port, regs->control, ctrl); + } if (locked) uart_port_unlock_irqrestore(port, flags); -- 2.43.0