Skip to content

Commit 1b3a5d0

Browse files
Robin Holttorvalds
authored andcommitted
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 <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Russell King <[email protected]> Cc: Guan Xuetao <[email protected]> Cc: Russ Anderson <[email protected]> Cc: Robin Holt <[email protected]> Acked-by: Ingo Molnar <[email protected]> Acked-by: Guan Xuetao <[email protected]> Acked-by: Russell King <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7b6d864 commit 1b3a5d0

File tree

8 files changed

+107
-145
lines changed

8 files changed

+107
-145
lines changed

Documentation/kernel-parameters.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,9 +2681,17 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
26812681
Run specified binary instead of /init from the ramdisk,
26822682
used for early userspace startup. See initrd.
26832683

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.
26872695

26882696
relax_domain_level=
26892697
[KNL, SMP] Set scheduler's default relax_domain_level.

arch/arm/kernel/process.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,6 @@ void arch_cpu_idle(void)
176176
default_idle();
177177
}
178178

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-
189179
/*
190180
* Called by kexec, immediately prior to machine_kexec().
191181
*

arch/unicore32/kernel/process.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ void arch_cpu_idle(void)
5151
local_irq_enable();
5252
}
5353

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-
6454
void machine_halt(void)
6555
{
6656
gpio_set_value(GPO_SOFT_OFF, 0);
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
#ifndef _ASM_X86_EMERGENCY_RESTART_H
22
#define _ASM_X86_EMERGENCY_RESTART_H
33

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-
164
extern void machine_emergency_restart(void);
175

186
#endif /* _ASM_X86_EMERGENCY_RESTART_H */

arch/x86/kernel/apic/x2apic_uv_x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/kdebug.h>
2626
#include <linux/delay.h>
2727
#include <linux/crash_dump.h>
28+
#include <linux/reboot.h>
2829

2930
#include <asm/uv/uv_mmrs.h>
3031
#include <asm/uv/uv_hub.h>
@@ -36,7 +37,6 @@
3637
#include <asm/ipi.h>
3738
#include <asm/smp.h>
3839
#include <asm/x86_init.h>
39-
#include <asm/emergency-restart.h>
4040
#include <asm/nmi.h>
4141

4242
/* BMC sets a bit this MMR non-zero before sending an NMI */

arch/x86/kernel/reboot.c

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,6 @@ void (*pm_power_off)(void);
3636
EXPORT_SYMBOL(pm_power_off);
3737

3838
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
5539

5640
/*
5741
* This is set if we need to go through the 'emergency' path.
@@ -63,79 +47,6 @@ static int reboot_emergency;
6347
/* This is set by the PCI code if either type 1 or type 2 PCI is detected */
6448
bool port_cf9_safe = false;
6549

66-
/*
67-
* reboot=b[ios] | s[mp] | t[riple] | k[bd] | e[fi] [, [w]arm | [c]old] | p[ci]
68-
* warm Don't set the cold reboot flag
69-
* cold Set the cold reboot flag
70-
* bios Reboot by jumping through the BIOS
71-
* smp Reboot by executing reset on BSP or other CPU
72-
* triple Force a triple fault (init)
73-
* kbd Use the keyboard controller. cold reset (default)
74-
* acpi Use the RESET_REG in the FADT
75-
* efi Use efi reset_system runtime service
76-
* pci Use the so-called "PCI reset register", CF9
77-
* force Avoid anything that could hang.
78-
*/
79-
static int __init reboot_setup(char *str)
80-
{
81-
for (;;) {
82-
/*
83-
* Having anything passed on the command line via
84-
* reboot= will cause us to disable DMI checking
85-
* below.
86-
*/
87-
reboot_default = 0;
88-
89-
switch (*str) {
90-
case 'w':
91-
reboot_mode = REBOOT_WARM;
92-
break;
93-
94-
case 'c':
95-
reboot_mode = REBOOT_COLD;
96-
break;
97-
98-
#ifdef CONFIG_SMP
99-
case 's':
100-
if (isdigit(*(str+1))) {
101-
reboot_cpu = (int) (*(str+1) - '0');
102-
if (isdigit(*(str+2)))
103-
reboot_cpu = reboot_cpu*10 + (int)(*(str+2) - '0');
104-
}
105-
/*
106-
* We will leave sorting out the final value
107-
* when we are ready to reboot, since we might not
108-
* have detected BSP APIC ID or smp_num_cpu
109-
*/
110-
break;
111-
#endif /* CONFIG_SMP */
112-
113-
case 'b':
114-
case 'a':
115-
case 'k':
116-
case 't':
117-
case 'e':
118-
case 'p':
119-
reboot_type = *str;
120-
break;
121-
122-
case 'f':
123-
reboot_force = 1;
124-
break;
125-
}
126-
127-
str = strchr(str, ',');
128-
if (str)
129-
str++;
130-
else
131-
break;
132-
}
133-
return 1;
134-
}
135-
136-
__setup("reboot=", reboot_setup);
137-
138-
13950
/*
14051
* Reboot options and system auto-detection code provided by
14152
* Dell Inc. so their systems "just work". :-)
@@ -616,26 +527,10 @@ void native_machine_shutdown(void)
616527
{
617528
/* Stop the cpus and apics */
618529
#ifdef CONFIG_SMP
619-
620-
/* The boot cpu is always logical cpu 0 */
621-
int reboot_cpu_id = 0;
622-
623-
/* See if there has been given a command line override */
624-
if ((reboot_cpu != -1) && (reboot_cpu < nr_cpu_ids) &&
625-
cpu_online(reboot_cpu))
626-
reboot_cpu_id = reboot_cpu;
627-
628-
/* Make certain the cpu I'm about to reboot on is online */
629-
if (!cpu_online(reboot_cpu_id))
630-
reboot_cpu_id = smp_processor_id();
631-
632-
/* Make certain I only run on the appropriate processor */
633-
set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id));
634-
635530
/*
636-
* O.K Now that I'm on the appropriate processor, stop all of the
637-
* others. Also disable the local irq to not receive the per-cpu
638-
* timer interrupt which may trigger scheduler's load balance.
531+
* Stop all of the others. Also disable the local irq to
532+
* not receive the per-cpu timer interrupt which may trigger
533+
* scheduler's load balance.
639534
*/
640535
local_irq_disable();
641536
stop_other_cpus();

include/linux/reboot.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ enum reboot_mode {
1717
REBOOT_SOFT,
1818
REBOOT_GPIO,
1919
};
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+
2037

2138
extern int register_reboot_notifier(struct notifier_block *);
2239
extern int unregister_reboot_notifier(struct notifier_block *);

kernel/reboot.c

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#define pr_fmt(fmt) "reboot: " fmt
88

9+
#include <linux/ctype.h>
910
#include <linux/export.h>
1011
#include <linux/kexec.h>
1112
#include <linux/kmod.h>
@@ -24,6 +25,18 @@ int C_A_D = 1;
2425
struct pid *cad_pid;
2526
EXPORT_SYMBOL(cad_pid);
2627

28+
#if defined(CONFIG_ARM) || defined(CONFIG_UNICORE32)
29+
#define DEFAULT_REBOOT_MODE = REBOOT_HARD
30+
#else
31+
#define DEFAULT_REBOOT_MODE
32+
#endif
33+
enum reboot_mode reboot_mode DEFAULT_REBOOT_MODE;
34+
35+
int reboot_default;
36+
int reboot_cpu;
37+
enum reboot_type reboot_type = BOOT_ACPI;
38+
int reboot_force;
39+
2740
/*
2841
* If set, this is used for preparing the system to power off.
2942
*/
@@ -87,7 +100,7 @@ EXPORT_SYMBOL(unregister_reboot_notifier);
87100
static void migrate_to_reboot_cpu(void)
88101
{
89102
/* The boot cpu is always logical cpu 0 */
90-
int cpu = 0;
103+
int cpu = reboot_cpu;
91104

92105
cpu_hotplug_disable();
93106

@@ -343,3 +356,64 @@ int orderly_poweroff(bool force)
343356
return 0;
344357
}
345358
EXPORT_SYMBOL_GPL(orderly_poweroff);
359+
360+
static int __init reboot_setup(char *str)
361+
{
362+
for (;;) {
363+
/*
364+
* Having anything passed on the command line via
365+
* reboot= will cause us to disable DMI checking
366+
* below.
367+
*/
368+
reboot_default = 0;
369+
370+
switch (*str) {
371+
case 'w':
372+
reboot_mode = REBOOT_WARM;
373+
break;
374+
375+
case 'c':
376+
reboot_mode = REBOOT_COLD;
377+
break;
378+
379+
case 'h':
380+
reboot_mode = REBOOT_HARD;
381+
break;
382+
383+
case 's':
384+
if (isdigit(*(str+1)))
385+
reboot_cpu = simple_strtoul(str+1, NULL, 0);
386+
else if (str[1] == 'm' && str[2] == 'p' &&
387+
isdigit(*(str+3)))
388+
reboot_cpu = simple_strtoul(str+3, NULL, 0);
389+
else
390+
reboot_mode = REBOOT_SOFT;
391+
break;
392+
393+
case 'g':
394+
reboot_mode = REBOOT_GPIO;
395+
break;
396+
397+
case 'b':
398+
case 'a':
399+
case 'k':
400+
case 't':
401+
case 'e':
402+
case 'p':
403+
reboot_type = *str;
404+
break;
405+
406+
case 'f':
407+
reboot_force = 1;
408+
break;
409+
}
410+
411+
str = strchr(str, ',');
412+
if (str)
413+
str++;
414+
else
415+
break;
416+
}
417+
return 1;
418+
}
419+
__setup("reboot=", reboot_setup);

0 commit comments

Comments
 (0)