aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael D Labriola <michael.d.labriola@gmail.com>2012-02-01 10:06:34 -0500
committerIngo Molnar <mingo@elte.hu>2012-02-07 05:34:12 -0500
commit144d102b926f887d3d9f909b69a5c4f504ae0d40 (patch)
tree8154d196766f6369a4518f81f21c2c6c444dadc0
parent57b165948fe0e1cca78bca1fe1e1ae9a38baedd2 (diff)
x86/reboot: Clean up coding style
This commit simply cleans up the style used in this file to fall in line with what's specified in CodingStyle. Mostly comment changes, with a single removal of unneeded braces. Note that the comments for all the DMI quirks in reboot_dmi_table now all line up consistently using tabs instead of spaces. Signed-off-by: Michael D Labriola <michael.d.labriola@gmail.com> Link: http://lkml.kernel.org/n/tip-lde9yy7qsomh0sdqevn7xp56@git.kernel.org [ Fixed a few small details. ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/reboot.c129
1 files changed, 70 insertions, 59 deletions
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index e73973769076..77215c23fba1 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -39,7 +39,8 @@ static int reboot_mode;
39enum reboot_type reboot_type = BOOT_ACPI; 39enum reboot_type reboot_type = BOOT_ACPI;
40int reboot_force; 40int reboot_force;
41 41
42/* This variable is used privately to keep track of whether or not 42/*
43 * This variable is used privately to keep track of whether or not
43 * reboot_type is still set to its default value (i.e., reboot= hasn't 44 * reboot_type is still set to its default value (i.e., reboot= hasn't
44 * been set on the command line). This is needed so that we can 45 * been set on the command line). This is needed so that we can
45 * suppress DMI scanning for reboot quirks. Without it, it's 46 * suppress DMI scanning for reboot quirks. Without it, it's
@@ -51,7 +52,8 @@ static int reboot_default = 1;
51static int reboot_cpu = -1; 52static int reboot_cpu = -1;
52#endif 53#endif
53 54
54/* This is set if we need to go through the 'emergency' path. 55/*
56 * This is set if we need to go through the 'emergency' path.
55 * When machine_emergency_restart() is called, we may be on 57 * When machine_emergency_restart() is called, we may be on
56 * an inconsistent state and won't be able to do a clean cleanup 58 * an inconsistent state and won't be able to do a clean cleanup
57 */ 59 */
@@ -60,22 +62,24 @@ static int reboot_emergency;
60/* This is set by the PCI code if either type 1 or type 2 PCI is detected */ 62/* This is set by the PCI code if either type 1 or type 2 PCI is detected */
61bool port_cf9_safe = false; 63bool port_cf9_safe = false;
62 64
63/* reboot=b[ios] | s[mp] | t[riple] | k[bd] | e[fi] [, [w]arm | [c]old] | p[ci] 65/*
64 warm Don't set the cold reboot flag 66 * reboot=b[ios] | s[mp] | t[riple] | k[bd] | e[fi] [, [w]arm | [c]old] | p[ci]
65 cold Set the cold reboot flag 67 * warm Don't set the cold reboot flag
66 bios Reboot by jumping through the BIOS (only for X86_32) 68 * cold Set the cold reboot flag
67 smp Reboot by executing reset on BSP or other CPU (only for X86_32) 69 * bios Reboot by jumping through the BIOS (only for X86_32)
68 triple Force a triple fault (init) 70 * smp Reboot by executing reset on BSP or other CPU (only for X86_32)
69 kbd Use the keyboard controller. cold reset (default) 71 * triple Force a triple fault (init)
70 acpi Use the RESET_REG in the FADT 72 * kbd Use the keyboard controller. cold reset (default)
71 efi Use efi reset_system runtime service 73 * acpi Use the RESET_REG in the FADT
72 pci Use the so-called "PCI reset register", CF9 74 * efi Use efi reset_system runtime service
73 force Avoid anything that could hang. 75 * pci Use the so-called "PCI reset register", CF9
76 * force Avoid anything that could hang.
74 */ 77 */
75static int __init reboot_setup(char *str) 78static int __init reboot_setup(char *str)
76{ 79{
77 for (;;) { 80 for (;;) {
78 /* Having anything passed on the command line via 81 /*
82 * Having anything passed on the command line via
79 * reboot= will cause us to disable DMI checking 83 * reboot= will cause us to disable DMI checking
80 * below. 84 * below.
81 */ 85 */
@@ -98,9 +102,11 @@ static int __init reboot_setup(char *str)
98 if (isdigit(*(str+2))) 102 if (isdigit(*(str+2)))
99 reboot_cpu = reboot_cpu*10 + (int)(*(str+2) - '0'); 103 reboot_cpu = reboot_cpu*10 + (int)(*(str+2) - '0');
100 } 104 }
101 /* we will leave sorting out the final value 105 /*
102 when we are ready to reboot, since we might not 106 * We will leave sorting out the final value
103 have detected BSP APIC ID or smp_num_cpu */ 107 * when we are ready to reboot, since we might not
108 * have detected BSP APIC ID or smp_num_cpu
109 */
104 break; 110 break;
105#endif /* CONFIG_SMP */ 111#endif /* CONFIG_SMP */
106 112
@@ -162,14 +168,15 @@ void machine_real_restart(unsigned int type)
162 168
163 local_irq_disable(); 169 local_irq_disable();
164 170
165 /* Write zero to CMOS register number 0x0f, which the BIOS POST 171 /*
166 routine will recognize as telling it to do a proper reboot. (Well 172 * Write zero to CMOS register number 0x0f, which the BIOS POST
167 that's what this book in front of me says -- it may only apply to 173 * routine will recognize as telling it to do a proper reboot. (Well
168 the Phoenix BIOS though, it's not clear). At the same time, 174 * that's what this book in front of me says -- it may only apply to
169 disable NMIs by setting the top bit in the CMOS address register, 175 * the Phoenix BIOS though, it's not clear). At the same time,
170 as we're about to do peculiar things to the CPU. I'm not sure if 176 * disable NMIs by setting the top bit in the CMOS address register,
171 `outb_p' is needed instead of just `outb'. Use it to be on the 177 * as we're about to do peculiar things to the CPU. I'm not sure if
172 safe side. (Yes, CMOS_WRITE does outb_p's. - Paul G.) 178 * `outb_p' is needed instead of just `outb'. Use it to be on the
179 * safe side. (Yes, CMOS_WRITE does outb_p's. - Paul G.)
173 */ 180 */
174 spin_lock(&rtc_lock); 181 spin_lock(&rtc_lock);
175 CMOS_WRITE(0x00, 0x8f); 182 CMOS_WRITE(0x00, 0x8f);
@@ -180,11 +187,12 @@ void machine_real_restart(unsigned int type)
180 */ 187 */
181 load_cr3(initial_page_table); 188 load_cr3(initial_page_table);
182 189
183 /* Write 0x1234 to absolute memory location 0x472. The BIOS reads 190 /*
184 this on booting to tell it to "Bypass memory test (also warm 191 * Write 0x1234 to absolute memory location 0x472. The BIOS reads
185 boot)". This seems like a fairly standard thing that gets set by 192 * this on booting to tell it to "Bypass memory test (also warm
186 REBOOT.COM programs, and the previous reset routine did this 193 * boot)". This seems like a fairly standard thing that gets set by
187 too. */ 194 * REBOOT.COM programs, and the previous reset routine did this
195 * too. */
188 *((unsigned short *)0x472) = reboot_mode; 196 *((unsigned short *)0x472) = reboot_mode;
189 197
190 /* Patch the GDT in the low memory trampoline */ 198 /* Patch the GDT in the low memory trampoline */
@@ -233,7 +241,8 @@ static int __init set_kbd_reboot(const struct dmi_system_id *d)
233 return 0; 241 return 0;
234} 242}
235 243
236/* This is a single dmi_table handling all reboot quirks. Note that 244/*
245 * This is a single dmi_table handling all reboot quirks. Note that
237 * REBOOT_BIOS is only available for 32bit 246 * REBOOT_BIOS is only available for 32bit
238 */ 247 */
239static struct dmi_system_id __initdata reboot_dmi_table[] = { 248static struct dmi_system_id __initdata reboot_dmi_table[] = {
@@ -262,7 +271,7 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
262 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 300/"), 271 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 300/"),
263 }, 272 },
264 }, 273 },
265 { /* Handle problems with rebooting on Dell Optiplex 745's SFF*/ 274 { /* Handle problems with rebooting on Dell Optiplex 745's SFF */
266 .callback = set_bios_reboot, 275 .callback = set_bios_reboot,
267 .ident = "Dell OptiPlex 745", 276 .ident = "Dell OptiPlex 745",
268 .matches = { 277 .matches = {
@@ -270,7 +279,7 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
270 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"), 279 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"),
271 }, 280 },
272 }, 281 },
273 { /* Handle problems with rebooting on Dell Optiplex 745's DFF*/ 282 { /* Handle problems with rebooting on Dell Optiplex 745's DFF */
274 .callback = set_bios_reboot, 283 .callback = set_bios_reboot,
275 .ident = "Dell OptiPlex 745", 284 .ident = "Dell OptiPlex 745",
276 .matches = { 285 .matches = {
@@ -279,7 +288,7 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
279 DMI_MATCH(DMI_BOARD_NAME, "0MM599"), 288 DMI_MATCH(DMI_BOARD_NAME, "0MM599"),
280 }, 289 },
281 }, 290 },
282 { /* Handle problems with rebooting on Dell Optiplex 745 with 0KW626 */ 291 { /* Handle problems with rebooting on Dell Optiplex 745 with 0KW626 */
283 .callback = set_bios_reboot, 292 .callback = set_bios_reboot,
284 .ident = "Dell OptiPlex 745", 293 .ident = "Dell OptiPlex 745",
285 .matches = { 294 .matches = {
@@ -288,7 +297,7 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
288 DMI_MATCH(DMI_BOARD_NAME, "0KW626"), 297 DMI_MATCH(DMI_BOARD_NAME, "0KW626"),
289 }, 298 },
290 }, 299 },
291 { /* Handle problems with rebooting on Dell Optiplex 330 with 0KP561 */ 300 { /* Handle problems with rebooting on Dell Optiplex 330 with 0KP561 */
292 .callback = set_bios_reboot, 301 .callback = set_bios_reboot,
293 .ident = "Dell OptiPlex 330", 302 .ident = "Dell OptiPlex 330",
294 .matches = { 303 .matches = {
@@ -297,7 +306,7 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
297 DMI_MATCH(DMI_BOARD_NAME, "0KP561"), 306 DMI_MATCH(DMI_BOARD_NAME, "0KP561"),
298 }, 307 },
299 }, 308 },
300 { /* Handle problems with rebooting on Dell Optiplex 360 with 0T656F */ 309 { /* Handle problems with rebooting on Dell Optiplex 360 with 0T656F */
301 .callback = set_bios_reboot, 310 .callback = set_bios_reboot,
302 .ident = "Dell OptiPlex 360", 311 .ident = "Dell OptiPlex 360",
303 .matches = { 312 .matches = {
@@ -306,7 +315,7 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
306 DMI_MATCH(DMI_BOARD_NAME, "0T656F"), 315 DMI_MATCH(DMI_BOARD_NAME, "0T656F"),
307 }, 316 },
308 }, 317 },
309 { /* Handle problems with rebooting on Dell OptiPlex 760 with 0G919G*/ 318 { /* Handle problems with rebooting on Dell OptiPlex 760 with 0G919G */
310 .callback = set_bios_reboot, 319 .callback = set_bios_reboot,
311 .ident = "Dell OptiPlex 760", 320 .ident = "Dell OptiPlex 760",
312 .matches = { 321 .matches = {
@@ -379,7 +388,7 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
379 DMI_MATCH(DMI_PRODUCT_NAME, "SBC-FITPC2"), 388 DMI_MATCH(DMI_PRODUCT_NAME, "SBC-FITPC2"),
380 }, 389 },
381 }, 390 },
382 { /* Handle problems with rebooting on ASUS P4S800 */ 391 { /* Handle problems with rebooting on ASUS P4S800 */
383 .callback = set_bios_reboot, 392 .callback = set_bios_reboot,
384 .ident = "ASUS P4S800", 393 .ident = "ASUS P4S800",
385 .matches = { 394 .matches = {
@@ -389,7 +398,7 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
389 }, 398 },
390#endif /* CONFIG_X86_32 */ 399#endif /* CONFIG_X86_32 */
391 400
392 { /* Handle reboot issue on Acer Aspire one */ 401 { /* Handle reboot issue on Acer Aspire one */
393 .callback = set_kbd_reboot, 402 .callback = set_kbd_reboot,
394 .ident = "Acer Aspire One A110", 403 .ident = "Acer Aspire One A110",
395 .matches = { 404 .matches = {
@@ -466,12 +475,12 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
466 475
467static int __init reboot_init(void) 476static int __init reboot_init(void)
468{ 477{
469 /* Only do the DMI check if reboot_type hasn't been overridden 478 /*
479 * Only do the DMI check if reboot_type hasn't been overridden
470 * on the command line 480 * on the command line
471 */ 481 */
472 if (reboot_default) { 482 if (reboot_default)
473 dmi_check_system(reboot_dmi_table); 483 dmi_check_system(reboot_dmi_table);
474 }
475 return 0; 484 return 0;
476} 485}
477core_initcall(reboot_init); 486core_initcall(reboot_init);
@@ -492,14 +501,14 @@ static void vmxoff_nmi(int cpu, struct pt_regs *regs)
492 cpu_emergency_vmxoff(); 501 cpu_emergency_vmxoff();
493} 502}
494 503
495/* Use NMIs as IPIs to tell all CPUs to disable virtualization 504/* Use NMIs as IPIs to tell all CPUs to disable virtualization */
496 */
497static void emergency_vmx_disable_all(void) 505static void emergency_vmx_disable_all(void)
498{ 506{
499 /* Just make sure we won't change CPUs while doing this */ 507 /* Just make sure we won't change CPUs while doing this */
500 local_irq_disable(); 508 local_irq_disable();
501 509
502 /* We need to disable VMX on all CPUs before rebooting, otherwise 510 /*
511 * We need to disable VMX on all CPUs before rebooting, otherwise
503 * we risk hanging up the machine, because the CPU ignore INIT 512 * we risk hanging up the machine, because the CPU ignore INIT
504 * signals when VMX is enabled. 513 * signals when VMX is enabled.
505 * 514 *
@@ -518,8 +527,7 @@ static void emergency_vmx_disable_all(void)
518 * is still enabling VMX. 527 * is still enabling VMX.
519 */ 528 */
520 if (cpu_has_vmx() && cpu_vmx_enabled()) { 529 if (cpu_has_vmx() && cpu_vmx_enabled()) {
521 /* Disable VMX on this CPU. 530 /* Disable VMX on this CPU. */
522 */
523 cpu_vmxoff(); 531 cpu_vmxoff();
524 532
525 /* Halt and disable VMX on the other CPUs */ 533 /* Halt and disable VMX on the other CPUs */
@@ -564,12 +572,12 @@ static void native_machine_emergency_restart(void)
564 /* Could also try the reset bit in the Hammer NB */ 572 /* Could also try the reset bit in the Hammer NB */
565 switch (reboot_type) { 573 switch (reboot_type) {
566 case BOOT_KBD: 574 case BOOT_KBD:
567 mach_reboot_fixups(); /* for board specific fixups */ 575 mach_reboot_fixups(); /* For board specific fixups */
568 576
569 for (i = 0; i < 10; i++) { 577 for (i = 0; i < 10; i++) {
570 kb_wait(); 578 kb_wait();
571 udelay(50); 579 udelay(50);
572 outb(0xfe, 0x64); /* pulse reset low */ 580 outb(0xfe, 0x64); /* Pulse reset low */
573 udelay(50); 581 udelay(50);
574 } 582 }
575 if (attempt == 0 && orig_reboot_type == BOOT_ACPI) { 583 if (attempt == 0 && orig_reboot_type == BOOT_ACPI) {
@@ -611,7 +619,7 @@ static void native_machine_emergency_restart(void)
611 619
612 case BOOT_CF9: 620 case BOOT_CF9:
613 port_cf9_safe = true; 621 port_cf9_safe = true;
614 /* fall through */ 622 /* Fall through */
615 623
616 case BOOT_CF9_COND: 624 case BOOT_CF9_COND:
617 if (port_cf9_safe) { 625 if (port_cf9_safe) {
@@ -649,7 +657,8 @@ void native_machine_shutdown(void)
649 /* Make certain I only run on the appropriate processor */ 657 /* Make certain I only run on the appropriate processor */
650 set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id)); 658 set_cpus_allowed_ptr(current, cpumask_of(reboot_cpu_id));
651 659
652 /* O.K Now that I'm on the appropriate processor, 660 /*
661 * O.K Now that I'm on the appropriate processor,
653 * stop all of the others. 662 * stop all of the others.
654 */ 663 */
655 stop_other_cpus(); 664 stop_other_cpus();
@@ -687,12 +696,11 @@ static void native_machine_restart(char *__unused)
687 696
688static void native_machine_halt(void) 697static void native_machine_halt(void)
689{ 698{
690 /* stop other cpus and apics */ 699 /* Stop other cpus and apics */
691 machine_shutdown(); 700 machine_shutdown();
692 701
693 tboot_shutdown(TB_SHUTDOWN_HALT); 702 tboot_shutdown(TB_SHUTDOWN_HALT);
694 703
695 /* stop this cpu */
696 stop_this_cpu(NULL); 704 stop_this_cpu(NULL);
697} 705}
698 706
@@ -703,7 +711,7 @@ static void native_machine_power_off(void)
703 machine_shutdown(); 711 machine_shutdown();
704 pm_power_off(); 712 pm_power_off();
705 } 713 }
706 /* a fallback in case there is no PM info available */ 714 /* A fallback in case there is no PM info available */
707 tboot_shutdown(TB_SHUTDOWN_HALT); 715 tboot_shutdown(TB_SHUTDOWN_HALT);
708} 716}
709 717
@@ -765,7 +773,8 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)
765 773
766 cpu = raw_smp_processor_id(); 774 cpu = raw_smp_processor_id();
767 775
768 /* Don't do anything if this handler is invoked on crashing cpu. 776 /*
777 * Don't do anything if this handler is invoked on crashing cpu.
769 * Otherwise, system will completely hang. Crashing cpu can get 778 * Otherwise, system will completely hang. Crashing cpu can get
770 * an NMI if system was initially booted with nmi_watchdog parameter. 779 * an NMI if system was initially booted with nmi_watchdog parameter.
771 */ 780 */
@@ -789,7 +798,8 @@ static void smp_send_nmi_allbutself(void)
789 apic->send_IPI_allbutself(NMI_VECTOR); 798 apic->send_IPI_allbutself(NMI_VECTOR);
790} 799}
791 800
792/* Halt all other CPUs, calling the specified function on each of them 801/*
802 * Halt all other CPUs, calling the specified function on each of them
793 * 803 *
794 * This function can be used to halt all other CPUs on crash 804 * This function can be used to halt all other CPUs on crash
795 * or emergency reboot time. The function passed as parameter 805 * or emergency reboot time. The function passed as parameter
@@ -800,7 +810,7 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)
800 unsigned long msecs; 810 unsigned long msecs;
801 local_irq_disable(); 811 local_irq_disable();
802 812
803 /* Make a note of crashing cpu. Will be used in NMI callback.*/ 813 /* Make a note of crashing cpu. Will be used in NMI callback. */
804 crashing_cpu = safe_smp_processor_id(); 814 crashing_cpu = safe_smp_processor_id();
805 815
806 shootdown_callback = callback; 816 shootdown_callback = callback;
@@ -809,8 +819,9 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)
809 /* Would it be better to replace the trap vector here? */ 819 /* Would it be better to replace the trap vector here? */
810 if (register_nmi_handler(NMI_LOCAL, crash_nmi_callback, 820 if (register_nmi_handler(NMI_LOCAL, crash_nmi_callback,
811 NMI_FLAG_FIRST, "crash")) 821 NMI_FLAG_FIRST, "crash"))
812 return; /* return what? */ 822 return; /* Return what? */
813 /* Ensure the new callback function is set before sending 823 /*
824 * Ensure the new callback function is set before sending
814 * out the NMI 825 * out the NMI
815 */ 826 */
816 wmb(); 827 wmb();