Skip to content

Commit 17b6557

Browse files
Raul E Rangelpmladek
authored andcommitted
init: Don't proxy console= to earlycon
Today we are proxying the `console=` command line args to the `param_setup_earlycon()` handler. This is done because the following are equivalent: console=uart[8250],mmio,<addr>[,options] earlycon=uart[8250],mmio,<addr>[,options] Both invocations enable an early `bootconsole`. `console=uartXXXX` is just an alias for `earlycon=uartXXXX`. In addition, when `earlycon=` (empty value) or just `earlycon` (no value) is specified on the command line, we enable the earlycon `bootconsole` specified by the SPCR table or the DT. The problem arises when `console=` (empty value) is specified on the command line. It's intention is to disable the `console`, but what happens instead is that the SPRC/DT console gets enabled. This happens because we are proxying the `console=` (empty value) parameter to the `earlycon` handler. The `earlycon` handler then sees that the parameter value is empty, so it enables the SPCR/DT `bootconsole`. This change makes it so that the `console` or `console=` parameters no longer enable the SPCR/DT `bootconsole`. I also cleans up the hack in `main.c` that would forward the `console` parameter to the `earlycon` handler. Signed-off-by: Raul E Rangel <rrangel@chromium.org> Reviewed-by: Petr Mladek <pmladek@suse.com> Tested-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20240911123507.v2.1.Id08823b2f848237ae90ce5c5fa7e027e97c33ad3@changeid Signed-off-by: Petr Mladek <pmladek@suse.com>
1 parent c903327 commit 17b6557

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

drivers/tty/serial/earlycon.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,29 @@ static int __init param_setup_earlycon(char *buf)
248248
}
249249
early_param("earlycon", param_setup_earlycon);
250250

251+
/*
252+
* The `console` parameter is overloaded. It's handled here as an early param
253+
* and in `printk.c` as a late param. It's possible to specify an early
254+
* `bootconsole` using `earlycon=uartXXXX` (handled above), or via
255+
* the `console=uartXXX` alias. See the comment in `8250_early.c`.
256+
*/
257+
static int __init param_setup_earlycon_console_alias(char *buf)
258+
{
259+
/*
260+
* A plain `console` parameter must not enable the SPCR `bootconsole`
261+
* like a plain `earlycon` does.
262+
*
263+
* A `console=` parameter that specifies an empty value is used to
264+
* disable the `console`, not the `earlycon` `bootconsole`. The
265+
* disabling of the `console` is handled by `printk.c`.
266+
*/
267+
if (!buf || !buf[0])
268+
return 0;
269+
270+
return param_setup_earlycon(buf);
271+
}
272+
early_param("console", param_setup_earlycon_console_alias);
273+
251274
#ifdef CONFIG_OF_EARLY_FLATTREE
252275

253276
int __init of_setup_earlycon(const struct earlycon_id *match,

init/main.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,7 @@ static int __init do_early_param(char *param, char *val,
754754
const struct obs_kernel_param *p;
755755

756756
for (p = __setup_start; p < __setup_end; p++) {
757-
if ((p->early && parameq(param, p->str)) ||
758-
(strcmp(param, "console") == 0 &&
759-
strcmp(p->str, "earlycon") == 0)
760-
) {
757+
if (p->early && parameq(param, p->str)) {
761758
if (p->setup_func(val) != 0)
762759
pr_warn("Malformed early option '%s'\n", param);
763760
}

0 commit comments

Comments
 (0)