1 #include <linux/kernel.h>
3 #include <linux/reboot.h>
4 #include <linux/kexec.h>
5 #include <linux/bootmem.h>
6 #include <linux/crash_dump.h>
7 #include <linux/delay.h>
9 #include <linux/types.h>
10 #include <linux/sched.h>
12 /* This keeps a track of which one is crashing cpu. */
13 static int crashing_cpu
= -1;
14 static cpumask_t cpus_in_crash
= CPU_MASK_NONE
;
17 static void crash_shutdown_secondary(void *ignore
)
20 int cpu
= smp_processor_id();
22 regs
= task_pt_regs(current
);
28 if (!cpu_isset(cpu
, cpus_in_crash
))
29 crash_save_cpu(regs
, cpu
);
30 cpu_set(cpu
, cpus_in_crash
);
32 while (!atomic_read(&kexec_ready_to_reboot
))
34 relocated_kexec_smp_wait(NULL
);
38 static void crash_kexec_prepare_cpus(void)
42 unsigned int ncpus
= num_online_cpus() - 1;/* Excluding the panic cpu */
44 dump_send_ipi(crash_shutdown_secondary
);
48 * The crash CPU sends an IPI and wait for other CPUs to
49 * respond. Delay of at least 10 seconds.
51 pr_emerg("Sending IPI to other cpus...\n");
53 while ((cpus_weight(cpus_in_crash
) < ncpus
) && (--msecs
> 0)) {
59 #else /* !defined(CONFIG_SMP) */
60 static void crash_kexec_prepare_cpus(void) {}
61 #endif /* !defined(CONFIG_SMP) */
63 void default_machine_crash_shutdown(struct pt_regs
*regs
)
66 crashing_cpu
= smp_processor_id();
67 crash_save_cpu(regs
, crashing_cpu
);
68 crash_kexec_prepare_cpus();
69 cpu_set(crashing_cpu
, cpus_in_crash
);