mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Chris Down <chris@chrisdown.name>
Cc: John Ogness <john.ogness@linutronix.de>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Marcos Paulo de Souza <mpdesouza@suse.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/8] printk: Separate code for adding/updating preferred console metadata
Date: Thu, 19 Feb 2026 17:51:29 +0100	[thread overview]
Message-ID: <aZc_kfghxwE_PGyX@pathway.suse.cz> (raw)
In-Reply-To: <aZci0XyxgnUuuXrQ@chrisdown.name>

On Thu 2026-02-19 22:48:49, Chris Down wrote:
> Petr Mladek writes:
> > @@ -2531,28 +2587,14 @@ static int __add_preferred_console(const char *name, const short idx,
> > 	for (i = 0, pc = preferred_consoles;
> > 	     i < MAX_PREFERRED_CONSOLES && (pc->name[0] || pc->devname[0]);
> > 	     i++, pc++) {
> > -		if ((name && strcmp(pc->name, name) == 0 && pc->index == idx) ||
> > -		    (devname && strcmp(pc->devname, devname) == 0)) {
> > -			if (!brl_options)
> > -				preferred_dev_console = i;
> > -			set_user_specified(pc, user_specified);
> > -			return 0;
> > -		}
> 
> So, in this old code when __add_preferred_console() finds an existing
> matching entry, it returns immediately without touching the options at all.
> 
> But in the new patch the loop breaks out and falls through to
> update_preferred_console(), which only conditionally updates options.
> 
> This has different behaviour. For example if you imagine SPCR/DT setting the
> options, before they win out against the command line, but now they do not.
> 
> This may well be intended, since the user cmdline probably should win over
> the platform defaults anyway. I'd argue that sounds like the right behaviour
> anyway. But I don't see this change being mentioned as intentional in the
> changelog. Is it?  If it is, let's mention it there.

Good point!

I considered this as a bug fix and I described this in the last
paragraph of the commit message:

<paste>
While this is primarily a refactoring, it fixes two minor behavioral
consistencies: console options can now be overridden via the command
line, and Braille options are preserved even if a non-Braille console
with the same name was previously defined.
</paste>


I hope that this change should be on the safe size because:

  1. People should be able to override any default value on the
     command line. It seems to be the only sane approach.

  2. 20 of 33 add_preferred_console() callers do not pass options[*]

  3. I somehow hooped that add_preferred_console() is mostly called
     before the command line is proceed. Otherwise, the command line
     would not be able to overwrite the options. Also /dev/console
     is supposed to be associated with the last console= defined
     on the command line.

     I have to admit that I checked this only on x86_64 where the spcr
     is handled before the command line, see:

       + setup_arch()
	 + acpi_boot_init()
	   + acpi_parse_spcr()

      Hmm, I see that the device tree seems to be handled later, for example,

	+ serial_core_add_one_port()
	  + of_console_check()


Honestly, I am a bit afraid of regressions caused by this change.
But I hope that it will be a corner case and users might
be persuaded that their command line was bogus.

As I said, people should be able to override the defaults via the
command line. And I do not see any other way how to achieve it.

By other words, the sooner we enforce a sane rule the better.
I hope that it is not too late. And the only way to check it
in the real life is to try it. /o\.

But you are right, I should be more clear about this in
the commit message. I am going to improve it in v2.

[*] 

$> git grep add_preferred_console | grep -v -e "__add_pre" -e "xen_add_pref" -e "printk" -e "console.h" | wc -l
33
$> git grep add_preferred_console | grep -v -e "__add_pre" -e "xen_add_pref" -e "printk" -e "console.h" | grep ", NULL);" | wc -l
20


Best Regards,
Petr

  reply	other threads:[~2026-02-19 16:51 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-06 16:49 [PATCH 0/8] printk: Clean up preferred console handling Petr Mladek
2026-02-06 16:49 ` [PATCH 1/8] printk: Rename struct console_cmdline to preferred_console Petr Mladek
2026-02-19 14:40   ` Chris Down
2026-02-19 18:34   ` Marcos Paulo de Souza
2026-02-06 16:49 ` [PATCH 2/8] printk: Rename preferred_console to preferred_dev_console Petr Mladek
2026-02-19 14:41   ` Chris Down
2026-02-19 18:37   ` Marcos Paulo de Souza
2026-02-06 16:49 ` [PATCH 3/8] printk: Separate code for adding/updating preferred console metadata Petr Mladek
2026-02-16 14:05   ` John Ogness
2026-02-19 12:46     ` Petr Mladek
2026-02-19 14:06       ` John Ogness
2026-02-19 14:48   ` Chris Down
2026-02-19 16:51     ` Petr Mladek [this message]
2026-02-06 16:49 ` [PATCH 4/8] printk: Cleanup _braille_(un)register_console() wrappers Petr Mladek
2026-02-19 14:49   ` Chris Down
2026-02-19 18:50   ` Marcos Paulo de Souza
2026-02-06 16:49 ` [PATCH 5/8] printk: Try to register each console as Braille first Petr Mladek
2026-02-19 14:59   ` Chris Down
2026-02-19 16:59     ` Petr Mladek
2026-02-20  4:52       ` Chris Down
2026-02-20 11:43         ` Petr Mladek
2026-02-06 16:50 ` [PATCH 6/8] printk: Do not set Braille console as preferred_console Petr Mladek
2026-02-16 16:07   ` John Ogness
2026-02-19 14:55     ` Petr Mladek
2026-02-19 15:35       ` John Ogness
2026-02-19 15:03   ` Chris Down
2026-02-06 16:50 ` [PATCH 7/8] printk: Handle pre-enabled consoles directly in register_console() Petr Mladek
2026-02-19 15:03   ` Chris Down
2026-02-06 16:50 ` [PATCH 8/8] printk: Try enable preferred consoles only when there are any Petr Mladek
2026-02-19 15:16   ` Chris Down
2026-02-17  8:56 ` [PATCH 0/8] printk: Clean up preferred console handling John Ogness
2026-02-19 15:20 ` Chris Down

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aZc_kfghxwE_PGyX@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=chris@chrisdown.name \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpdesouza@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®