at commit c03c1a14
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright IBM Corp. 1999, 2012 |
| 4 | * Author(s): Denis Joseph Barrow, |
| 5 | * Martin Schwidefsky <schwidefsky@de.ibm.com>, |
| 6 | */ |
| 7 | #ifndef __ASM_SMP_H |
| 8 | #define __ASM_SMP_H |
| 9 | |
| 10 | #include <asm/processor.h> |
| 11 | #include <asm/lowcore.h> |
| 12 | #include <asm/machine.h> |
| 13 | #include <asm/sigp.h> |
| 14 | |
| 15 | static __always_inline unsigned int raw_smp_processor_id(void) |
| 16 | { |
| 17 | unsigned long lc_cpu_nr; |
| 18 | unsigned int cpu; |
| 19 | |
| 20 | BUILD_BUG_ON(sizeof_field(struct lowcore, cpu_nr) != sizeof(cpu)); |
| 21 | lc_cpu_nr = offsetof(struct lowcore, cpu_nr); |
| 22 | asm_inline( |
| 23 | ALTERNATIVE(" ly %[cpu],%[offzero](%%r0)\n", |
| 24 | " ly %[cpu],%[offalt](%%r0)\n", |
| 25 | ALT_FEATURE(MFEATURE_LOWCORE)) |
| 26 | : [cpu] "=d" (cpu) |
| 27 | : [offzero] "i" (lc_cpu_nr), |
| 28 | [offalt] "i" (lc_cpu_nr + LOWCORE_ALT_ADDRESS), |
| 29 | "m" (((struct lowcore *)0)->cpu_nr)); |
| 30 | return cpu; |
| 31 | } |
| 32 | |
| 33 | #define arch_scale_cpu_capacity topology_get_cpu_scale |
| 34 | |
| 35 | extern struct mutex smp_cpu_state_mutex; |
| 36 | extern unsigned int smp_cpu_mt_shift; |
| 37 | extern unsigned int smp_cpu_mtid; |
| 38 | extern __vector128 __initdata boot_cpu_vector_save_area[__NUM_VXRS]; |
| 39 | extern cpumask_t cpu_setup_mask; |
| 40 | |
| 41 | extern int __cpu_up(unsigned int cpu, struct task_struct *tidle); |
| 42 | |
| 43 | extern void arch_send_call_function_single_ipi(int cpu); |
| 44 | extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); |
| 45 | |
| 46 | extern void __noreturn smp_call_ipl_cpu(void (*func)(void *), void *data); |
| 47 | extern void smp_emergency_stop(void); |
| 48 | |
| 49 | extern int smp_find_processor_id(u16 address); |
| 50 | extern int smp_store_status(int cpu); |
| 51 | extern void smp_save_dump_ipl_cpu(void); |
| 52 | extern void smp_save_dump_secondary_cpus(void); |
| 53 | extern void smp_yield_cpu(int cpu); |
| 54 | extern void smp_cpu_set_polarization(int cpu, int val); |
| 55 | extern int smp_cpu_get_polarization(int cpu); |
| 56 | extern void smp_set_core_capacity(int cpu, unsigned long val); |
| 57 | extern int smp_cpu_get_cpu_address(int cpu); |
| 58 | extern void smp_fill_possible_mask(void); |
| 59 | extern void smp_detect_cpus(void); |
| 60 | |
| 61 | static inline void smp_stop_cpu(void) |
| 62 | { |
| 63 | u16 pcpu = stap(); |
| 64 | |
| 65 | for (;;) { |
| 66 | __pcpu_sigp(pcpu, SIGP_STOP, 0, NULL); |
| 67 | cpu_relax(); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /* Return thread 0 CPU number as base CPU */ |
| 72 | static inline int smp_get_base_cpu(int cpu) |
| 73 | { |
| 74 | return cpu - (cpu % (smp_cpu_mtid + 1)); |
| 75 | } |
| 76 | |
| 77 | static inline void smp_cpus_done(unsigned int max_cpus) |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | extern int smp_rescan_cpus(bool early); |
| 82 | extern void __noreturn cpu_die(void); |
| 83 | extern void __cpu_die(unsigned int cpu); |
| 84 | extern int __cpu_disable(void); |
| 85 | extern void schedule_mcck_handler(void); |
| 86 | void notrace smp_yield_cpu(int cpu); |
| 87 | |
| 88 | #endif /* __ASM_SMP_H */ |