Revert "serial: 8250: Clear CON_PRINTBUFFER on port re-registration"

This reverts commit d338ab1d90.

uart_console() only indicates that the port is selected as the console.
It does not mean that the console has already been registered or has
printed the buffered messages.

On platforms where an initial 8250 port is replaced when the real UART
device is registered, clearing CON_PRINTBUFFER causes the console to
start at the end of the printk ring buffer. Without earlycon, all
messages logged before UART registration are therefore lost.

Fixes: d338ab1d90 ("serial: 8250: Clear CON_PRINTBUFFER on port re-registration")
Reported-by: Mark Brown <broonie@kernel.org>
Reported-by: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
Link: https://lore.kernel.org/all/20260522101042.21976-1-fushuai.wang@linux.dev/
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
Reviewed-by: John Ogness <john.ogness@linutronix.de>
Link: https://patch.msgid.link/20260724093151.53216-1-fushuai.wang@linux.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Fushuai Wang 2026-07-24 17:31:51 +08:00 committed by Greg Kroah-Hartman
parent a5339effdd
commit 57c0741b8c

View File

@ -720,12 +720,8 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)
/* Preserve specified console flow control. */
cons_flow = uart_cons_flow_enabled(&uart->port);
if (uart->port.dev) {
if (uart_console(&uart->port))
uart->port.cons->flags &= ~CON_PRINTBUFFER;
if (uart->port.dev)
uart_remove_one_port(&serial8250_reg, &uart->port);
}
uart->port.ctrl_id = up->port.ctrl_id;
uart->port.port_id = up->port.port_id;