diff --git a/kernel/reboot.c b/kernel/reboot.c index ceca51aed998df4017c4b28fa41a037deb4b6bd2..ef90b7cf105603660e9c93444e66e4008f4e5f2c 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -48,6 +48,8 @@ int reboot_cpu; enum reboot_type reboot_type = BOOT_ACPI; int reboot_force; +static bool reboot_lava_test_mode; + /** * emergency_restart - reboot the system * @@ -235,6 +237,9 @@ void migrate_to_reboot_cpu(void) */ void kernel_restart(char *cmd) { + if (reboot_lava_test_mode) + return do_kernel_restart(cmd); + kernel_restart_prepare(cmd); migrate_to_reboot_cpu(); syscore_shutdown(); @@ -354,6 +359,11 @@ static int sys_off_handler_power_off(struct notifier_block *nb, struct sys_off_handler *h; int ret = NOTIFY_DONE; + if (reboot_lava_test_mode) { + pr_emerg("power-off test: okay\n"); + return NOTIFY_DONE; + } + priv = container_of(nb, struct sys_off_handler_private_data, power_off_nb); h = container_of(priv, struct sys_off_handler, priv); prep_data.cb_data = h->cb_data; @@ -395,6 +405,11 @@ static int sys_off_handler_restart(struct notifier_block *nb, struct restart_data data = {}; struct sys_off_handler *h; + if (reboot_lava_test_mode) { + pr_emerg("restart test: okay\n"); + return NOTIFY_DONE; + } + priv = container_of(nb, struct sys_off_handler_private_data, restart_nb); h = container_of(priv, struct sys_off_handler, priv); @@ -415,6 +430,11 @@ static int sys_off_handler_reboot(struct notifier_block *nb, struct reboot_prep_data data = {}; struct sys_off_handler *h; + if (reboot_lava_test_mode) { + pr_emerg("reboot test: okay\n"); + return NOTIFY_DONE; + } + priv = container_of(nb, struct sys_off_handler_private_data, reboot_nb); h = container_of(priv, struct sys_off_handler, priv); @@ -805,6 +825,9 @@ static void do_kernel_power_off_prepare(void) */ void kernel_power_off(void) { + if (reboot_lava_test_mode) + return do_kernel_power_off(); + kernel_shutdown_prepare(SYSTEM_POWER_OFF); do_kernel_power_off_prepare(); migrate_to_reboot_cpu(); @@ -1231,6 +1254,17 @@ static int __init reboot_setup(char *str) } __setup("reboot=", reboot_setup); +static int __init reboot_lava_test_setup(char *str) +{ + if (!strcmp(str, "1")) { + pr_info("enabled reboot_lava_test_mode\n"); + reboot_lava_test_mode = 1; + } + + return 1; +} +__setup("reboot_lava_test=", reboot_lava_test_setup); + #ifdef CONFIG_SYSFS #define REBOOT_COLD_STR "cold"