10 #include <linux/module.h>
14 #include <linux/sched.h>
18 #include <linux/errno.h>
31 #include <asm/cacheflush.h>
33 #include <asm/cputype.h>
34 #include <asm/exception.h>
36 #include <asm/topology.h>
37 #include <asm/mmu_context.h>
38 #include <asm/pgtable.h>
39 #include <asm/pgalloc.h>
40 #include <asm/processor.h>
41 #include <asm/sections.h>
42 #include <asm/tlbflush.h>
43 #include <asm/ptrace.h>
108 pr_crit(
"CPU%u: failed to come online\n", cpu);
112 pr_err(
"CPU%u: failed to boot: %d\n", cpu, ret);
128 static void __init platform_smp_prepare_cpus(
unsigned int max_cpus)
134 static void __cpuinit platform_secondary_init(
unsigned int cpu)
136 if (
smp_ops.smp_secondary_init)
137 smp_ops.smp_secondary_init(cpu);
142 if (
smp_ops.smp_boot_secondary)
143 return smp_ops.smp_boot_secondary(cpu, idle);
147 #ifdef CONFIG_HOTPLUG_CPU
148 static void percpu_timer_stop(
void);
150 static int platform_cpu_kill(
unsigned int cpu)
163 static int platform_cpu_disable(
unsigned int cpu)
173 return cpu == 0 ? -
EPERM : 0;
183 ret = platform_cpu_disable(cpu);
213 clear_tasks_mm_cpumask(cpu);
227 pr_err(
"CPU%u: cpu didn't die\n", cpu);
232 if (!platform_cpu_kill(cpu))
233 printk(
"CPU%u: unable to kill\n", cpu);
269 " b secondary_start_kernel"
288 static void percpu_timer_setup(
void);
303 cpu_switch_mm(mm->
pgd, mm);
314 cpumask_set_cpu(cpu, mm_cpumask(mm));
316 printk(
"CPU%u: Booted secondary processor\n", cpu);
325 platform_secondary_init(cpu);
327 notify_cpu_starting(cpu);
331 smp_store_cpu_info(cpu);
344 percpu_timer_setup();
358 unsigned long bogosum = 0;
364 "(%lu.%02lu BogoMIPS).\n",
366 bogosum / (500000/
HZ),
367 (bogosum / (5000/
HZ)) % 100);
387 if (max_cpus > ncores)
389 if (ncores > 1 && max_cpus) {
394 percpu_timer_setup();
408 platform_smp_prepare_cpus(max_cpus);
412 static void (*smp_cross_call)(
const struct cpumask *,
unsigned int);
429 static const char *ipi_types[
NR_IPI] = {
430 #define S(x,s) [x] = s
434 S(IPI_CALL_FUNC,
"Function call interrupts"),
435 S(IPI_CALL_FUNC_SINGLE,
"Single function call interrupts"),
436 S(IPI_CPU_STOP,
"CPU stop interrupts"),
443 for (i = 0; i <
NR_IPI; i++) {
459 for (i = 0; i <
NR_IPI; i++)
468 static DEFINE_PER_CPU(
struct clock_event_device, percpu_clockevent);
470 static void ipi_timer(
void)
473 evt->event_handler(evt);
476 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
482 #define smp_timer_broadcast NULL
485 static void broadcast_timer_set_mode(
enum clock_event_mode
mode,
486 struct clock_event_device *evt)
490 static void __cpuinit broadcast_timer_setup(
struct clock_event_device *evt)
492 evt->name =
"dummy_timer";
493 evt->features = CLOCK_EVT_FEAT_ONESHOT |
494 CLOCK_EVT_FEAT_PERIODIC |
495 CLOCK_EVT_FEAT_DUMMY;
498 evt->set_mode = broadcast_timer_set_mode;
505 #ifdef CONFIG_LOCAL_TIMERS
519 static void __cpuinit percpu_timer_setup(
void)
522 struct clock_event_device *evt = &
per_cpu(percpu_clockevent, cpu);
527 if (!lt_ops || lt_ops->
setup(evt))
528 broadcast_timer_setup(evt);
531 #ifdef CONFIG_HOTPLUG_CPU
537 static void percpu_timer_stop(
void)
540 struct clock_event_device *evt = &
per_cpu(percpu_clockevent, cpu);
552 static void ipi_cpu_stop(
unsigned int cpu)
582 struct pt_regs *old_regs = set_irq_regs(regs);
603 generic_smp_call_function_interrupt();
609 generic_smp_call_function_single_interrupt();
624 set_irq_regs(old_regs);
632 #ifdef CONFIG_HOTPLUG_CPU
637 platform_cpu_kill(cpu);
640 static void smp_kill_cpus(
cpumask_t *mask) { }
650 if (!cpumask_empty(&mask))
659 pr_warning(
"SMP: failed to stop secondary CPUs\n");
661 smp_kill_cpus(&mask);
672 #ifdef CONFIG_CPU_FREQ
676 static unsigned long global_l_p_j_ref;
677 static unsigned long global_l_p_j_ref_freq;
688 if (!
per_cpu(l_p_j_ref, cpu)) {
692 if (!global_l_p_j_ref) {
694 global_l_p_j_ref_freq = freq->
old;
702 global_l_p_j_ref_freq,
705 cpufreq_scale(
per_cpu(l_p_j_ref, cpu),
716 static int __init register_cpufreq_notifier(
void)