• Petr Mladek's avatar
    printk: Properly deal with nbcon consoles on seq init · d3ff380d
    Petr Mladek authored
    If a non-boot console is registering and boot consoles exist,
    the consoles are flushed before being unregistered. This allows
    the non-boot console to continue where the boot console left
    off.
    
    If for whatever reason flushing fails, the lowest seq found from
    any of the enabled boot consoles is used. Until now con->seq was
    checked. However, if it is an nbcon boot console, the function
    nbcon_seq_read() must be used to read seq because con->seq is
    not updated for nbcon consoles.
    
    Check if it is an nbcon boot console and if so call
    nbcon_seq_read() to read seq.
    
    Also, avoid usage of con->seq as temporary storage of the
    starting record. Instead, rename console_init_seq() to
    get_init_console_seq() and just return the value. For nbcon
    consoles set the sequence via nbcon_seq_force(), for legacy
    consoles set con->seq.
    
    The cleaned design should make sure that the value stays and is
    set before the console is added to the console list. It also
    unifies the sequence number initialization for legacy and nbcon
    consoles.
    Reviewed-by: default avatarJohn Ogness <john.ogness@linutronix.de>
    Link: https://lore.kernel.org/r/20240820063001.36405-4-john.ogness@linutronix.deSigned-off-by: default avatarPetr Mladek <pmladek@suse.com>
    d3ff380d
nbcon.c 29.9 KB