[PATCH v5 09/16] printk: Allow to override options via the command line
From: Petr Mladek
Date: Tue Sep 29 2026 - 08:09:25 EST
Consoles can be preferred either via the console= command line parameter
or by some platform specific code, e.g. SPCR, device tree.
Historically, the preferred console options are stored only by the first
caller who prefers the particular console. The ordering is:
1. acpi_parse_spcr() is called via setup_arch(). Also some platforms,
for example, s390, powerpc, x86 Xen, explicitly call
add_preferred_console() before or in setup_arch().
2. console= command line parameter adds the preferred consoles via
console_setup().
3. The device tree is read in setup_arch(), see unflatten_device_tree().
But the preferred console entries are added later when probing
particular devices in do_initcalls(), see of_console_check().
It means that users could override console options via the command line
only for entries defined via the device tree but not for entries added
via SPCR or another platform-specific code.
I looks like a bug. It should always be possible to override any
platform-specific defaults via the command line. Also it is usual
that the last variant wins.
Be conservative when Braille console is wanted and prefer the Braille
variant.
The change might theoretically break setups where users passed wrong
console options and they used to be ignored. But the fix seems to
be worth the risk.
Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
---
kernel/printk/printk.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 4670787195d1..b458a920ce5a 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2563,6 +2563,9 @@ asmlinkage __visible void early_printk(const char *fmt, ...)
*
* 2. Only matching entries can be updated.
*
+ * 3. Allow to override @options via the command line. Last one wins
+ * except that the Braille variant is preferred.
+ *
* [*] A valid @name and @idx will get assigned for a devname later when
* @devname matches during the device initialization, see
* match_devname_and_update_preferred_console().
@@ -2632,10 +2635,11 @@ static int add_or_update_preferred_console(unsigned int i,
}
/*
- * Historically, the preferred options are stored only by the first
- * caller who prefers the particular console.
+ * Allow to override options via the command line but always
+ * prefer the Braille variant.
*/
- if (is_new_entry) {
+ if (is_new_entry || brl_options ||
+ (user_specified && !is_braille_console_preferred(pc))) {
pc->options = options;
braille_set_options(pc, brl_options);
}
--
2.55.0