From 03053d709b6b5cfb25ca5087cabe223987987dbd Mon Sep 17 00:00:00 2001 From: Devin Kim Date: Mon, 9 Sep 2013 13:01:19 -0700 Subject: [PATCH] panic: resume console if panic after console suspend. Device rebooted by kernel panic but no panic message. This helps to get the panic messages in this case. Bug: 10184128 Change-Id: I24545b1ce2f9e3e239795089d8564c2cc5f89fe7 Signed-off-by: shihhao.feng Signed-off-by: Devin Kim --- include/linux/console.h | 1 + kernel/panic.c | 5 +++++ kernel/printk.c | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/include/linux/console.h b/include/linux/console.h index 7201ce4280c..dffe4772a53 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -153,6 +153,7 @@ extern int braille_register_console(struct console *, int index, extern int braille_unregister_console(struct console *); extern void console_sysfs_notify(void); extern bool console_suspend_enabled; +extern int is_console_suspended(void); /* Suspend and resume console messages over PM events */ extern void suspend_console(void); diff --git a/kernel/panic.c b/kernel/panic.c index 4ffbce815c5..2bd000132e0 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -24,6 +24,7 @@ #include #include #include +#include #define PANIC_TIMER_STEP 100 #define PANIC_BLINK_SPD 18 @@ -133,6 +134,10 @@ void panic(const char *fmt, ...) kmsg_dump(KMSG_DUMP_PANIC); + /* print last_kmsg even after console suspend */ + if (is_console_suspended()) + resume_console(); + /* * Note smp_send_stop is the usual smp shutdown function, which * unfortunately means it may not be hardened to work in a panic diff --git a/kernel/printk.c b/kernel/printk.c index 8e3af827913..ecb4ce36390 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -1188,6 +1188,12 @@ module_param_named(console_suspend, console_suspend_enabled, MODULE_PARM_DESC(console_suspend, "suspend console during suspend" " and hibernate operations"); +/* check current suspend/resume status of the console */ +int is_console_suspended(void) +{ + return console_suspended; +} + /** * suspend_console - suspend the console subsystem *