Lines Matching full:cpu
23 #include <linux/cpu.h>
38 #include <asm/cpu.h>
79 static int op_cpu_kill(unsigned int cpu);
81 static inline int op_cpu_kill(unsigned int cpu) in op_cpu_kill() argument
89 * Boot a secondary CPU, and assign it the specified idle task.
90 * This also gives us the initial stack to use for this CPU.
92 static int boot_secondary(unsigned int cpu, struct task_struct *idle) in boot_secondary() argument
94 if (cpu_ops[cpu]->cpu_boot) in boot_secondary()
95 return cpu_ops[cpu]->cpu_boot(cpu); in boot_secondary()
102 int __cpu_up(unsigned int cpu, struct task_struct *idle) in __cpu_up() argument
117 * Now bring the CPU into our world. in __cpu_up()
119 ret = boot_secondary(cpu, idle); in __cpu_up()
122 * CPU was successfully started, wait for it to come online or in __cpu_up()
128 if (!cpu_online(cpu)) { in __cpu_up()
129 pr_crit("CPU%u: failed to come online\n", cpu); in __cpu_up()
133 pr_err("CPU%u: failed to boot: %d\n", cpu, ret); in __cpu_up()
148 pr_err("CPU%u: failed in unknown state : 0x%lx\n", in __cpu_up()
149 cpu, status); in __cpu_up()
153 if (!op_cpu_kill(cpu)) { in __cpu_up()
154 pr_crit("CPU%u: died during early boot\n", cpu); in __cpu_up()
157 pr_crit("CPU%u: may not have shut down cleanly\n", cpu); in __cpu_up()
160 pr_crit("CPU%u: is stuck in kernel\n", cpu); in __cpu_up()
162 pr_crit("CPU%u: does not support 52-bit VAs\n", cpu); in __cpu_up()
164 pr_crit("CPU%u: does not support %luK granule \n", cpu, PAGE_SIZE / SZ_1K); in __cpu_up()
168 panic("CPU%u detected unsupported configuration\n", cpu); in __cpu_up()
190 * This is the secondary CPU boot entry. We're using this CPUs
197 unsigned int cpu; in secondary_start_kernel() local
199 cpu = task_cpu(current); in secondary_start_kernel()
200 set_my_cpu_offset(per_cpu_offset(cpu)); in secondary_start_kernel()
223 * this CPU ticks all of those. If it doesn't, the CPU will in secondary_start_kernel()
228 if (cpu_ops[cpu]->cpu_postboot) in secondary_start_kernel()
229 cpu_ops[cpu]->cpu_postboot(); in secondary_start_kernel()
232 * Log the CPU info before it is marked online and might get read. in secondary_start_kernel()
239 notify_cpu_starting(cpu); in secondary_start_kernel()
241 store_cpu_topology(cpu); in secondary_start_kernel()
242 numa_add_cpu(cpu); in secondary_start_kernel()
245 * OK, now it's safe to let the boot CPU continue. Wait for in secondary_start_kernel()
246 * the CPU migration code to notice that the CPU is online in secondary_start_kernel()
249 pr_info("CPU%u: Booted secondary processor 0x%010lx [0x%08x]\n", in secondary_start_kernel()
250 cpu, (unsigned long)mpidr, in secondary_start_kernel()
253 set_cpu_online(cpu, true); in secondary_start_kernel()
265 static int op_cpu_disable(unsigned int cpu) in op_cpu_disable() argument
271 if (!cpu_ops[cpu] || !cpu_ops[cpu]->cpu_die) in op_cpu_disable()
278 if (cpu_ops[cpu]->cpu_disable) in op_cpu_disable()
279 return cpu_ops[cpu]->cpu_disable(cpu); in op_cpu_disable()
289 unsigned int cpu = smp_processor_id(); in __cpu_disable() local
292 ret = op_cpu_disable(cpu); in __cpu_disable()
296 remove_cpu_topology(cpu); in __cpu_disable()
297 numa_remove_cpu(cpu); in __cpu_disable()
300 * Take this CPU offline. Once we clear this, we can't return, in __cpu_disable()
301 * and we must not schedule until we're ready to give up the cpu. in __cpu_disable()
303 set_cpu_online(cpu, false); in __cpu_disable()
306 * OK - migrate IRQs away from this CPU in __cpu_disable()
313 static int op_cpu_kill(unsigned int cpu) in op_cpu_kill() argument
316 * If we have no means of synchronising with the dying CPU, then assume in op_cpu_kill()
320 if (!cpu_ops[cpu]->cpu_kill) in op_cpu_kill()
323 return cpu_ops[cpu]->cpu_kill(cpu); in op_cpu_kill()
327 * called on the thread which is asking for a CPU to be shutdown -
330 void __cpu_die(unsigned int cpu) in __cpu_die() argument
334 if (!cpu_wait_death(cpu, 5)) { in __cpu_die()
335 pr_crit("CPU%u: cpu didn't die\n", cpu); in __cpu_die()
338 pr_notice("CPU%u: shutdown\n", cpu); in __cpu_die()
341 * Now that the dying CPU is beyond the point of no return w.r.t. in __cpu_die()
346 err = op_cpu_kill(cpu); in __cpu_die()
348 pr_warn("CPU%d may not have shut down cleanly: %d\n", in __cpu_die()
349 cpu, err); in __cpu_die()
353 * Called from the idle thread for the CPU which has been shutdown.
358 unsigned int cpu = smp_processor_id(); in cpu_die() local
364 /* Tell __cpu_die() that this CPU is now safe to dispose of */ in cpu_die()
368 * Actually shutdown the CPU. This must never fail. The specific hotplug in cpu_die()
370 * no dirty lines are lost in the process of shutting down the CPU. in cpu_die()
372 cpu_ops[cpu]->cpu_die(cpu); in cpu_die()
379 * Kill the calling secondary CPU, early in bringup before it is turned
384 int cpu = smp_processor_id(); in cpu_die_early() local
386 pr_crit("CPU%d: will not boot\n", cpu); in cpu_die_early()
388 /* Mark this CPU absent */ in cpu_die_early()
389 set_cpu_present(cpu, 0); in cpu_die_early()
394 if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_die) in cpu_die_early()
395 cpu_ops[cpu]->cpu_die(cpu); in cpu_die_early()
405 pr_info("CPU: All CPU(s) started at EL2\n"); in hyp_mode_check()
408 "CPU: CPUs started in inconsistent modes"); in hyp_mode_check()
410 pr_info("CPU: All CPU(s) started at EL1\n"); in hyp_mode_check()
428 * We now know enough about the boot CPU to apply the in smp_prepare_boot_cpu()
445 * A cpu node with missing "reg" property is in of_get_cpu_mpidr()
469 * cpu. cpu_logical_map was initialized to INVALID_HWID to avoid
472 static bool __init is_mpidr_duplicate(unsigned int cpu, u64 hwid) in is_mpidr_duplicate() argument
476 for (i = 1; (i < cpu) && (i < NR_CPUS); i++) in is_mpidr_duplicate()
483 * Initialize cpu operations for a logical cpu and
486 static int __init smp_cpu_setup(int cpu) in smp_cpu_setup() argument
488 if (cpu_read_ops(cpu)) in smp_cpu_setup()
491 if (cpu_ops[cpu]->cpu_init(cpu)) in smp_cpu_setup()
494 set_cpu_possible(cpu, true); in smp_cpu_setup()
505 struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu) in acpi_cpu_get_madt_gicc() argument
507 return &cpu_madt_gicc[cpu]; in acpi_cpu_get_madt_gicc()
522 pr_debug("skipping disabled CPU entry with 0x%llx MPIDR\n", hwid); in acpi_map_gic_cpu_interface()
527 pr_err("skipping CPU entry with invalid MPIDR 0x%llx\n", hwid); in acpi_map_gic_cpu_interface()
532 pr_err("duplicate CPU MPIDR 0x%llx in MADT\n", hwid); in acpi_map_gic_cpu_interface()
536 /* Check if GICC structure of boot CPU is available in the MADT */ in acpi_map_gic_cpu_interface()
539 pr_err("duplicate boot CPU MPIDR: 0x%llx in MADT\n", in acpi_map_gic_cpu_interface()
551 /* map the logical cpu id to cpu MPIDR */ in acpi_map_gic_cpu_interface()
557 * Set-up the ACPI parking protocol cpu entries in acpi_map_gic_cpu_interface()
562 * initialize the cpu if the parking protocol is in acpi_map_gic_cpu_interface()
600 * In ACPI, SMP and CPU NUMA information is provided in separate in acpi_parse_and_init_cpus()
603 * Thus, it is simpler to first create the cpu logical map through in acpi_parse_and_init_cpus()
617 * Enumerate the possible CPU set from the device tree and build the
618 * cpu logical map array containing MPIDR values related to logical
632 pr_err("%pOF: duplicate cpu reg properties in the DT\n", in of_parse_and_init_cpus()
638 * The numbering scheme requires that the boot CPU in of_parse_and_init_cpus()
645 pr_err("%pOF: duplicate boot cpu reg property in DT\n", in of_parse_and_init_cpus()
655 * initialized and the boot cpu doesn't need in of_parse_and_init_cpus()
657 * incrementing cpu. in of_parse_and_init_cpus()
665 pr_debug("cpu logical map 0x%llx\n", hwid); in of_parse_and_init_cpus()
675 * Enumerate the possible CPU set from the device tree or ACPI and build the
676 * cpu logical map array containing MPIDR values related to logical
693 pr_err("missing boot CPU MPIDR, not enabling secondaries\n"); in smp_init_cpus()
699 * the cpus so that cpu processor description entries (DT cpu nodes in smp_init_cpus()
700 * and ACPI MADT entries) can be retrieved by matching the cpu hwid in smp_init_cpus()
702 * If the cpu set-up fails, invalidate the cpu_logical_map entry. in smp_init_cpus()
715 unsigned int cpu; in smp_prepare_cpus() local
737 for_each_possible_cpu(cpu) { in smp_prepare_cpus()
739 per_cpu(cpu_number, cpu) = cpu; in smp_prepare_cpus()
741 if (cpu == smp_processor_id()) in smp_prepare_cpus()
744 if (!cpu_ops[cpu]) in smp_prepare_cpus()
747 err = cpu_ops[cpu]->cpu_prepare(cpu); in smp_prepare_cpus()
751 set_cpu_present(cpu, true); in smp_prepare_cpus()
752 numa_store_cpu_info(cpu); in smp_prepare_cpus()
767 S(IPI_CPU_STOP, "CPU stop interrupts"),
768 S(IPI_CPU_CRASH_STOP, "CPU stop (for crash dump) interrupts"),
771 S(IPI_WAKEUP, "CPU wake-up interrupts"),
782 unsigned int cpu, i; in show_ipi_list() local
787 for_each_online_cpu(cpu) in show_ipi_list()
789 __get_irq_stat(cpu, ipi_irqs[i])); in show_ipi_list()
794 u64 smp_irq_stat_cpu(unsigned int cpu) in smp_irq_stat_cpu() argument
800 sum += __get_irq_stat(cpu, ipi_irqs[i]); in smp_irq_stat_cpu()
810 void arch_send_call_function_single_ipi(int cpu) in arch_send_call_function_single_ipi() argument
812 smp_cross_call(cpumask_of(cpu), IPI_CALL_FUNC); in arch_send_call_function_single_ipi()
853 static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs) in ipi_cpu_crash_stop() argument
856 crash_save_cpu(regs, cpu); in ipi_cpu_crash_stop()
864 if (cpu_ops[cpu]->cpu_die) in ipi_cpu_crash_stop()
865 cpu_ops[cpu]->cpu_die(cpu); in ipi_cpu_crash_stop()
878 unsigned int cpu = smp_processor_id(); in handle_IPI() local
883 __inc_irq_stat(cpu, ipi_irqs[ipinr]); in handle_IPI()
906 ipi_cpu_crash_stop(cpu, regs); in handle_IPI()
930 WARN_ONCE(!acpi_parking_protocol_valid(cpu), in handle_IPI()
931 "CPU%u: Wake-up IPI outside the ACPI parking protocol\n", in handle_IPI()
932 cpu); in handle_IPI()
937 pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr); in handle_IPI()
946 void smp_send_reschedule(int cpu) in smp_send_reschedule() argument
948 smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE); in smp_send_reschedule()