printk: Make static printk buffers available to nbcon
authorJohn Ogness <john.ogness@linutronix.de>
Sat, 16 Sep 2023 19:20:02 +0000 (21:26 +0206)
committerPetr Mladek <pmladek@suse.com>
Mon, 18 Sep 2023 15:03:45 +0000 (17:03 +0200)
The nbcon boot consoles also need printk buffers that are available
very early. Since the nbcon boot consoles will also be serialized
by the console_lock, they can use the same static printk buffers
that the legacy consoles are using.

Make the legacy static printk buffers available outside of printk.c
so they can be used by nbcon.c.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20230916192007.608398-4-john.ogness@linutronix.de
kernel/printk/internal.h
kernel/printk/printk.c

index 2ca0ab78802c918940cb60061e4081a130c1bcca..7199d60bfc256471efbdafb28ad94eec069d66e8 100644 (file)
@@ -86,6 +86,8 @@ static inline void nbcon_cleanup(struct console *con) { }
 
 #endif /* CONFIG_PRINTK */
 
+extern struct printk_buffers printk_shared_pbufs;
+
 /**
  * struct printk_buffers - Buffers to read/format/output printk messages.
  * @outbuf:    After formatting, contains text to output.
index 5f372eaceb293f12003cb2135ebb6e37f0040bc3..17def3791bc09bd52b69f6aa4f0d9c3712ec7fba 100644 (file)
@@ -2846,6 +2846,13 @@ out:
        return true;
 }
 
+/*
+ * Used as the printk buffers for non-panic, serialized console printing.
+ * This is for legacy (!CON_NBCON) as well as all boot (CON_BOOT) consoles.
+ * Its usage requires the console_lock held.
+ */
+struct printk_buffers printk_shared_pbufs;
+
 /*
  * Print one record for the given console. The record printed is whatever
  * record is the next available record for the given console.
@@ -2863,12 +2870,10 @@ out:
  */
 static bool console_emit_next_record(struct console *con, bool *handover, int cookie)
 {
-       static struct printk_buffers pbufs;
-
        bool is_extended = console_srcu_read_flags(con) & CON_EXTENDED;
-       char *outbuf = &pbufs.outbuf[0];
+       char *outbuf = &printk_shared_pbufs.outbuf[0];
        struct printk_message pmsg = {
-               .pbufs = &pbufs,
+               .pbufs = &printk_shared_pbufs,
        };
        unsigned long flags;