Skip to content

Commit d818b56

Browse files
jognesspmladek
authored andcommitted
printk: Make static printk buffers available to nbcon
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
1 parent 3a5bb25 commit d818b56

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

kernel/printk/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ static inline void nbcon_cleanup(struct console *con) { }
8686

8787
#endif /* CONFIG_PRINTK */
8888

89+
extern struct printk_buffers printk_shared_pbufs;
90+
8991
/**
9092
* struct printk_buffers - Buffers to read/format/output printk messages.
9193
* @outbuf: After formatting, contains text to output.

kernel/printk/printk.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2846,6 +2846,13 @@ static bool printk_get_next_message(struct printk_message *pmsg, u64 seq,
28462846
return true;
28472847
}
28482848

2849+
/*
2850+
* Used as the printk buffers for non-panic, serialized console printing.
2851+
* This is for legacy (!CON_NBCON) as well as all boot (CON_BOOT) consoles.
2852+
* Its usage requires the console_lock held.
2853+
*/
2854+
struct printk_buffers printk_shared_pbufs;
2855+
28492856
/*
28502857
* Print one record for the given console. The record printed is whatever
28512858
* record is the next available record for the given console.
@@ -2863,12 +2870,10 @@ static bool printk_get_next_message(struct printk_message *pmsg, u64 seq,
28632870
*/
28642871
static bool console_emit_next_record(struct console *con, bool *handover, int cookie)
28652872
{
2866-
static struct printk_buffers pbufs;
2867-
28682873
bool is_extended = console_srcu_read_flags(con) & CON_EXTENDED;
2869-
char *outbuf = &pbufs.outbuf[0];
2874+
char *outbuf = &printk_shared_pbufs.outbuf[0];
28702875
struct printk_message pmsg = {
2871-
.pbufs = &pbufs,
2876+
.pbufs = &printk_shared_pbufs,
28722877
};
28732878
unsigned long flags;
28742879

0 commit comments

Comments
 (0)