Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

reboot: move arch/x86 reboot= handling to generic kernel

Merge together the unicore32, arm, and x86 reboot= command line
parameter handling.

Signed-off-by: Robin Holt <holt@sgi.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Russ Anderson <rja@sgi.com>
Cc: Robin Holt <holt@sgi.com>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Robin Holt and committed by
Linus Torvalds
1b3a5d02 7b6d864b

+107 -145
+11 -3
Documentation/kernel-parameters.txt
··· 2681 2681 Run specified binary instead of /init from the ramdisk, 2682 2682 used for early userspace startup. See initrd. 2683 2683 2684 - reboot= [BUGS=X86-32,BUGS=ARM,BUGS=IA-64] Rebooting mode 2685 - Format: <reboot_mode>[,<reboot_mode2>[,...]] 2686 - See arch/*/kernel/reboot.c or arch/*/kernel/process.c 2684 + reboot= [KNL] 2685 + Format (x86 or x86_64): 2686 + [w[arm] | c[old] | h[ard] | s[oft] | g[pio]] \ 2687 + [[,]s[mp]#### \ 2688 + [[,]b[ios] | a[cpi] | k[bd] | t[riple] | e[fi] | p[ci]] \ 2689 + [[,]f[orce] 2690 + Where reboot_mode is one of warm (soft) or cold (hard) or gpio, 2691 + reboot_type is one of bios, acpi, kbd, triple, efi, or pci, 2692 + reboot_force is either force or not specified, 2693 + reboot_cpu is s[mp]#### with #### being the processor 2694 + to be used for rebooting. 2687 2695 2688 2696 relax_domain_level= 2689 2697 [KNL, SMP] Set scheduler's default relax_domain_level.
-10
arch/arm/kernel/process.c
··· 176 176 default_idle(); 177 177 } 178 178 179 - enum reboot_mode reboot_mode = REBOOT_HARD; 180 - 181 - static int __init reboot_setup(char *str) 182 - { 183 - if ('s' == str[0]) 184 - reboot_mode = REBOOT_SOFT; 185 - return 1; 186 - } 187 - __setup("reboot=", reboot_setup); 188 - 189 179 /* 190 180 * Called by kexec, immediately prior to machine_kexec(). 191 181 *
-10
arch/unicore32/kernel/process.c
··· 51 51 local_irq_enable(); 52 52 } 53 53 54 - static enum reboot_mode reboot_mode = REBOOT_HARD; 55 - 56 - int __init reboot_setup(char *str) 57 - { 58 - if ('s' == str[0]) 59 - reboot_mode = REBOOT_SOFT; 60 - return 1; 61 - } 62 - __setup("reboot=", reboot_setup); 63 - 64 54 void machine_halt(void) 65 55 { 66 56 gpio_set_value(GPO_SOFT_OFF, 0);
-12
arch/x86/include/asm/emergency-restart.h
··· 1 1 #ifndef _ASM_X86_EMERGENCY_RESTART_H 2 2 #define _ASM_X86_EMERGENCY_RESTART_H 3 3 4 - enum reboot_type { 5 - BOOT_TRIPLE = 't', 6 - BOOT_KBD = 'k', 7 - BOOT_BIOS = 'b', 8 - BOOT_ACPI = 'a', 9 - BOOT_EFI = 'e', 10 - BOOT_CF9 = 'p', 11 - BOOT_CF9_COND = 'q', 12 - }; 13 - 14 - extern enum reboot_type reboot_type; 15 - 16 4 extern void machine_emergency_restart(void); 17 5 18 6 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
+1 -1
arch/x86/kernel/apic/x2apic_uv_x.c
··· 25 25 #include <linux/kdebug.h> 26 26 #include <linux/delay.h> 27 27 #include <linux/crash_dump.h> 28 + #include <linux/reboot.h> 28 29 29 30 #include <asm/uv/uv_mmrs.h> 30 31 #include <asm/uv/uv_hub.h> ··· 37 36 #include <asm/ipi.h> 38 37 #include <asm/smp.h> 39 38 #include <asm/x86_init.h> 40 - #include <asm/emergency-restart.h> 41 39 #include <asm/nmi.h> 42 40 43 41 /* BMC sets a bit this MMR non-zero before sending an NMI */
+3 -108
arch/x86/kernel/reboot.c
··· 36 36 EXPORT_SYMBOL(pm_power_off); 37 37 38 38 static const struct desc_ptr no_idt = {}; 39 - static enum reboot_mode reboot_mode; 40 - enum reboot_type reboot_type = BOOT_ACPI; 41 - int reboot_force; 42 - 43 - /* 44 - * This variable is used privately to keep track of whether or not 45 - * reboot_type is still set to its default value (i.e., reboot= hasn't 46 - * been set on the command line). This is needed so that we can 47 - * suppress DMI scanning for reboot quirks. Without it, it's 48 - * impossible to override a faulty reboot quirk without recompiling. 49 - */ 50 - static int reboot_default = 1; 51 - 52 - #ifdef CONFIG_SMP 53 - static int reboot_cpu = -1; 54 - #endif 55 39 56 40 /* 57 41 * This is set if we need to go through the 'emergency' path. ··· 46 62 47 63 /* This is set by the PCI code if either type 1 or type 2 PCI is detected */ 48 64 bool port_cf9_safe = false; 49 - 50 - /* 51 - * reboot=b[ios] | s[mp] | t[riple] | k[bd] | e[fi] [, [w]arm | [c]old] | p[ci] 52 - * warm Don't set the cold reboot flag 53 - * cold Set the cold reboot flag 54 - * bios Reboot by jumping through the BIOS 55 - * smp Reboot by executing reset on BSP or other CPU 56 - * triple Force a triple fault (init) 57 - * kbd Use the keyboard controller. cold reset (default) 58 - * acpi Use the RESET_REG in the FADT 59 - * efi Use efi reset_system runtime service 60 - * pci Use the so-called "PCI reset register", CF9 61 - * force Avoid anything that could hang. 62 - */ 63 - static int __init reboot_setup(char *str) 64 - { 65 - for (;;) { 66 - /* 67 - * Having anything passed on the command line via 68 - * reboot= will cause us to disable DMI checking 69 - * below. 70 - */ 71 - reboot_default = 0; 72 - 73 - switch (*str) { 74 - case 'w': 75 - reboot_mode = REBOOT_WARM; 76 - break; 77 - 78 - case 'c': 79 - reboot_mode = REBOOT_COLD; 80 - break; 81 - 82 - #ifdef CONFIG_SMP 83 - case 's': 84 - if (isdigit(*(str+1))) { 85 - reboot_cpu = (int) (*(str+1) - '0'); 86 - if (isdigit(*(str+2))) 87 - reboot_cpu = reboot_cpu*10 + (int)(*(str+2) - '0'); 88 - } 89 - /* 90 - * We will leave sorting out the final value 91 - * when we are ready to reboot, since we might not 92 - * have detected BSP APIC ID or smp_num_cpu 93 - */ 94 - break; 95 - #endif /* CONFIG_SMP */ 96 - 97 - case 'b': 98 - case 'a': 99 - case 'k': 100 - case 't': 101 - case 'e': 102 - case 'p': 103 - reboot_type = *str; 104 - break; 105 - 106 - case 'f': 107 - reboot_force = 1; 108 - break; 109 - } 110 - 111 - str = strchr(str, ','); 112 - if (str) 113 - str++; 114 - else 115 - break; 116 - } 117 - return 1; 118 - } 119 - 120 - __setup("reboot=", reboot_setup); 121 - 122 65 123 66 /* 124 67 * Reboot options and system auto-detection code provided by ··· 527 616 { 528 617 /* Stop the cpus and apics */ 529 618 #ifdef CONFIG_SMP 530 - 531 - /* The boot cpu is always logical cpu 0 */ 532 - int reboot_cpu_id = 0; 533 - 534 - /* See if there has been given a command line override */ 535 - if ((reboot_cpu != -1) && (reboot_cpu < nr_cpu_ids) && 536 - cpu_online(reboot_cpu)) 537 - reboot_cpu_id = reboot_cpu; 538 - 539 - /* Make certain the cpu I'm about to reboot on is online */ 540 - if (!cpu_online(reboot_cpu_id)) 541 - reboot_cpu_id = smp_processor_id(); 542 - 543 - /* Make certain I only run on the appropriate processor */ 544 - set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id)); 545 - 546 619 /* 547 - * O.K Now that I'm on the appropriate processor, stop all of the 548 - * others. Also disable the local irq to not receive the per-cpu 549 - * timer interrupt which may trigger scheduler's load balance. 620 + * Stop all of the others. Also disable the local irq to 621 + * not receive the per-cpu timer interrupt which may trigger 622 + * scheduler's load balance. 550 623 */ 551 624 local_irq_disable(); 552 625 stop_other_cpus();
+17
include/linux/reboot.h
··· 17 17 REBOOT_SOFT, 18 18 REBOOT_GPIO, 19 19 }; 20 + extern enum reboot_mode reboot_mode; 21 + 22 + enum reboot_type { 23 + BOOT_TRIPLE = 't', 24 + BOOT_KBD = 'k', 25 + BOOT_BIOS = 'b', 26 + BOOT_ACPI = 'a', 27 + BOOT_EFI = 'e', 28 + BOOT_CF9 = 'p', 29 + BOOT_CF9_COND = 'q', 30 + }; 31 + extern enum reboot_type reboot_type; 32 + 33 + extern int reboot_default; 34 + extern int reboot_cpu; 35 + extern int reboot_force; 36 + 20 37 21 38 extern int register_reboot_notifier(struct notifier_block *); 22 39 extern int unregister_reboot_notifier(struct notifier_block *);
+75 -1
kernel/reboot.c
··· 6 6 7 7 #define pr_fmt(fmt) "reboot: " fmt 8 8 9 + #include <linux/ctype.h> 9 10 #include <linux/export.h> 10 11 #include <linux/kexec.h> 11 12 #include <linux/kmod.h> ··· 24 23 int C_A_D = 1; 25 24 struct pid *cad_pid; 26 25 EXPORT_SYMBOL(cad_pid); 26 + 27 + #if defined(CONFIG_ARM) || defined(CONFIG_UNICORE32) 28 + #define DEFAULT_REBOOT_MODE = REBOOT_HARD 29 + #else 30 + #define DEFAULT_REBOOT_MODE 31 + #endif 32 + enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE; 33 + 34 + int reboot_default; 35 + int reboot_cpu; 36 + enum reboot_type reboot_type = BOOT_ACPI; 37 + int reboot_force; 27 38 28 39 /* 29 40 * If set, this is used for preparing the system to power off. ··· 100 87 static void migrate_to_reboot_cpu(void) 101 88 { 102 89 /* The boot cpu is always logical cpu 0 */ 103 - int cpu = 0; 90 + int cpu = reboot_cpu; 104 91 105 92 cpu_hotplug_disable(); 106 93 ··· 356 343 return 0; 357 344 } 358 345 EXPORT_SYMBOL_GPL(orderly_poweroff); 346 + 347 + static int __init reboot_setup(char *str) 348 + { 349 + for (;;) { 350 + /* 351 + * Having anything passed on the command line via 352 + * reboot= will cause us to disable DMI checking 353 + * below. 354 + */ 355 + reboot_default = 0; 356 + 357 + switch (*str) { 358 + case 'w': 359 + reboot_mode = REBOOT_WARM; 360 + break; 361 + 362 + case 'c': 363 + reboot_mode = REBOOT_COLD; 364 + break; 365 + 366 + case 'h': 367 + reboot_mode = REBOOT_HARD; 368 + break; 369 + 370 + case 's': 371 + if (isdigit(*(str+1))) 372 + reboot_cpu = simple_strtoul(str+1, NULL, 0); 373 + else if (str[1] == 'm' && str[2] == 'p' && 374 + isdigit(*(str+3))) 375 + reboot_cpu = simple_strtoul(str+3, NULL, 0); 376 + else 377 + reboot_mode = REBOOT_SOFT; 378 + break; 379 + 380 + case 'g': 381 + reboot_mode = REBOOT_GPIO; 382 + break; 383 + 384 + case 'b': 385 + case 'a': 386 + case 'k': 387 + case 't': 388 + case 'e': 389 + case 'p': 390 + reboot_type = *str; 391 + break; 392 + 393 + case 'f': 394 + reboot_force = 1; 395 + break; 396 + } 397 + 398 + str = strchr(str, ','); 399 + if (str) 400 + str++; 401 + else 402 + break; 403 + } 404 + return 1; 405 + } 406 + __setup("reboot=", reboot_setup);