Commit d8955958 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by Linus Torvalds

[PATCH] kexec: x86_64: factor out apic shutdown code

Factor out the apic and smp shutdown code from machine_restart so it can be
called by in the kexec reboot path as well.
Signed-off-by: default avatarEric Biederman <ebiederm@xmission.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1bc3b91a
...@@ -66,41 +66,47 @@ static int __init reboot_setup(char *str) ...@@ -66,41 +66,47 @@ static int __init reboot_setup(char *str)
__setup("reboot=", reboot_setup); __setup("reboot=", reboot_setup);
#ifdef CONFIG_SMP static inline void kb_wait(void)
static void smp_halt(void)
{ {
int cpuid = safe_smp_processor_id(); int i;
static int first_entry = 1;
if (reboot_force) for (i=0; i<0x10000; i++)
return; if ((inb_p(0x64) & 0x02) == 0)
break;
}
if (first_entry) { void machine_shutdown(void)
first_entry = 0; {
smp_call_function((void *)machine_restart, NULL, 1, 0); /* Stop the cpus and apics */
} #ifdef CONFIG_SMP
int reboot_cpu_id;
smp_stop_cpu();
/* AP calling this. Just halt */ /* The boot cpu is always logical cpu 0 */
if (cpuid != boot_cpu_id) { reboot_cpu_id = 0;
for (;;)
asm("hlt"); /* Make certain the cpu I'm about to reboot on is online */
if (!cpu_isset(reboot_cpu_id, cpu_online_map)) {
reboot_cpu_id = smp_processor_id();
} }
/* Wait for all other CPUs to have run smp_stop_cpu */ /* Make certain I only run on the appropriate processor */
while (!cpus_empty(cpu_online_map)) set_cpus_allowed(current, cpumask_of_cpu(reboot_cpu_id));
rep_nop();
} /* O.K Now that I'm on the appropriate processor,
* stop all of the others.
*/
smp_send_stop();
#endif #endif
static inline void kb_wait(void) local_irq_disable();
{
int i;
for (i=0; i<0x10000; i++) #ifndef CONFIG_SMP
if ((inb_p(0x64) & 0x02) == 0) disable_local_APIC();
break; #endif
disable_IO_APIC();
local_irq_enable();
} }
void machine_restart(char * __unused) void machine_restart(char * __unused)
...@@ -109,9 +115,7 @@ void machine_restart(char * __unused) ...@@ -109,9 +115,7 @@ void machine_restart(char * __unused)
printk("machine restart\n"); printk("machine restart\n");
#ifdef CONFIG_SMP machine_shutdown();
smp_halt();
#endif
if (!reboot_force) { if (!reboot_force) {
local_irq_disable(); local_irq_disable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment