13 #include <linux/errno.h>
14 #include <linux/kernel.h>
16 #include <linux/module.h>
17 #include <linux/sched.h>
29 #include <linux/bitops.h>
33 #include <asm/ptrace.h>
38 #include <asm/pgtable.h>
39 #include <asm/pgalloc.h>
40 #include <asm/mmu_context.h>
41 #include <asm/tlbflush.h>
49 #define DBGS(args) printk args
82 smp_store_cpu_info(
int cpuid)
94 smp_setup_percpu_timer(
int cpuid)
101 wait_boot_cpu_to_stop(
int cpuid)
106 if (!smp_secondary_alive)
111 printk(
"wait_boot_cpu_to_stop: FAILED on CPU %d, hanging now\n", cpuid);
125 printk(
"??, cpu 0x%x already present??\n", cpuid);
140 smp_setup_percpu_timer(cpuid);
143 if (alpha_mv.smp_callin) alpha_mv.smp_callin();
150 notify_cpu_starting(cpuid);
157 wait_boot_cpu_to_stop(cpuid);
161 smp_store_cpu_info(cpuid);
164 smp_secondary_alive = 1;
166 DBGS((
"smp_callin: commencing CPU %d current %p active_mm %p\n",
176 wait_for_txrdy (
unsigned long cpumask)
180 if (!(
hwrpb->txrdy & cpumask))
185 if (!(
hwrpb->txrdy & cpumask))
199 send_secondary_console_msg(
char *
str,
int cpuid)
202 register char *cp1, *cp2;
208 +
hwrpb->processor_offset
209 + cpuid *
hwrpb->processor_size);
212 if (wait_for_txrdy(cpumask))
225 if (wait_for_txrdy(cpumask))
230 printk(
"Processor %x not ready\n", cpuid);
237 recv_secondary_console_msg(
void)
240 unsigned long txrdy =
hwrpb->txrdy;
241 char *cp1, *cp2,
buf[80];
244 DBGS((
"recv_secondary_console_msg: TXRDY 0x%lx.\n", txrdy));
248 for (i = 0; i <
NR_CPUS; i++) {
249 if (!(txrdy & (1
UL << i)))
252 DBGS((
"recv_secondary_console_msg: "
253 "TXRDY contains CPU %d.\n", i));
257 +
hwrpb->processor_offset
258 + i *
hwrpb->processor_size);
260 DBGS((
"recv_secondary_console_msg: on %d from %d"
261 " HALT_REASON 0x%lx FLAGS 0x%lx\n",
265 if (cnt <= 0 || cnt >= 80)
266 strcpy(buf,
"<<< BOGUS MSG >>>");
272 while ((cp2 =
strchr(cp2,
'\r')) != 0) {
280 "message is '%s'\n", mycpu, buf));
294 unsigned long timeout;
298 +
hwrpb->processor_offset
299 + cpuid *
hwrpb->processor_size);
317 DBGS((
"KSP 0x%lx PTBR 0x%lx VPTBR 0x%lx UNIQUE 0x%lx\n",
320 DBGS((
"Starting secondary cpu %d: state 0x%lx pal_flags 0x%lx\n",
328 hwrpb_update_checksum(
hwrpb);
339 send_secondary_console_msg(
"START\r\n", cpuid);
353 DBGS((
"secondary_cpu_start: SUCCESS for CPU %d!!!\n", cpuid));
363 unsigned long timeout;
366 smp_secondary_alive = -1;
369 if (secondary_cpu_start(cpuid, idle))
374 smp_secondary_alive = 0;
380 if (smp_secondary_alive == 1)
411 if (
hwrpb->nr_processors > 1) {
414 DBGS((
"setup_smp: nr_processors %ld\n",
415 hwrpb->nr_processors));
421 for (i = 0; i <
hwrpb->nr_processors; i++) {
423 ((
char *)cpubase + i*
hwrpb->processor_size);
424 if ((cpu->
flags & 0x1cc) == 0x1cc) {
431 DBGS((
"setup_smp: CPU %d: flags 0x%lx type 0x%lx\n",
433 DBGS((
"setup_smp: CPU %d: PAL rev 0x%lx\n",
488 unsigned long bogosum = 0;
490 for(cpu = 0; cpu <
NR_CPUS; cpu++)
495 "(%lu.%02lu BogoMIPS).\n",
497 (bogosum + 2500) / (500000/HZ),
498 ((bogosum + 2500) / (5000/HZ)) % 100);
510 old_regs = set_irq_regs(regs);
515 if (!--data->prof_counter) {
523 data->prof_counter = data->prof_multiplier;
527 set_irq_regs(old_regs);
559 DBGS((
"handle_ipi: on CPU %d ops 0x%lx PC 0x%lx\n",
560 this_cpu, *pending_ipis, regs->pc));
564 while ((ops =
xchg(pending_ipis, 0)) != 0) {
571 which =
__ffs(which);
579 generic_smp_call_function_interrupt();
583 generic_smp_call_function_single_interrupt();
602 recv_secondary_console_msg();
611 "smp_send_reschedule: Sending IPI to self.\n");
655 ipi_flush_tlb_all(
void *
ignored)
670 #define asn_locked() (cpu_data[smp_processor_id()].asn_lock)
673 ipi_flush_tlb_mm(
void *
x)
687 if (mm ==
current->active_mm) {
691 for (cpu = 0; cpu <
NR_CPUS; cpu++) {
717 ipi_flush_tlb_page(
void *
x)
736 if (mm ==
current->active_mm) {
740 for (cpu = 0; cpu <
NR_CPUS; cpu++) {
772 ipi_flush_icache_page(
void *
x)
783 unsigned long addr,
int len)
792 if (mm ==
current->active_mm) {
796 for (cpu = 0; cpu <
NR_CPUS; cpu++) {