Lines Matching +full:reboot +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/kernel/reboot.c
8 #define pr_fmt(fmt) "reboot: " fmt
16 #include <linux/reboot.h>
23 * this indicates whether you can reboot with ctrl-alt-del: the default is yes
43 * reboot_type is still set to its default value (i.e., reboot= hasn't
45 * suppress DMI scanning for reboot quirks. Without it, it's
46 * impossible to override a faulty reboot quirk without recompiling.
57 enum sys_off_mode mode; member
65 * reboot when the reboot call was invoked with LINUX_REBOOT_CMD_POWER_OFF, but
85 * emergency_restart - reboot the system
88 * reboot the system. This is called when we know we are in
89 * trouble so this is our best effort to reboot. This is
109 * register_reboot_notifier - Register function to be called at reboot time
113 * to be called at reboot time.
125 * unregister_reboot_notifier - Unregister previously registered reboot notifier
128 * Unregisters a previously registered reboot
131 * Returns zero on success, or %-ENOENT on failure.
152 return -ENOMEM; in devm_register_reboot_notifier()
173 * register_restart_handler - Register function to be called to reset
176 * @nb->priority: Handler priority. Handlers should follow the
192 * machine_restart function calls do_kernel_restart - see below
198 * Restart handlers are expected to be registered from non-architecture
217 * unregister_restart_handler - Unregister previously registered
223 * Returns zero on success, or %-ENOENT on failure.
232 * do_kernel_restart - Execute kernel restart handler call chain
257 /* Make certain the cpu I'm about to reboot on is online */ in migrate_to_reboot_cpu()
262 current->flags |= PF_NO_SETAFFINITY; in migrate_to_reboot_cpu()
280 * kernel_restart - reboot the system
284 * Shutdown everything and perform a clean reboot.
311 * kernel_halt - halt the system
342 unsigned long mode, void *cmd) in sys_off_notify() argument
348 data.cb_data = handler->cb_data; in sys_off_notify()
349 data.mode = mode; in sys_off_notify()
351 data.dev = handler->dev; in sys_off_notify()
353 return handler->sys_off_cb(&data); in sys_off_notify()
369 if (handler->cb_data) in alloc_sys_off_handler()
370 return ERR_PTR(-EBUSY); in alloc_sys_off_handler()
379 return ERR_PTR(-ENOMEM); in alloc_sys_off_handler()
394 * register_sys_off_handler - Register sys-off handler
395 * @mode: Sys-off mode
400 * Registers system power-off or restart handler that will be invoked
401 * at the step corresponding to the given sys-off mode. Handler's callback
408 * Only one handler can be registered at the non-default priority level,
409 * otherwise ERR_PTR(-EBUSY) is returned.
412 * an ERR_PTR()-encoded error code otherwise.
415 register_sys_off_handler(enum sys_off_mode mode, in register_sys_off_handler() argument
427 switch (mode) { in register_sys_off_handler()
429 handler->list = &power_off_prep_handler_list; in register_sys_off_handler()
430 handler->blocking = true; in register_sys_off_handler()
434 handler->list = &power_off_handler_list; in register_sys_off_handler()
438 handler->list = &restart_prep_handler_list; in register_sys_off_handler()
439 handler->blocking = true; in register_sys_off_handler()
443 handler->list = &restart_handler_list; in register_sys_off_handler()
448 return ERR_PTR(-EINVAL); in register_sys_off_handler()
451 handler->nb.notifier_call = sys_off_notify; in register_sys_off_handler()
452 handler->nb.priority = priority; in register_sys_off_handler()
453 handler->sys_off_cb = callback; in register_sys_off_handler()
454 handler->cb_data = cb_data; in register_sys_off_handler()
455 handler->mode = mode; in register_sys_off_handler()
457 if (handler->blocking) { in register_sys_off_handler()
459 err = blocking_notifier_chain_register(handler->list, in register_sys_off_handler()
460 &handler->nb); in register_sys_off_handler()
462 err = blocking_notifier_chain_register_unique_prio(handler->list, in register_sys_off_handler()
463 &handler->nb); in register_sys_off_handler()
466 err = atomic_notifier_chain_register(handler->list, in register_sys_off_handler()
467 &handler->nb); in register_sys_off_handler()
469 err = atomic_notifier_chain_register_unique_prio(handler->list, in register_sys_off_handler()
470 &handler->nb); in register_sys_off_handler()
483 * unregister_sys_off_handler - Unregister sys-off handler
484 * @handler: Sys-off handler
486 * Unregisters given sys-off handler.
495 if (handler->blocking) in unregister_sys_off_handler()
496 err = blocking_notifier_chain_unregister(handler->list, in unregister_sys_off_handler()
497 &handler->nb); in unregister_sys_off_handler()
499 err = atomic_notifier_chain_unregister(handler->list, in unregister_sys_off_handler()
500 &handler->nb); in unregister_sys_off_handler()
517 * devm_register_sys_off_handler - Register sys-off handler
519 * @mode: Sys-off mode
524 * Registers resource-managed sys-off handler.
529 enum sys_off_mode mode, in devm_register_sys_off_handler() argument
536 handler = register_sys_off_handler(mode, priority, callback, cb_data); in devm_register_sys_off_handler()
539 handler->dev = dev; in devm_register_sys_off_handler()
547 * devm_register_power_off_handler - Register power-off handler
552 * Registers resource-managed sys-off handler with a default priority
553 * and using power-off mode.
569 * devm_register_restart_handler - Register restart handler
574 * Registers resource-managed sys-off handler with a default priority
575 * and using restart mode.
594 void (*platform_power_power_off_cb)(void) = data->cb_data; in platform_power_off_notify()
602 * register_platform_power_off - Register platform-level power-off callback
603 * @power_off: Power-off callback
605 * Registers power-off callback that will be called as last step
606 * of the power-off sequence. This callback is expected to be invoked
607 * for the last resort. Only one platform power-off callback is allowed
630 * unregister_platform_power_off - Unregister platform-level power-off callback
631 * @power_off: Power-off callback
633 * Unregisters previously registered platform power-off callback.
638 platform_power_off_handler->cb_data == power_off) { in unregister_platform_power_off()
659 * do_kernel_power_off - Execute kernel power-off handler call chain
661 * Expected to be called as last step of the power-off sequence.
663 * Powers off the system immediately if a power-off handler function has
671 * Register sys-off handlers for legacy PM callback. This allows in do_kernel_power_off()
672 * legacy PM callbacks temporary co-exist with the new sys-off API. in do_kernel_power_off()
675 * switched to the sys-off based APIs. in do_kernel_power_off()
688 * kernel_can_power_off - check whether system can be powered off
690 * Returns true if power-off handler is registered and system can be
701 * kernel_power_off - power_off the system
721 * Reboot system call: for obvious reasons only root may call it,
723 * so that some mistake won't make this reboot the whole machine.
724 * You can also set the meaning of the ctrl-alt-del-key here.
726 * reboot doesn't sync: do that yourself before calling this.
728 SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, in SYSCALL_DEFINE4() argument
736 if (!ns_capable(pid_ns->user_ns, CAP_SYS_BOOT)) in SYSCALL_DEFINE4()
737 return -EPERM; in SYSCALL_DEFINE4()
745 return -EINVAL; in SYSCALL_DEFINE4()
788 ret = strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1); in SYSCALL_DEFINE4()
790 ret = -EFAULT; in SYSCALL_DEFINE4()
793 buffer[sizeof(buffer) - 1] = '\0'; in SYSCALL_DEFINE4()
811 ret = -EINVAL; in SYSCALL_DEFINE4()
824 * This function gets called by ctrl-alt-del - ie the keyboard interrupt.
826 * is whether to reboot at once, or just ignore the ctrl-alt-del.
840 static const char reboot_cmd[] = "/sbin/reboot";
856 ret = -ENOMEM; in run_cmd()
869 pr_warn("Failed to start orderly reboot: forcing the issue\n"); in __orderly_reboot()
908 * orderly_poweroff - Trigger an orderly system poweroff
930 * orderly_reboot - Trigger an orderly system reboot
932 * This may be called from any context to trigger a system reboot.
933 * If the orderly reboot fails, it will force an immediate reboot.
947 return "reboot"; in hw_protection_action_str()
956 * hw_failure_emergency_action_func - emergency action work after a known delay
960 * a kernel poweroff or reboot after a configurable timeout value.
966 pr_emerg("Hardware protection timed-out. Trying forced %s\n", in hw_failure_emergency_action_func()
971 * expired. This means orderly_poweroff/reboot has not been able to in hw_failure_emergency_action_func()
994 * hw_failure_emergency_schedule - Schedule an emergency system shutdown or reboot
1000 * or reboot after a given period of time.
1014 * __hw_protection_trigger - Trigger an emergency system shutdown or reboot
1016 * @reason: Reason of emergency shutdown or reboot to be printed.
1017 * @ms_until_forced: Time to wait for orderly shutdown or reboot before
1019 * shutdown or reboot.
1022 * Initiate an emergency system shutdown or reboot in order to protect
1024 * NOTE: The request is ignored if protection shutdown or reboot is already
1026 * shutdown/reboot.
1060 else if (sysfs_streq(str, "reboot")) in hw_protection_action_parse()
1087 return -EPERM; in hw_protection_store()
1090 return -EINVAL; in hw_protection_store()
1100 enum reboot_mode *mode; in reboot_setup() local
1104 * reboot= will cause us to disable DMI checking in reboot_setup()
1110 mode = &panic_reboot_mode; in reboot_setup()
1113 mode = &reboot_mode; in reboot_setup()
1118 *mode = REBOOT_WARM; in reboot_setup()
1122 *mode = REBOOT_COLD; in reboot_setup()
1126 *mode = REBOOT_HARD; in reboot_setup()
1140 pr_err("Ignoring the CPU number in reboot= option. " in reboot_setup()
1147 *mode = REBOOT_SOFT; in reboot_setup()
1151 *mode = REBOOT_GPIO; in reboot_setup()
1176 __setup("reboot=", reboot_setup);
1224 return -EPERM; in mode_store()
1237 return -EINVAL; in mode_store()
1243 static struct kobj_attribute reboot_mode_attr = __ATTR_RW(mode);
1256 return -EPERM; in force_store()
1259 return -EINVAL; in force_store()
1301 return -EPERM; in type_store()
1316 return -EINVAL; in type_store()
1337 return -EPERM; in cpu_store()
1345 return -ERANGE; in cpu_store()
1374 .mode = 0644,
1378 .procname = "ctrl-alt-del",
1381 .mode = 0644,
1403 reboot_kobj = kobject_create_and_add("reboot", kernel_kobj); in reboot_ksysfs_init()
1405 return -ENOMEM; in reboot_ksysfs_init()