Re: [PATCH 6/8] printk: Do not set Braille console as preferred_console

From: Petr Mladek

Date: Thu Feb 19 2026 - 09:55:44 EST


On Mon 2026-02-16 17:13:10, John Ogness wrote:
> On 2026-02-06, Petr Mladek <pmladek@xxxxxxxx> wrote:
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index 279b36ef90bd..eb224eaace64 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -365,6 +365,7 @@ static int console_locked;
> > static struct preferred_console preferred_consoles[MAX_PREFERRED_CONSOLES];
> >
> > static int preferred_dev_console = -1;
> > +static int preferred_dev_console_prev = -1;
> > static bool want_braille_console;
> > int console_set_on_cmdline;
> > EXPORT_SYMBOL(console_set_on_cmdline);
> > @@ -2555,10 +2556,23 @@ static int update_preferred_console(int i, const char *name, const short idx,
> >
> > braille_update_options(pc, brl_options);
> >
> > - if (brl_options)
> > + if (brl_options) {
> > want_braille_console = true;
> > - else
> > + /*
> > + * This console name will always get enabled as Braille
> > + * console. It takes special code paths in register_console().
> > + * Do not treat it as a normal preferred_console.
> > + */
> > + if (preferred_dev_console == i)
> > + preferred_dev_console = preferred_dev_console_prev;
>
> I am wondering if in this case it should also do:
>
> preferred_dev_console_prev = -1;
>
> to make sure that @preferred_dev_console never ends up at a Braille
> device.

Great catch!

> > + } else {
> > + /*
> > + * Only the VisioBraille device is supported at the moment.
> > + * One level history should be enough.
> > + */
> > + preferred_dev_console_prev = preferred_dev_console;
> > preferred_dev_console = i;
> > + }

We actually also need to prevent setting "preferred_dev_console" when
the same console has been preferred as Braille before, for example:

console=brl,ttyS0,115200 console=ttyS0,115200

One might argue that the later definition should win. But it would
be a regression.

The motivation to keep the current behavior is that the Braille console
is special. IMHO, it should always win. Otherwise, the user might have
hard times to debug the problem.

My new version of this code is:

/*
* The last preferred console should get associated with /dev/console.
* Except for the Braille console which can't get associated with
* /dev/console. One level history should be enough because only one,
* the VisioBraille device, is supported at the moment.
*/
if (brl_options) {
want_braille_console = true;
if (preferred_dev_console == i) {
preferred_dev_console = preferred_dev_console_prev;
preferred_dev_console_prev = -1;
}
} else if (!is_braille_console_preferred(pc)) {
preferred_dev_console_prev = preferred_dev_console;
preferred_dev_console = i;
}

Best Regards,
Petr