Lines Matching +full:1 +full:- +full:cpu

1 // SPDX-License-Identifier: GPL-2.0
5 * 2001-07-09 Phil Ezolt (Phillip.Ezolt@compaq.com)
31 #include <linux/cpu.h>
54 /* A collection of per-processor data. */
73 int smp_num_cpus = 1; /* Number that came online. */
78 * per-processor storage.
90 * Ideally sets up per-cpu profiling hooks. Doesn't do much now...
95 cpu_data[cpuid].prof_counter = 1; in smp_setup_percpu_timer()
96 cpu_data[cpuid].prof_multiplier = 1; in smp_setup_percpu_timer()
110 printk("wait_boot_cpu_to_stop: FAILED on CPU %d, hanging now\n", cpuid); in wait_boot_cpu_to_stop()
124 printk("??, cpu 0x%x already present??\n", cpuid); in smp_callin()
142 /* Call platform-specific callin, if specified */ in smp_callin()
148 current->active_mm = &init_mm; in smp_callin()
150 /* inform the notifiers about the new cpu */ in smp_callin()
156 /* Wait boot CPU to stop with irq enabled before running in smp_callin()
165 smp_secondary_alive = 1; in smp_callin()
167 DBGS(("smp_callin: commencing CPU %d current %p active_mm %p\n", in smp_callin()
168 cpuid, current, current->active_mm)); in smp_callin()
173 /* Wait until hwrpb->txrdy is clear for cpu. Return -1 on timeout. */
179 if (!(hwrpb->txrdy & cpumask)) in wait_for_txrdy()
184 if (!(hwrpb->txrdy & cpumask)) in wait_for_txrdy()
190 return -1; in wait_for_txrdy()
195 * interesting message. ;-)
200 struct percpu_struct *cpu; in send_secondary_console_msg() local
205 cpu = (struct percpu_struct *) in send_secondary_console_msg()
207 + hwrpb->processor_offset in send_secondary_console_msg()
208 + cpuid * hwrpb->processor_size); in send_secondary_console_msg()
210 cpumask = (1UL << cpuid); in send_secondary_console_msg()
216 *(unsigned int *)&cpu->ipc_buffer[0] = len; in send_secondary_console_msg()
217 cp1 = (char *) &cpu->ipc_buffer[1]; in send_secondary_console_msg()
222 set_bit(cpuid, &hwrpb->rxrdy); in send_secondary_console_msg()
239 unsigned long txrdy = hwrpb->txrdy; in recv_secondary_console_msg()
241 struct percpu_struct *cpu; in recv_secondary_console_msg() local
248 if (!(txrdy & (1UL << i))) in recv_secondary_console_msg()
252 "TXRDY contains CPU %d.\n", i)); in recv_secondary_console_msg()
254 cpu = (struct percpu_struct *) in recv_secondary_console_msg()
256 + hwrpb->processor_offset in recv_secondary_console_msg()
257 + i * hwrpb->processor_size); in recv_secondary_console_msg()
261 mycpu, i, cpu->halt_reason, cpu->flags)); in recv_secondary_console_msg()
263 cnt = cpu->ipc_buffer[0] >> 32; in recv_secondary_console_msg()
267 cp1 = (char *) &cpu->ipc_buffer[1]; in recv_secondary_console_msg()
274 if (cp2[1] == '\n') in recv_secondary_console_msg()
275 cp2[1] = ' '; in recv_secondary_console_msg()
283 hwrpb->txrdy = 0; in recv_secondary_console_msg()
287 * Convince the console to have a secondary cpu begin execution.
292 struct percpu_struct *cpu; in secondary_cpu_start() local
296 cpu = (struct percpu_struct *) in secondary_cpu_start()
298 + hwrpb->processor_offset in secondary_cpu_start()
299 + cpuid * hwrpb->processor_size); in secondary_cpu_start()
300 hwpcb = (struct pcb_struct *) cpu->hwpcb; in secondary_cpu_start()
301 ipcb = &task_thread_info(idle)->pcb; in secondary_cpu_start()
303 /* Initialize the CPU's HWPCB to something just good enough for in secondary_cpu_start()
307 hwpcb->ksp = (unsigned long)ipcb + sizeof(union thread_union) - 16; in secondary_cpu_start()
308 hwpcb->usp = 0; in secondary_cpu_start()
309 hwpcb->ptbr = ipcb->ptbr; in secondary_cpu_start()
310 hwpcb->pcc = 0; in secondary_cpu_start()
311 hwpcb->asn = 0; in secondary_cpu_start()
312 hwpcb->unique = virt_to_phys(ipcb); in secondary_cpu_start()
313 hwpcb->flags = ipcb->flags; in secondary_cpu_start()
314 hwpcb->res1 = hwpcb->res2 = 0; in secondary_cpu_start()
318 hwpcb->ksp, hwpcb->ptbr, hwrpb->vptb, hwpcb->unique)); in secondary_cpu_start()
320 DBGS(("Starting secondary cpu %d: state 0x%lx pal_flags 0x%lx\n", in secondary_cpu_start()
321 cpuid, idle->state, ipcb->flags)); in secondary_cpu_start()
323 /* Setup HWRPB fields that SRM uses to activate secondary CPU */ in secondary_cpu_start()
324 hwrpb->CPU_restart = __smp_callin; in secondary_cpu_start()
325 hwrpb->CPU_restart_data = (unsigned long) __smp_callin; in secondary_cpu_start()
335 cpu->flags |= 0x22; /* turn on Context Valid and Restart Capable */ in secondary_cpu_start()
336 cpu->flags &= ~1; /* turn off Bootstrap In Progress */ in secondary_cpu_start()
344 if (cpu->flags & 1) in secondary_cpu_start()
350 return -1; in secondary_cpu_start()
353 DBGS(("secondary_cpu_start: SUCCESS for CPU %d!!!\n", cpuid)); in secondary_cpu_start()
358 * Bring one cpu online.
366 smp_secondary_alive = -1; in smp_boot_one_cpu()
370 return -1; in smp_boot_one_cpu()
372 /* Notify the secondary CPU it can run calibrate_delay. */ in smp_boot_one_cpu()
378 timeout = jiffies + 1*HZ; in smp_boot_one_cpu()
380 if (smp_secondary_alive == 1) in smp_boot_one_cpu()
386 /* We failed to boot the CPU. */ in smp_boot_one_cpu()
389 return -1; in smp_boot_one_cpu()
403 struct percpu_struct *cpubase, *cpu; in setup_smp() local
407 printk(KERN_WARNING "SMP: Booting off cpu %d instead of 0?\n", in setup_smp()
411 if (hwrpb->nr_processors > 1) { in setup_smp()
415 hwrpb->nr_processors)); in setup_smp()
418 ((char*)hwrpb + hwrpb->processor_offset); in setup_smp()
419 boot_cpu_palrev = cpubase->pal_revision; in setup_smp()
421 for (i = 0; i < hwrpb->nr_processors; i++) { in setup_smp()
422 cpu = (struct percpu_struct *) in setup_smp()
423 ((char *)cpubase + i*hwrpb->processor_size); in setup_smp()
424 if ((cpu->flags & 0x1cc) == 0x1cc) { in setup_smp()
428 cpu->pal_revision = boot_cpu_palrev; in setup_smp()
431 DBGS(("setup_smp: CPU %d: flags 0x%lx type 0x%lx\n", in setup_smp()
432 i, cpu->flags, cpu->type)); in setup_smp()
433 DBGS(("setup_smp: CPU %d: PAL rev 0x%lx\n", in setup_smp()
434 i, cpu->pal_revision)); in setup_smp()
437 smp_num_probed = 1; in setup_smp()
440 printk(KERN_INFO "SMP: %d CPUs probed -- cpu_present_mask = %lx\n", in setup_smp()
453 current_thread_info()->cpu = boot_cpuid; in smp_prepare_cpus()
459 if (smp_num_probed == 1 || max_cpus == 0) { in smp_prepare_cpus()
472 __cpu_up(unsigned int cpu, struct task_struct *tidle) in __cpu_up() argument
474 smp_boot_one_cpu(cpu, tidle); in __cpu_up()
476 return cpu_online(cpu) ? 0 : -ENOSYS; in __cpu_up()
482 int cpu; in smp_cpus_done() local
485 for(cpu = 0; cpu < NR_CPUS; cpu++) in smp_cpus_done()
486 if (cpu_online(cpu)) in smp_cpus_done()
487 bogosum += cpu_data[cpu].loops_per_jiffy; in smp_cpus_done()
518 DBGS(("handle_ipi: on CPU %d ops 0x%lx PC 0x%lx\n", in handle_ipi()
519 this_cpu, *pending_ipis, regs->pc)); in handle_ipi()
528 which = ops & -ops; in handle_ipi()
545 printk(KERN_CRIT "Unknown IPI on CPU %d: %lu\n", in handle_ipi()
556 if (hwrpb->txrdy) in handle_ipi()
561 arch_smp_send_reschedule(int cpu) in arch_smp_send_reschedule() argument
564 if (cpu == hard_smp_processor_id()) in arch_smp_send_reschedule()
568 send_ipi_message(cpumask_of(cpu), IPI_RESCHEDULE); in arch_smp_send_reschedule()
579 printk(KERN_WARNING "smp_send_stop: Not on boot cpu.\n"); in smp_send_stop()
589 void arch_send_call_function_single_ipi(int cpu) in arch_send_call_function_single_ipi() argument
591 send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC); in arch_send_call_function_single_ipi()
604 on_each_cpu(ipi_imb, NULL, 1); in smp_imb()
619 on_each_cpu(ipi_flush_tlb_all, NULL, 1); in flush_tlb_all()
628 if (mm == current->active_mm && !asn_locked()) in ipi_flush_tlb_mm()
639 if (mm == current->active_mm) { in flush_tlb_mm()
641 if (atomic_read(&mm->mm_users) <= 1) { in flush_tlb_mm()
642 int cpu, this_cpu = smp_processor_id(); in flush_tlb_mm() local
643 for (cpu = 0; cpu < NR_CPUS; cpu++) { in flush_tlb_mm()
644 if (!cpu_online(cpu) || cpu == this_cpu) in flush_tlb_mm()
646 if (mm->context[cpu]) in flush_tlb_mm()
647 mm->context[cpu] = 0; in flush_tlb_mm()
654 smp_call_function(ipi_flush_tlb_mm, mm, 1); in flush_tlb_mm()
670 struct mm_struct * mm = data->mm; in ipi_flush_tlb_page()
672 if (mm == current->active_mm && !asn_locked()) in ipi_flush_tlb_page()
673 flush_tlb_current_page(mm, data->vma, data->addr); in ipi_flush_tlb_page()
682 struct mm_struct *mm = vma->vm_mm; in flush_tlb_page()
686 if (mm == current->active_mm) { in flush_tlb_page()
688 if (atomic_read(&mm->mm_users) <= 1) { in flush_tlb_page()
689 int cpu, this_cpu = smp_processor_id(); in flush_tlb_page() local
690 for (cpu = 0; cpu < NR_CPUS; cpu++) { in flush_tlb_page()
691 if (!cpu_online(cpu) || cpu == this_cpu) in flush_tlb_page()
693 if (mm->context[cpu]) in flush_tlb_page()
694 mm->context[cpu] = 0; in flush_tlb_page()
705 smp_call_function(ipi_flush_tlb_page, &data, 1); in flush_tlb_page()
715 flush_tlb_mm(vma->vm_mm); in flush_tlb_range()
723 if (mm == current->active_mm && !asn_locked()) in ipi_flush_icache_page()
733 struct mm_struct *mm = vma->vm_mm; in flush_icache_user_page()
735 if ((vma->vm_flags & VM_EXEC) == 0) in flush_icache_user_page()
740 if (mm == current->active_mm) { in flush_icache_user_page()
742 if (atomic_read(&mm->mm_users) <= 1) { in flush_icache_user_page()
743 int cpu, this_cpu = smp_processor_id(); in flush_icache_user_page() local
744 for (cpu = 0; cpu < NR_CPUS; cpu++) { in flush_icache_user_page()
745 if (!cpu_online(cpu) || cpu == this_cpu) in flush_icache_user_page()
747 if (mm->context[cpu]) in flush_icache_user_page()
748 mm->context[cpu] = 0; in flush_icache_user_page()
755 smp_call_function(ipi_flush_icache_page, mm, 1); in flush_icache_user_page()