diff options
author | Dima Zavin <dima@android.com> | 2011-08-23 15:56:50 -0700 |
---|---|---|
committer | Mattias Nissler <mnissler@google.com> | 2016-07-20 16:17:57 +0200 |
commit | 229ea9a06c6bb9aa63bd6f638df8bd340a4cb02c (patch) | |
tree | 420f58dd2305cce2a02e4c628fad82384ff63de6 | |
parent | 5169afcde1d7816a5a32663d0e49a7f237ad8101 (diff) | |
download | v4.4-229ea9a06c6bb9aa63bd6f638df8bd340a4cb02c.tar.gz |
ANDROID: ARM: add option to flush console before reboot
If the console_lock was held while the system was rebooted, the messages
in the temporary logbuffer would not have propogated to all the console
drivers.
This force releases the console lock if it failed to be acquired.
Signed-off-by: Dima Zavin <dima@android.com>
Bug: None
Patchset: arm-flush-console-on-reboot
Signed-off-by: Mattias Nissler <mnissler@google.com>
Change-Id: I76b279e77394f10932ddcd744ecc2ead300c0382
-rw-r--r-- | arch/arm/Kconfig | 9 | ||||
-rw-r--r-- | arch/arm/kernel/reboot.c | 30 |
2 files changed, 39 insertions, 0 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a1b8ca129a8a..05450caaff95 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1825,6 +1825,15 @@ config XEN help Say Y if you want to run Linux in a Virtual Machine on Xen on ARM. +config ARM_FLUSH_CONSOLE_ON_RESTART + bool "Force flush the console on restart" + help + If the console is locked while the system is rebooted, the messages + in the temporary logbuffer would not have propogated to all the + console drivers. This option forces the console lock to be + released if it failed to be acquired, which will cause all the + pending messages to be flushed. + endmenu menu "Boot options" diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c index 38269358fd25..1a06da8f0366 100644 --- a/arch/arm/kernel/reboot.c +++ b/arch/arm/kernel/reboot.c @@ -6,6 +6,7 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#include <linux/console.h> #include <linux/cpu.h> #include <linux/delay.h> #include <linux/reboot.h> @@ -124,6 +125,31 @@ void machine_power_off(void) pm_power_off(); } +#ifdef CONFIG_ARM_FLUSH_CONSOLE_ON_RESTART +void arm_machine_flush_console(void) +{ + printk("\n"); + pr_emerg("Restarting %s\n", linux_banner); + if (console_trylock()) { + console_unlock(); + return; + } + + mdelay(50); + + local_irq_disable(); + if (!console_trylock()) + pr_emerg("arm_restart: Console was locked! Busting\n"); + else + pr_emerg("arm_restart: Console was locked!\n"); + console_unlock(); +} +#else +void arm_machine_flush_console(void) +{ +} +#endif + /* * Restart requires that the secondary CPUs stop performing any activity * while the primary CPU resets the system. Systems with a single CPU can @@ -140,6 +166,10 @@ void machine_restart(char *cmd) local_irq_disable(); smp_send_stop(); + /* Flush the console to make sure all the relevant messages make it + * out to the console drivers */ + arm_machine_flush_console(); + if (arm_pm_restart) arm_pm_restart(reboot_mode, cmd); else |