On Tue, Nov 19, 2019 at 3:30 AM Petr Mladek <pmladek@xxxxxxxx> wrote: > > On Mon 2019-11-18 13:38:04, Jonathan Richardson wrote: > > On Thu, Nov 14, 2019 at 8:33 PM Sergey Senozhatsky > > <sergey.senozhatsky.work@xxxxxxxxx> wrote: > > > > > > Gosh, that part of printk is really complex. > > > > > > On (19/11/14 10:57), Petr Mladek wrote: > > > > For a proper solution we would need to match boot and real > > > > consoles that write messages into the physical device. > > > > But I am afraid that there is no support for this. > > > > > > Wouldn't those have same tty driver? > > Interesting idea. Well, do early consoles have tty driver? > > > > --- > > > > > > kernel/printk/printk.c | 16 ++++++++++++++++ > > > 1 file changed, 16 insertions(+) > > > > > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > > > index f1b08015d3fa..a84cb20acf42 100644 > > > --- a/kernel/printk/printk.c > > > +++ b/kernel/printk/printk.c > > > @@ -2690,6 +2690,19 @@ static int __init keep_bootcon_setup(char *str) > > > > > > early_param("keep_bootcon", keep_bootcon_setup); > > > > > > +static bool known_console_driver(struct console *newcon) > > > +{ > > > + struct console *con; > > > + > > > + for_each_console(con) { > > > + if (!(con->flags & CON_ENABLED)) > > > + continue; > > > + if (con->device && con->device == newcon->device) > > > + return true; > > > + } > > > + return false; > > > +} > > > + > > > /* > > > * The console driver calls this routine during kernel initialization > > > * to register the console printing procedure with printk() and to > > > @@ -2828,6 +2841,9 @@ void register_console(struct console *newcon) > > > if (newcon->flags & CON_EXTENDED) > > > nr_ext_console_drivers++; > > > > > > + if (known_console_driver(newcon)) > > > + newcon->flags &= ~CON_PRINTBUFFER; > > > + > > > if (newcon->flags & CON_PRINTBUFFER) { > > > /* > > > * console_unlock(); will print out the buffered messages > > > > Thanks. > > Jonathan, have you tried this patch, please? > Does it solve your problem? I've tried it and it doesn't solve the problem. newcon is not a known console at the time I register my second console. The only thing I can do is not replay the log by not setting CON_PRINTBUFFER and I shouldn't have to do that after reading Sergey's last response.