Path: blob/master/arch/powerpc/include/asm/cputhreads.h
26481 views
/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_POWERPC_CPUTHREADS_H2#define _ASM_POWERPC_CPUTHREADS_H34#ifndef __ASSEMBLY__5#include <linux/cpumask.h>6#include <asm/cpu_has_feature.h>78/*9* Mapping of threads to cores10*11* Note: This implementation is limited to a power of 2 number of12* threads per core and the same number for each core in the system13* (though it would work if some processors had less threads as long14* as the CPU numbers are still allocated, just not brought online).15*16* However, the API allows for a different implementation in the future17* if needed, as long as you only use the functions and not the variables18* directly.19*/2021#ifdef CONFIG_SMP22extern int threads_per_core;23extern int threads_per_subcore;24extern int threads_shift;25extern cpumask_t threads_core_mask;26#else27#define threads_per_core 128#define threads_per_subcore 129#define threads_shift 030#define has_big_cores 031#define threads_core_mask (*get_cpu_mask(0))32#endif3334static inline int cpu_nr_cores(void)35{36return nr_cpu_ids >> threads_shift;37}3839#ifdef CONFIG_SMP40int cpu_core_index_of_thread(int cpu);41int cpu_first_thread_of_core(int core);42#else43static inline int cpu_core_index_of_thread(int cpu) { return cpu; }44static inline int cpu_first_thread_of_core(int core) { return core; }45#endif4647static inline int cpu_thread_in_core(int cpu)48{49return cpu & (threads_per_core - 1);50}5152static inline int cpu_thread_in_subcore(int cpu)53{54return cpu & (threads_per_subcore - 1);55}5657static inline int cpu_first_thread_sibling(int cpu)58{59return cpu & ~(threads_per_core - 1);60}6162static inline int cpu_last_thread_sibling(int cpu)63{64return cpu | (threads_per_core - 1);65}6667/*68* tlb_thread_siblings are siblings which share a TLB. This is not69* architected, is not something a hypervisor could emulate and a future70* CPU may change behaviour even in compat mode, so this should only be71* used on PowerNV, and only with care.72*/73static inline int cpu_first_tlb_thread_sibling(int cpu)74{75if (cpu_has_feature(CPU_FTR_ARCH_300) && (threads_per_core == 8))76return cpu & ~0x6; /* Big Core */77else78return cpu_first_thread_sibling(cpu);79}8081static inline int cpu_last_tlb_thread_sibling(int cpu)82{83if (cpu_has_feature(CPU_FTR_ARCH_300) && (threads_per_core == 8))84return cpu | 0x6; /* Big Core */85else86return cpu_last_thread_sibling(cpu);87}8889static inline int cpu_tlb_thread_sibling_step(void)90{91if (cpu_has_feature(CPU_FTR_ARCH_300) && (threads_per_core == 8))92return 2; /* Big Core */93else94return 1;95}9697static inline u32 get_tensr(void)98{99#ifdef CONFIG_BOOKE100if (cpu_has_feature(CPU_FTR_SMT))101return mfspr(SPRN_TENSR);102#endif103return 1;104}105106void book3e_start_thread(int thread, unsigned long addr);107void book3e_stop_thread(int thread);108109#endif /* __ASSEMBLY__ */110111#define INVALID_THREAD_HWID 0x0fff112113#endif /* _ASM_POWERPC_CPUTHREADS_H */114115116117