Re: [PATCH v3] serial: 8250: Clear CON_PRINTBUFFER on port re-registration
From: Anirudh Srinivasan
Date: Mon Jul 20 2026 - 15:22:31 EST
Hi Fushuai,
On Fri, May 22, 2026 at 06:10:42PM +0800, Fushuai Wang wrote:
> From: Fushuai Wang <wangfushuai@xxxxxxxxx>
>
> When two PnP devices map to the same physical port, the serial8250 driver
> removes and re-registers the console structure for the same port.
>
> During re-registration, the console structure still has CON_PRINTBUFFER set
> from the initial registration, which causes console_init_seq() to set
> console->seq to syslog_seq. This results in re-printing the entire
> system log buffer, which may lead to RCU stall on slow serial consoles.
>
> Clear CON_PRINTBUFFER when re-registering a port to prevent duplicate
> log printing.
>
> Fixes: 835d844d1a28 ("8250_pnp: do pnp probe before legacy probe")
> Suggested-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Fushuai Wang <wangfushuai@xxxxxxxxx>
> ---
> V2->V3: Clear CON_PRINTBUFFER when remove the port
> V1->V2: Add Fixes tag
>
> drivers/tty/serial/8250/8250_core.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
Seems like this patch was added in next-20261717.
I'm noticing that this patch is causing no serial output to be visible
on riscv boards till the uart device is registered. Normally while
booting, we expect for all the prints made before this to be
buffered and appear post serial device initialization.
=> booti 0x11000000 0x21000000:${initrd_size} 0x31000000
Moving Image from 0x11000000 to 0x200000, end=1ca6000
[ 161.301] ## Flattened Device Tree blob at 31000000
[ 161.302] Booting using the fdt blob at 0x31000000
[ 161.307] Loading Ramdisk to 7653e000, end 7dd81853 ... OK
[ 161.366] Loading Device Tree to 0000000076532000, end 000000007653d25d ... OK
Starting kernel ...
[ 0.235159] printk: legacy console [ttyS0] enabled
[ 0.238787] /soc/i2c@d401d800/pmic@41: Fixed dependency cycle(s) with /soc/i2c@d401d800/pmic@41/regulators/buck5
Most devs who are debugging might be booting with the earlycon boot
parameter. If earlycon is present, serial output is present, but
with earlycon missing (which is what most distros use), I don't get
any serial output till this point.
I observed this on a Milk-V Jupiter and a Hifive Premier P550. Same
behaviour in both cases.
Regards
Anirudh Srinivasan
>
> diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
> index a428e88938eb..5419f1d22d47 100644
> --- a/drivers/tty/serial/8250/8250_core.c
> +++ b/drivers/tty/serial/8250/8250_core.c
> @@ -716,8 +716,12 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
> if (uart->port.type == PORT_8250_CIR)
> return -ENODEV;
>
> - if (uart->port.dev)
> + if (uart->port.dev) {
> + if (uart_console(&uart->port))
> + uart->port.cons->flags &= ~CON_PRINTBUFFER;
> +
> uart_remove_one_port(&serial8250_reg, &uart->port);
> + }
>
> uart->port.ctrl_id = up->port.ctrl_id;
> uart->port.port_id = up->port.port_id;
> --
> 2.36.1
>