summaryrefslogtreecommitdiffstats
path: root/kernel/printk/nbcon.c
diff options
context:
space:
mode:
authorJohn Ogness <john.ogness@linutronix.de>2024-09-04 14:05:24 +0200
committerPetr Mladek <pmladek@suse.com>2024-09-04 15:56:32 +0200
commitfb9fabf3d86216961d1103ecbc33e98d5f6c48f5 (patch)
tree055350c243e9ec4761c8171fbcd50e7353b2fddc /kernel/printk/nbcon.c
parentprintk: nbcon: Add context to usable() and emit() (diff)
downloadlinux-fb9fabf3d86216961d1103ecbc33e98d5f6c48f5.tar.xz
linux-fb9fabf3d86216961d1103ecbc33e98d5f6c48f5.zip
printk: nbcon: Init @nbcon_seq to highest possible
When initializing an nbcon console, have nbcon_alloc() set @nbcon_seq to the highest possible sequence number. For all practical purposes, this will guarantee that the console will have nothing to print until later when @nbcon_seq is set to the proper initial printing value. This will be particularly important once kthread printing is introduced because nbcon_alloc() can create/start the kthread before the desired initial sequence number is known. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20240904120536.115780-6-john.ogness@linutronix.de Signed-off-by: Petr Mladek <pmladek@suse.com>
Diffstat (limited to 'kernel/printk/nbcon.c')
-rw-r--r--kernel/printk/nbcon.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 88db24f9a8de..bc684ff5028a 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1397,7 +1397,13 @@ bool nbcon_alloc(struct console *con)
struct nbcon_state state = { };
nbcon_state_set(con, &state);
- atomic_long_set(&ACCESS_PRIVATE(con, nbcon_seq), 0);
+
+ /*
+ * Initialize @nbcon_seq to the highest possible sequence number so
+ * that practically speaking it will have nothing to print until a
+ * desired initial sequence number has been set via nbcon_seq_force().
+ */
+ atomic_long_set(&ACCESS_PRIVATE(con, nbcon_seq), ULSEQ_MAX(prb));
if (con->flags & CON_BOOT) {
/*