From d8e5fc3002294a28af53e97f6c83a35956e738f3 Mon Sep 17 00:00:00 2001 From: Petr Mladek Date: Tue, 13 Oct 2026 17:41:41 +0200 Subject: [PATCH 1/3] nbcon/reboot: Switch NBCON consoles into the emergency mode in emergency_restart() When the system is going down a normal way, the NBCON kthreads are flushed and stopped properly via a syscore shutdown callback, see printk_kthreads_shutdown(). One missing piece is emergency_restart() where the kthreads are not stopped. It might be called from several non-panic code paths, e.g. sysrq-o, kdb_reboot(), or some watchdogs. Fix it by explicitly entering the emergency (atomic) mode and trying to flush the consoles there. Note that printk_trigger_flush() must be used instead of pr_flush() because the later is not safe in an atomic context. Reported-by: kernel test robot Closes: https://lore.kernel.org/all/202608061008.48a1e76e-lkp@intel.com/ Suggested-by: John Ogness Reviewed-by: John Ogness Link: https://patch.msgid.link/20261013154141.94016-1-pmladek@suse.com Signed-off-by: Petr Mladek --- kernel/reboot.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/reboot.c b/kernel/reboot.c index f070c5c1103a..9f822246a9de 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) "reboot: " fmt #include +#include #include #include #include @@ -93,6 +94,14 @@ void emergency_restart(void) { kmsg_dump(KMSG_DUMP_EMERG); system_state = SYSTEM_RESTART; + + /* + * NBCON kthreads won't be flushed and stopped properly in + * the emergency restart. Move them to the atomic mode. + */ + nbcon_cpu_emergency_enter(); + printk_trigger_flush(); + machine_emergency_restart(); } EXPORT_SYMBOL_GPL(emergency_restart); From 19ed235c1adcaf40f05997dfe8b96eb209effd35 Mon Sep 17 00:00:00 2001 From: Muhammad Mahdi Amirpour Date: Tue, 13 Oct 2026 18:43:00 +0330 Subject: [PATCH 2/3] printk: fix kernel-doc name for nbcon_write_context_is_braille Use the function name in the kerneldoc description. Fixes: c83e3d291243 ("braille: nbcon: Allow to use a serial console with NBCON API as Braille console") Signed-off-by: Muhammad Mahdi Amirpour Reviewed-by: John Ogness Link: https://patch.msgid.link/20261013151300.75966-1-ampr.mhd@gmail.com Signed-off-by: Petr Mladek --- kernel/printk/nbcon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c index fb1b37741952..5f8afaca8866 100644 --- a/kernel/printk/nbcon.c +++ b/kernel/printk/nbcon.c @@ -2005,7 +2005,8 @@ void nbcon_kdb_release(struct nbcon_write_context *wctxt) } /** - * nbcon_is_braille - Checks whether the nbcon write context is using Braille console + * nbcon_write_context_is_braille - Checks whether the nbcon write context + * is using Braille console * * @wctxt: checked nbcon write context * From 5f339c46f153184570f16c8e789c9709b14cbe8b Mon Sep 17 00:00:00 2001 From: John Ogness Date: Fri, 16 Oct 2026 11:00:34 +0206 Subject: [PATCH 3/3] printk: Postpone kthread startup There have been various bug reports related to SMP systems hanging on boot. The reports vary but seem to have some overlap with regard to missed IPI's during SMP setup. The reports also show that reverting NBCON console usage allows the bugs to disappear. The NBCON kthreads for console printing are started very early during boot using early_initcall(). Since these kthreads are asynchronously enabling/disabling interrupts during early boot, they may be interfering with early SMP setup on some hardware platforms. Starting the console printing kthreads later has shown to avoid the hanging on systems that could previously reproduce the issue. Postpone kthread starting until after all arch initcalls have completed. Reported-by: Derek Barbosa Closes: https://lore.kernel.org/linux-rt-users/arPmYPbFLf2EldIl@debarbos-thinkpadt14gen5.rmtusma.csb Fixes: 76f258bf3f2a ("printk: nbcon: Introduce printer kthreads") Signed-off-by: John Ogness Tested-by: Derek Barbosa Link: https://patch.msgid.link/20261016085441.857695-1-john.ogness@linutronix.de Signed-off-by: Petr Mladek --- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 6d3d18a50da7..bc3b9f6e404b 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3862,7 +3862,7 @@ static int __init printk_set_kthreads_ready(void) return 0; } -early_initcall(printk_set_kthreads_ready); +subsys_initcall(printk_set_kthreads_ready); #endif /* CONFIG_PRINTK */ static int __read_mostly keep_bootcon;