Commit
d8e5fc3002294a28af53e97f6c83a35956e738f3
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 <lkp@intel.com> Closes: https://lore.kernel.org/all/202608061008.48a1e76e-lkp@intel.com/ Suggested-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: John Ogness <john.ogness@linutronix.de> Link: https://patch.msgid.link/20261013154141.94016-1-pmladek@suse.com Signed-off-by: Petr Mladek <pmladek@suse.com>
Petr Mladek <pmladek@suse.com> · 2026-10-13 15:41 UTC
1 file changed,
+9
−0
modified kernel/reboot.c
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | #define pr_fmt(fmt) "reboot: " fmt | |
| 9 | 9 | ||
| 10 | 10 | #include <linux/atomic.h> | |
| 11 | + | #include <linux/console.h> | |
| 11 | 12 | #include <linux/ctype.h> | |
| 12 | 13 | #include <linux/export.h> | |
| 13 | 14 | #include <linux/kexec.h> | |
| @@ -93,6 +94,14 @@ void emergency_restart(void) | |||
| 93 | 94 | { | |
| 94 | 95 | kmsg_dump(KMSG_DUMP_EMERG); | |
| 95 | 96 | system_state = SYSTEM_RESTART; | |
| 97 | + | ||
| 98 | + | /* | |
| 99 | + | * NBCON kthreads won't be flushed and stopped properly in | |
| 100 | + | * the emergency restart. Move them to the atomic mode. | |
| 101 | + | */ | |
| 102 | + | nbcon_cpu_emergency_enter(); | |
| 103 | + | printk_trigger_flush(); | |
| 104 | + | ||
| 96 | 105 | machine_emergency_restart(); | |
| 97 | 106 | } | |
| 98 | 107 | EXPORT_SYMBOL_GPL(emergency_restart); | |