Re: [PATCH v2 1/2] printk: Revert add_preferred_console_match() related commits

Petr Mladek
2024-06-14T17:18:22Z

On Thu 2024-06-13 15:51:07, Tony Lindgren wrote:
> Recent changes to allow using DEVNAME:0.0 style console names caused a
> regression to the kernel command line handling for the console options.
>
> The last preferred console added gets used for init. This is documented
> in the comments for add_preferred_console(). Now the kernel command line
> options for console=ttyS0,115200 console=tty0 are wrongly handled and
> cause the /dev/console to be associated with ttyS0 instead of tty0.
>
> This happens because we are calling __add_preferred_console() later on
> from serial8250_isa_init_ports() after console_setup() and the console
> gets treated as the last added preferred console. As the DEVNAME:0.0 style
> console device is not known at console_setup() time, I added a call to
> __add_preferred_console() later on when the console is ready.
>
> To fix the issue, let's revert the printk related commits:
>
> f03e8c1060f8 ("printk: Save console options for add_preferred_console_match()")
> b73c9cbe4f1f ("printk: Flag register_console() if console is set on command line")
> 8a831c584e6e ("printk: Don't try to parse DEVNAME:0.0 console options")
>
> We need to also drop the call for add_preferred_console_match() from
> serial_base_add_one_prefcon() added by commit 787a1cabac01 ("serial: core:
> Add support for DEVNAME:0.0 style naming for kernel console").
>
> Petr has suggested a better way to handle the deferred consoles that does
> not rely on calling __add_preferred_console() again.
>
> Reported-by: Petr Mladek <pmladek@suse.com>
> Link: https://lore.kernel.org/linux-serial/ZlC6_Um4P4b-_WQE@pathway.suse.cz/
> Fixes: f03e8c1060f8 ("printk: Save console options for add_preferred_console_match()")
> Signed-off-by: Tony Lindgren <tony.lindgren@linux.intel.com>

It seems that it really reverts the right parts.

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr