Re: [PATCH v11 4/5] x86/earlyprintk: setup earlyprintk as early as possible

Alexander Kuleshov
2015-06-10T10:36:30Z

2015-06-10 15:44 GMT+06:00 Andy Shevchenko <andriy.shevchenko@linux.intel.com>:
> You do parsing twice (still original code and your piece here), and
> honestly I don't like your approach in this form.

I just researched earlyprintk and we can use not only serial, but
vga and pciserial. What if I'll rename setup_early_serial_console
to the setup_earlyprintk_console, will add variable, something like
this

static unsigned int early = 1;

to the arch/x86/kernel/earlyprintk.c and refactor the
setup_early_serial_console as:

int __init setup_earlyprintk_console(void)
{
char *arg;

arg = strstr(boot_command_line, "earlyprintk=");
if (!arg)
return -1;

early = 0;
return setup_early_printk(arg);
}

After this we can check in the setup_earlyprintk
is it early to set other consoles or not,

while (*buf != '\0') {
....

#ifdef CONFIG_EARLY_PRINTK_EFI
if (!strncmp(buf, "efi", 3) && early)
early_console_register(&early_efi_console, keep);
#endif
....
}
early = 1;

So, when we will call setup_earlyprintk_console from the
arch/x86/kernel/head{32,64}.c, early variable will be 0 and
it allows us to setup only 'real early' consoles and when
setup_earlyprintk will be called by the do_early_param
early variable will be one and we will be able to setup
efi console and etc....

What do you think about it?