42 #include <linux/module.h>
45 #include <linux/kernel.h>
47 #include <linux/sched.h>
54 #include <asm/pgalloc.h>
55 #include <asm/tlbflush.h>
59 #define Dprintk(x...) printk(x)
71 static unsigned int bsp_phys_id = -1;
94 static volatile int physid_2_cpu[
NR_CPUS];
95 #define physid_to_cpu(physid) physid_2_cpu[physid]
106 static unsigned int calibration_result;
112 static void init_ipi_lock(
void);
113 static void do_boot_cpu(
int);
117 static void smp_online(
void);
119 static void show_mp_info(
int);
120 static void smp_store_cpu_info(
int);
121 static void show_cpu_info(
int);
123 static void init_cpu_to_physid(
void);
124 static void map_cpu_to_physid(
int,
int);
125 static void unmap_cpu_to_physid(
int,
int);
133 physid_set(bsp_phys_id, phys_cpu_present_map);
135 cpumask_set_cpu(0, &cpu_callout_map);
136 cpumask_set_cpu(0, &cpu_callin_map);
141 init_cpu_to_physid();
142 map_cpu_to_physid(0, bsp_phys_id);
166 unsigned long nr_cpu;
174 for (phys_id = 0 ; phys_id < nr_cpu ; phys_id++)
176 #ifndef CONFIG_HOTPLUG_CPU
180 show_mp_info(nr_cpu);
187 smp_store_cpu_info(0);
200 Dprintk(
"CPU present map : %lx\n", physids_coerce(phys_cpu_present_map));
202 for (phys_id = 0 ; phys_id <
NR_CPUS ; phys_id++) {
206 if (phys_id == bsp_phys_id)
212 if (max_cpus <= cpucount + 1)
215 do_boot_cpu(phys_id);
222 printk(
"phys CPU#%d not responding - " \
223 "cannot use it.\n", phys_id);
234 static void __init init_ipi_lock(
void)
238 for (ipi = 0 ; ipi < NR_IPIS ; ipi++)
259 static void __init do_boot_cpu(
int phys_id)
273 panic(
"failed fork for CPU#%d.", cpu_id);
277 map_cpu_to_physid(cpu_id, phys_id);
280 printk(
"Booting processor %d/%d\n", phys_id, cpu_id);
293 cpumask_set_cpu(phys_id, &cpu_bootout_map);
298 Dprintk(
"Waiting for send to finish...\n");
306 }
while (send_status && (timeout++ < 100));
314 Dprintk(
"Before Callout %d.\n", cpu_id);
315 cpumask_set_cpu(cpu_id, &cpu_callout_map);
316 Dprintk(
"After Callout %d.\n", cpu_id);
321 for (timeout = 0; timeout < 5000; timeout++) {
332 printk(
"Not responding.\n");
335 printk(
"IPI never delivered???\n");
337 if (send_status || boot_status) {
338 unmap_cpu_to_physid(cpu_id, phys_id);
339 cpumask_clear_cpu(cpu_id, &cpu_callout_map);
340 cpumask_clear_cpu(cpu_id, &cpu_callin_map);
341 cpumask_clear_cpu(cpu_id, &cpu_initialized);
350 cpumask_set_cpu(cpu_id, &smp_commenced_mask);
355 for (timeout = 0; timeout < 5000; timeout++) {
369 unsigned long bogosum = 0;
371 for (timeout = 0; timeout < 5000; timeout++) {
380 show_cpu_info(cpu_id);
391 "(%lu.%02lu BogoMIPS).\n", cpucount + 1,
392 bogosum / (500000 /
HZ),
393 (bogosum / (5000 /
HZ)) % 100);
394 Dprintk(
"Before bogocount - setting activated=1.\n");
460 unsigned long timeout;
463 printk(
"huh, phys CPU#%d, CPU#%d already present??\n",
467 Dprintk(
"CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpu_id, phys_id);
479 printk(
"BUG: CPU#%d started up but did not get a callout!\n",
485 cpumask_set_cpu(cpu_id, &cpu_callin_map);
488 static void __init smp_online(
void)
492 notify_cpu_starting(cpu_id);
500 smp_store_cpu_info(cpu_id);
508 static void __init show_mp_info(
int nr_cpu)
511 char cpu_model0[17], cpu_model1[17], cpu_ver[9];
517 cpu_model0[16] =
'\0';
518 for (i = 15 ; i >= 0 ; i--) {
519 if (cpu_model0[i] !=
' ')
521 cpu_model0[
i] =
'\0';
523 cpu_model1[16] =
'\0';
524 for (i = 15 ; i >= 0 ; i--) {
525 if (cpu_model1[i] !=
' ')
527 cpu_model1[
i] =
'\0';
530 for (i = 7 ; i >= 0 ; i--) {
531 if (cpu_ver[i] !=
' ')
539 cpu_model1, cpu_ver);
546 static void __init smp_store_cpu_info(
int cpu_id)
554 static void __init show_cpu_info(
int cpu_id)
558 printk(
"CPU#%d : ", cpu_id);
560 #define PRINT_CLOCK(name, value) \
561 printk(name " clock %d.%02dMHz", \
562 ((value) / 1000000), ((value) % 1000000) / 10000)
582 if ( (!multiplier) || (calibration_result / multiplier < 500))
592 per_cpu(prof_multiplier, i) = multiplier;
598 static
void __init init_cpu_to_physid(
void)
602 for (i = 0 ; i <
NR_CPUS ; i++) {
604 physid_2_cpu[
i] = -1;
612 static void __init map_cpu_to_physid(
int cpu_id,
int phys_id)
614 physid_2_cpu[phys_id] =
cpu_id;
622 static void __init unmap_cpu_to_physid(
int cpu_id,
int phys_id)
624 physid_2_cpu[phys_id] = -1;