Lines Matching full:cpu

13  * The code outside of smp.c uses logical cpu numbers, only smp.c does
14 * the translation of logical to physical cpu ids. All new code that
15 * operates on physical cpu numbers needs to go into smp.c.
18 #define KMSG_COMPONENT "cpu"
33 #include <linux/cpu.h>
76 static DEFINE_PER_CPU(struct cpu *, cpu_device);
81 signed char state; /* physical cpu state */
83 u16 address; /* physical cpu address */
166 /* Status stored condition code is equivalent to cpu not running. */ in pcpu_running()
171 * Find struct pcpu by cpu address.
175 int cpu; in pcpu_find_address() local
177 for_each_cpu(cpu, mask) in pcpu_find_address()
178 if (pcpu_devices[cpu].address == address) in pcpu_find_address()
179 return pcpu_devices + cpu; in pcpu_find_address()
194 static int pcpu_alloc_lowcore(struct pcpu *pcpu, int cpu) in pcpu_alloc_lowcore() argument
210 lc->cpu_nr = cpu; in pcpu_alloc_lowcore()
211 lc->spinlock_lockval = arch_spin_lockval(cpu); in pcpu_alloc_lowcore()
218 if (abs_lowcore_map(cpu, lc, true)) in pcpu_alloc_lowcore()
220 lowcore_ptr[cpu] = lc; in pcpu_alloc_lowcore()
238 int cpu; in pcpu_free_lowcore() local
240 cpu = pcpu - pcpu_devices; in pcpu_free_lowcore()
241 lc = lowcore_ptr[cpu]; in pcpu_free_lowcore()
246 lowcore_ptr[cpu] = NULL; in pcpu_free_lowcore()
247 abs_lowcore_unmap(cpu); in pcpu_free_lowcore()
255 static void pcpu_prepare_secondary(struct pcpu *pcpu, int cpu) in pcpu_prepare_secondary() argument
259 lc = lowcore_ptr[cpu]; in pcpu_prepare_secondary()
260 cpumask_set_cpu(cpu, &init_mm.context.cpu_attach_mask); in pcpu_prepare_secondary()
261 cpumask_set_cpu(cpu, mm_cpumask(&init_mm)); in pcpu_prepare_secondary()
262 lc->cpu_nr = cpu; in pcpu_prepare_secondary()
264 lc->spinlock_lockval = arch_spin_lockval(cpu); in pcpu_prepare_secondary()
266 lc->percpu_offset = __per_cpu_offset[cpu]; in pcpu_prepare_secondary()
278 arch_spin_lock_setup(cpu); in pcpu_prepare_secondary()
284 int cpu; in pcpu_attach_task() local
286 cpu = pcpu - pcpu_devices; in pcpu_attach_task()
287 lc = lowcore_ptr[cpu]; in pcpu_attach_task()
303 int cpu; in pcpu_start_fn() local
305 cpu = pcpu - pcpu_devices; in pcpu_start_fn()
306 lc = lowcore_ptr[cpu]; in pcpu_start_fn()
317 * Call function via PSW restart on pcpu and stop the current cpu.
338 /* Stop target cpu (if func returns this stops the current cpu). */ in pcpu_delegate()
341 /* Restart func on the target cpu and stop the current cpu. */ in pcpu_delegate()
356 "0: sigp 0,%0,%2 # sigp restart to target cpu\n" in pcpu_delegate()
358 "1: sigp 0,%1,%3 # sigp stop to current cpu\n" in pcpu_delegate()
387 * Call function on an online CPU.
393 /* Use the current cpu if it is online. */ in smp_call_online_cpu()
396 /* Use the first online cpu. */ in smp_call_online_cpu()
402 * Call function on the ipl CPU.
417 int cpu; in smp_find_processor_id() local
419 for_each_present_cpu(cpu) in smp_find_processor_id()
420 if (pcpu_devices[cpu].address == address) in smp_find_processor_id()
421 return cpu; in smp_find_processor_id()
430 bool notrace arch_vcpu_is_preempted(int cpu) in arch_vcpu_is_preempted() argument
432 if (test_cpu_flag_of(CIF_ENABLED_WAIT, cpu)) in arch_vcpu_is_preempted()
434 if (pcpu_running(pcpu_devices + cpu)) in arch_vcpu_is_preempted()
440 void notrace smp_yield_cpu(int cpu) in smp_yield_cpu() argument
446 : : "d" (pcpu_devices[cpu].address)); in smp_yield_cpu()
459 int cpu; in smp_emergency_stop() local
466 for_each_cpu(cpu, &cpumask) { in smp_emergency_stop()
467 struct pcpu *pcpu = pcpu_devices + cpu; in smp_emergency_stop()
475 for_each_cpu(cpu, &cpumask) in smp_emergency_stop()
476 if (pcpu_stopped(pcpu_devices + cpu)) in smp_emergency_stop()
477 cpumask_clear_cpu(cpu, &cpumask); in smp_emergency_stop()
491 int cpu; in smp_send_stop() local
503 for_each_online_cpu(cpu) { in smp_send_stop()
504 if (cpu == smp_processor_id()) in smp_send_stop()
506 pcpu_sigp_retry(pcpu_devices + cpu, SIGP_STOP, 0); in smp_send_stop()
507 while (!pcpu_stopped(pcpu_devices + cpu)) in smp_send_stop()
543 int cpu; in arch_send_call_function_ipi_mask() local
545 for_each_cpu(cpu, mask) in arch_send_call_function_ipi_mask()
546 pcpu_ec_call(pcpu_devices + cpu, ec_call_function_single); in arch_send_call_function_ipi_mask()
549 void arch_send_call_function_single_ipi(int cpu) in arch_send_call_function_single_ipi() argument
551 pcpu_ec_call(pcpu_devices + cpu, ec_call_function_single); in arch_send_call_function_single_ipi()
555 * this function sends a 'reschedule' IPI to another CPU.
559 void arch_smp_send_reschedule(int cpu) in arch_smp_send_reschedule() argument
561 pcpu_ec_call(pcpu_devices + cpu, ec_schedule); in arch_smp_send_reschedule()
573 int smp_store_status(int cpu) in smp_store_status() argument
579 pcpu = pcpu_devices + cpu; in smp_store_status()
580 lc = lowcore_ptr[cpu]; in smp_store_status()
597 * Collect CPU state of the previous, crashed system.
601 * The state for all CPUs except the boot CPU needs to be collected
602 * with sigp stop-and-store-status. The boot CPU state is located in
604 * will copy the boot CPU state from the HSA.
607 * The state for all CPUs except the boot CPU needs to be collected
609 * stored the registers of the boot CPU in the absolute lowcore in the
611 * 3) kdump and the old kernel did not store the CPU state,
614 * The state for all CPUs except the boot CPU needs to be collected
616 * stored the registers of the boot CPU in the memory of the old system.
617 * 4) kdump and the old kernel stored the CPU state
637 panic("could not allocate memory for boot CPU save area\n"); in smp_save_dump_ipl_cpu()
685 void smp_cpu_set_polarization(int cpu, int val) in smp_cpu_set_polarization() argument
687 pcpu_devices[cpu].polarization = val; in smp_cpu_set_polarization()
690 int smp_cpu_get_polarization(int cpu) in smp_cpu_get_polarization() argument
692 return pcpu_devices[cpu].polarization; in smp_cpu_get_polarization()
695 int smp_cpu_get_cpu_address(int cpu) in smp_cpu_get_cpu_address() argument
697 return pcpu_devices[cpu].address; in smp_cpu_get_cpu_address()
721 static int smp_add_present_cpu(int cpu);
727 int cpu, nr, i; in smp_add_core() local
733 cpu = cpumask_first(avail); in smp_add_core()
735 for (i = 0; (i <= smp_cpu_mtid) && (cpu < nr_cpu_ids); i++) { in smp_add_core()
738 pcpu = pcpu_devices + cpu; in smp_add_core()
744 smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN); in smp_add_core()
745 set_cpu_present(cpu, true); in smp_add_core()
746 if (!early && smp_add_present_cpu(cpu) != 0) in smp_add_core()
747 set_cpu_present(cpu, false); in smp_add_core()
750 cpumask_clear_cpu(cpu, avail); in smp_add_core()
751 cpu = cpumask_next(cpu, avail); in smp_add_core()
769 * Add IPL core first (which got logical CPU number 0) to make sure in __smp_rescan_cpus()
770 * that all SMT threads get subsequent logical CPU numbers. in __smp_rescan_cpus()
793 unsigned int cpu, mtid, c_cpus, s_cpus; in smp_detect_cpus() local
797 /* Get CPU information */ in smp_detect_cpus()
803 /* Find boot CPU type */ in smp_detect_cpus()
806 for (cpu = 0; cpu < info->combined; cpu++) in smp_detect_cpus()
807 if (info->core[cpu].core_id == address) { in smp_detect_cpus()
808 /* The boot cpu dictates the cpu type. */ in smp_detect_cpus()
809 boot_core_type = info->core[cpu].type; in smp_detect_cpus()
812 if (cpu >= info->combined) in smp_detect_cpus()
813 panic("Could not find boot CPU type"); in smp_detect_cpus()
823 for (cpu = 0; cpu < info->combined; cpu++) { in smp_detect_cpus()
825 info->core[cpu].type != boot_core_type) in smp_detect_cpus()
827 if (cpu < info->configured) in smp_detect_cpus()
844 int cpu = raw_smp_processor_id(); in smp_start_secondary() local
854 rcutree_report_cpu_starting(cpu); in smp_start_secondary()
859 cpumask_set_cpu(cpu, &cpu_setup_mask); in smp_start_secondary()
861 notify_cpu_starting(cpu); in smp_start_secondary()
862 if (topology_cpu_dedicated(cpu)) in smp_start_secondary()
866 set_cpu_online(cpu, true); in smp_start_secondary()
873 int __cpu_up(unsigned int cpu, struct task_struct *tidle) in __cpu_up() argument
875 struct pcpu *pcpu = pcpu_devices + cpu; in __cpu_up()
884 rc = pcpu_alloc_lowcore(pcpu, cpu); in __cpu_up()
889 * until new CPU has initialized control registers. in __cpu_up()
892 pcpu_prepare_secondary(pcpu, cpu); in __cpu_up()
895 /* Wait until cpu puts itself in the online & active maps */ in __cpu_up()
896 while (!cpu_online(cpu)) in __cpu_up()
914 int cpu; in __cpu_disable() local
918 cpu = smp_processor_id(); in __cpu_disable()
919 set_cpu_online(cpu, false); in __cpu_disable()
920 cpumask_clear_cpu(cpu, &cpu_setup_mask); in __cpu_disable()
922 /* Disable pseudo page faults on this cpu. */ in __cpu_disable()
934 void __cpu_die(unsigned int cpu) in __cpu_die() argument
938 /* Wait until target cpu is down */ in __cpu_die()
939 pcpu = pcpu_devices + cpu; in __cpu_die()
943 cpumask_clear_cpu(cpu, mm_cpumask(&init_mm)); in __cpu_die()
944 cpumask_clear_cpu(cpu, &init_mm.context.cpu_attach_mask); in __cpu_die()
956 unsigned int possible, sclp_max, cpu; in smp_fill_possible_mask() local
963 for (cpu = 0; cpu < possible && cpu < nr_cpu_ids; cpu++) in smp_fill_possible_mask()
964 set_cpu_possible(cpu, true); in smp_fill_possible_mask()
1022 int cpu, val, rc, i; in cpu_configure_store() local
1033 cpu = dev->id; in cpu_configure_store()
1034 cpu = smp_get_base_cpu(cpu); in cpu_configure_store()
1036 if (cpu_online(cpu + i)) in cpu_configure_store()
1038 pcpu = pcpu_devices + cpu; in cpu_configure_store()
1048 if (cpu + i >= nr_cpu_ids || !cpu_present(cpu + i)) in cpu_configure_store()
1051 smp_cpu_set_polarization(cpu + i, in cpu_configure_store()
1063 if (cpu + i >= nr_cpu_ids || !cpu_present(cpu + i)) in cpu_configure_store()
1066 smp_cpu_set_polarization(cpu + i, in cpu_configure_store()
1108 static int smp_cpu_online(unsigned int cpu) in smp_cpu_online() argument
1110 struct device *s = &per_cpu(cpu_device, cpu)->dev; in smp_cpu_online()
1115 static int smp_cpu_pre_down(unsigned int cpu) in smp_cpu_pre_down() argument
1117 struct device *s = &per_cpu(cpu_device, cpu)->dev; in smp_cpu_pre_down()
1123 static int smp_add_present_cpu(int cpu) in smp_add_present_cpu() argument
1126 struct cpu *c; in smp_add_present_cpu()
1132 per_cpu(cpu_device, cpu) = c; in smp_add_present_cpu()
1134 c->hotpluggable = !!cpu; in smp_add_present_cpu()
1135 rc = register_cpu(c, cpu); in smp_add_present_cpu()
1189 int cpu, rc = 0; in s390_smp_init() local
1199 for_each_present_cpu(cpu) { in s390_smp_init()
1200 rc = smp_add_present_cpu(cpu); in s390_smp_init()