20 #include <linux/kernel.h>
21 #include <linux/export.h>
22 #include <linux/sched.h>
30 #include <linux/device.h>
35 #include <asm/ptrace.h>
39 #include <asm/pgtable.h>
43 #include <asm/machdep.h>
45 #include <asm/cputable.h>
47 #include <asm/vdso_datapage.h>
52 #include <asm/debug.h>
56 #define DBG(fmt...) udbg_printf(fmt)
61 #ifdef CONFIG_HOTPLUG_CPU
94 if (!
paca[nr].cpu_start) {
100 #ifdef CONFIG_HOTPLUG_CPU
105 generic_set_cpu_up(nr);
116 generic_smp_call_function_interrupt();
128 generic_smp_call_function_single_interrupt();
134 if (crash_ipi_function_ptr) {
139 #ifdef CONFIG_DEBUGGER
147 [PPC_MSG_CALL_FUNCTION] = call_function_action,
148 [PPC_MSG_RESCHEDULE] = reschedule_action,
149 [PPC_MSG_CALL_FUNC_SINGLE] = call_function_single_action,
150 [PPC_MSG_DEBUGGER_BREAK] = debug_ipi_action,
154 [PPC_MSG_CALL_FUNCTION] =
"ipi call function",
155 [PPC_MSG_RESCHEDULE] =
"ipi reschedule",
156 [PPC_MSG_CALL_FUNC_SINGLE] =
"ipi call function single",
157 [PPC_MSG_DEBUGGER_BREAK] =
"ipi debugger",
168 #if !defined(CONFIG_DEBUGGER) && !defined(CONFIG_KEXEC)
169 if (msg == PPC_MSG_DEBUGGER_BREAK) {
175 smp_ipi_name[msg], 0);
176 WARN(err < 0,
"unable to request_irq %d for %s (rc %d)\n",
177 virq, smp_ipi_name[msg], err);
182 #ifdef CONFIG_PPC_SMP_MUXED_IPI
183 struct cpu_messages {
189 void smp_muxed_ipi_set_data(
int cpu,
unsigned long data)
191 struct cpu_messages *
info = &
per_cpu(ipi_message, cpu);
196 void smp_muxed_ipi_message_pass(
int cpu,
int msg)
198 struct cpu_messages *
info = &
per_cpu(ipi_message, cpu);
199 char *
message = (
char *)&info->messages;
210 smp_ops->cause_ipi(cpu, info->data);
221 all =
xchg(&info->messages, 0);
224 if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNCTION)))
225 generic_smp_call_function_interrupt();
226 if (all & (1 << (24 - 8 * PPC_MSG_RESCHEDULE)))
228 if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNC_SINGLE)))
229 generic_smp_call_function_single_interrupt();
230 if (all & (1 << (24 - 8 * PPC_MSG_DEBUGGER_BREAK)))
231 debug_ipi_action(0,
NULL);
233 #error Unsupported ENDIAN
235 }
while (info->messages);
241 static inline void do_message_pass(
int cpu,
int msg)
244 smp_ops->message_pass(cpu, msg);
245 #ifdef CONFIG_PPC_SMP_MUXED_IPI
247 smp_muxed_ipi_message_pass(cpu, msg);
254 do_message_pass(cpu, PPC_MSG_RESCHEDULE);
260 do_message_pass(cpu, PPC_MSG_CALL_FUNC_SINGLE);
268 do_message_pass(cpu, PPC_MSG_CALL_FUNCTION);
271 #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
272 void smp_send_debugger_break(
void)
282 do_message_pass(cpu, PPC_MSG_DEBUGGER_BREAK);
287 void crash_send_ipi(
void (*crash_ipi_callback)(
struct pt_regs *))
289 crash_ipi_function_ptr = crash_ipi_callback;
290 if (crash_ipi_callback) {
292 smp_send_debugger_break();
314 static void __devinit smp_store_cpu_info(
int id)
317 #ifdef CONFIG_PPC_FSL_BOOK3E
327 DBG(
"smp_prepare_cpus\n");
367 #ifdef CONFIG_HOTPLUG_CPU
369 int generic_cpu_disable(
void)
384 void generic_cpu_die(
unsigned int cpu)
388 for (i = 0; i < 100; i++) {
397 void generic_mach_cpu_die(
void)
411 void generic_set_cpu_dead(
unsigned int cpu)
421 void generic_set_cpu_up(
unsigned int cpu)
426 int generic_check_cpu_restart(
unsigned int cpu)
432 static void cpu_idle_thread_init(
unsigned int cpu,
struct task_struct *
idle)
441 secondary_ti = current_set[
cpu] = ti;
452 cpu_idle_thread_init(cpu, tidle);
466 DBG(
"smp: kicking cpu %d\n", cpu);
469 pr_err(
"smp: failed starting cpu %d (rc %d)\n", cpu, rc);
481 #ifdef CONFIG_HOTPLUG_CPU
496 DBG(
"Processor %u found.\n", cpu);
576 smp_store_cpu_info(cpu);
594 notify_cpu_starting(cpu);
597 base = cpu_first_thread_sibling(cpu);
601 cpumask_set_cpu(cpu, cpu_sibling_mask(base + i));
602 cpumask_set_cpu(base + i, cpu_sibling_mask(cpu));
608 cpumask_set_cpu(cpu, cpu_core_mask(base + i));
609 cpumask_set_cpu(base + i, cpu_core_mask(cpu));
611 l2_cache = cpu_to_l2cache(cpu);
616 if (np == l2_cache) {
617 cpumask_set_cpu(cpu, cpu_core_mask(i));
618 cpumask_set_cpu(i, cpu_core_mask(cpu));
622 of_node_put(l2_cache);
651 set_cpus_allowed_ptr(
current, old_mask);
653 free_cpumask_var(old_mask);
666 return SD_ASYM_PACKING;
671 #ifdef CONFIG_HOTPLUG_CPU
687 base = cpu_first_thread_sibling(cpu);
689 cpumask_clear_cpu(cpu, cpu_sibling_mask(base + i));
690 cpumask_clear_cpu(base + i, cpu_sibling_mask(cpu));
691 cpumask_clear_cpu(cpu, cpu_core_mask(base + i));
692 cpumask_clear_cpu(base + i, cpu_core_mask(cpu));
695 l2_cache = cpu_to_l2cache(cpu);
700 if (np == l2_cache) {
701 cpumask_clear_cpu(cpu, cpu_core_mask(i));
702 cpumask_clear_cpu(i, cpu_core_mask(cpu));
706 of_node_put(l2_cache);
720 void cpu_hotplug_driver_lock()
722 mutex_lock(&powerpc_cpu_hotplug_driver_mutex);
725 void cpu_hotplug_driver_unlock()
736 start_secondary_resume();