25 #include <linux/module.h>
33 #include <linux/kernel.h>
41 #include <linux/bitops.h>
44 #include <asm/cache.h>
45 #include <asm/current.h>
46 #include <asm/delay.h>
49 #include <asm/machvec.h>
52 #include <asm/paravirt.h>
53 #include <asm/pgalloc.h>
54 #include <asm/pgtable.h>
55 #include <asm/processor.h>
56 #include <asm/ptrace.h>
58 #include <asm/tlbflush.h>
59 #include <asm/unistd.h>
60 #include <asm/sn/arch.h>
65 #define Dprintk(x...) printk(x)
70 #ifdef CONFIG_HOTPLUG_CPU
71 #ifdef CONFIG_PERMIT_BSP_REMOVE
72 #define bsp_remove_ok 1
74 #define bsp_remove_ok 0
80 struct sal_to_os_boot sal_boot_rendez_state[
NR_CPUS];
86 struct sal_to_os_boot *sal_state_for_booting_cpu = &sal_boot_rendez_state[0];
88 #define set_brendez_area(x) (sal_state_for_booting_cpu = &sal_boot_rendez_state[(x)]);
91 #define set_brendez_area(x)
99 #define SLAVE (SMP_CACHE_BYTES/8)
101 #define NUM_ROUNDS 64
105 static volatile unsigned long go[
SLAVE + 1];
107 #define DEBUG_ITC_SYNC 0
130 static volatile cpumask_t cpu_callin_map;
140 #ifdef CONFIG_FORCE_CPEI_RETARGET
141 #define CPEI_OVERRIDE_DEFAULT (1)
143 #define CPEI_OVERRIDE_DEFAULT (0)
149 cmdl_force_cpei(
char *
str)
159 __setup(
"force_cpei=", cmdl_force_cpei);
162 nointroute (
char *
str)
165 printk (
"no_int_routing on\n");
169 __setup(
"nointroute", nointroute);
171 static void fix_b0_for_bsp(
void)
173 #ifdef CONFIG_HOTPLUG_CPU
175 static int fix_bsp_b0 = 1;
182 if (!(fix_bsp_b0 && cpuid))
185 sal_boot_rendez_state[0].br[0] = sal_boot_rendez_state[
cpuid].br[0];
186 printk (
"Fixed BSP b0 value from CPU %d\n", cpuid);
217 get_delta (
long *rt,
long *master)
219 unsigned long best_t0 = 0, best_t1 = ~0
UL, best_tm = 0;
220 unsigned long tcenter,
t0,
t1,
tm;
231 if (t1 - t0 < best_t1 - best_t0)
232 best_t0 =
t0, best_t1 =
t1, best_tm =
tm;
235 *rt = best_t1 - best_t0;
236 *master = best_tm - best_t0;
239 tcenter = (best_t0/2 + best_t1/2);
240 if (best_t0 % 2 + best_t1 % 2 == 2)
242 return tcenter - best_tm;
280 long i,
delta, adj, adjust_latency = 0,
done = 0;
281 unsigned long flags, rt, master_time_stamp, bound;
297 BUG_ON((ia64_get_itv() & (1 << 16)) == 0);
302 printk(
KERN_ERR "sync_itc: failed to get attention of CPU %u!\n", master);
312 delta = get_delta(&rt, &master_time_stamp);
320 adjust_latency += -
delta;
321 adj = -delta + adjust_latency/4;
325 ia64_set_itc(ia64_get_itc() + adj);
329 t[
i].master = master_time_stamp;
331 t[
i].lat = adjust_latency/4;
335 spin_unlock_irqrestore(&itc_sync_lock, flags);
339 printk(
"rt=%5ld master=%5ld diff=%5ld adjlat=%5ld\n",
340 t[i].rt,
t[i].master,
t[i].diff,
t[i].lat);
343 printk(
KERN_INFO "CPU %d: synchronized ITC with CPU %u (last diff %ld cycles, "
351 smp_setup_percpu_timer (
void)
358 int cpuid, phys_id, itc_master;
363 #ifdef CONFIG_PERFMON
372 printk(
KERN_ERR "huh, phys CPU#0x%x, CPU#0x%x already present??\n",
383 set_numa_mem(local_memory_node(cpu_to_node_map[cpuid]));
385 spin_lock(&vector_lock);
388 notify_cpu_starting(cpuid);
391 spin_unlock(&vector_lock);
393 smp_setup_percpu_timer();
397 #ifdef CONFIG_PERFMON
410 Dprintk(
"Going to syncup ITC with ITC Master.\n");
438 cpu_set(cpuid, cpu_callin_map);
439 Dprintk(
"Stack on CPU %d at about %p\n",cpuid, &cpuid);
451 #ifndef CONFIG_PRINTK_TIME
473 task_for_booting_cpu =
idle;
482 Dprintk(
"Waiting on callin_map ...");
483 for (timeout = 0; timeout < 100000; timeout++) {
518 for (cpu = 0; cpu <
NR_CPUS; cpu++) {
525 for (cpu = 1, i = 0; i < smp_boot_data.cpu_count; i++) {
526 sapicid = smp_boot_data.cpu_phys_id[
i];
527 if (sapicid == boot_cpu_id)
548 smp_setup_percpu_timer();
580 #ifdef CONFIG_HOTPLUG_CPU
582 clear_cpu_sibling_map(
int cpu)
595 remove_siblinginfo(
int cpu)
600 cpu_data(cpu)->cores_per_socket == 1) {
609 clear_cpu_sibling_map(cpu);
614 int migrate_platform_irqs(
unsigned int cpu)
624 if (cpe_vector > 0 && is_cpu_cpei_target(cpu)) {
625 printk (
"CPU (%d) is CPEI Target\n", cpu);
626 if (can_cpei_retarget()) {
632 set_cpei_target_cpu(new_cpei_cpu);
639 if (data && data->
chip) {
640 data->
chip->irq_disable(data);
641 data->
chip->irq_set_affinity(data, mask,
false);
642 data->
chip->irq_enable(data);
643 printk (
"Re-targeting CPEI to cpu %d\n", new_cpei_cpu);
647 printk (
"Unable to retarget CPEI, offline cpu [%d] failed\n", cpu);
662 if (cpu == 0 && !bsp_remove_ok) {
663 printk (
"Your platform does not support removal of BSP\n");
674 if (migrate_platform_irqs(cpu)) {
679 remove_siblinginfo(cpu);
690 for (i = 0; i < 100; i++) {
694 printk (
"CPU %d is now offline\n", cpu);
707 unsigned long bogosum = 0;
714 bogosum +=
cpu_data(cpu)->loops_per_jiffy;
717 printk(
KERN_INFO "Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
722 set_cpu_sibling_map(
int cpu)
757 ret = do_boot_cpu(sapicid, cpu, tidle);
762 cpu_data(cpu)->cores_per_socket == 1) {
768 set_cpu_sibling_map(cpu);
789 ap_startup = (
struct fptr *)
start_ap;
808 status = ia64_pal_logical_to_phys(-1, &info);
812 "ia64_pal_logical_to_phys failed with %ld\n",
817 info.overview_ppid = 0;
818 info.overview_cpp = 1;
819 info.overview_tpc = 1;
822 status = ia64_sal_physical_id_info(&pltid);
826 "ia64_sal_pltid failed with %ld\n",
831 c->socket_id = (pltid << 8) | info.overview_ppid;
833 if (info.overview_cpp == 1 && info.overview_tpc == 1)
836 c->cores_per_socket = info.overview_cpp;
837 c->threads_per_core = info.overview_tpc;
838 c->num_log = info.overview_num_log;
840 c->core_id = info.log1_cid;
841 c->thread_id = info.log1_tid;