Kevin Hao | b92a226 | 2016-07-23 14:42:40 +0530 | [diff] [blame] | 1 | #ifndef __ASM_POWERPC_CPUFEATURES_H |
| 2 | #define __ASM_POWERPC_CPUFEATURES_H |
| 3 | |
| 4 | #ifndef __ASSEMBLY__ |
| 5 | |
| 6 | #include <asm/cputable.h> |
| 7 | |
| 8 | static inline bool early_cpu_has_feature(unsigned long feature) |
| 9 | { |
| 10 | return !!((CPU_FTRS_ALWAYS & feature) || |
| 11 | (CPU_FTRS_POSSIBLE & cur_cpu_spec->cpu_features & feature)); |
| 12 | } |
| 13 | |
Kevin Hao | 4db7327 | 2016-07-23 14:42:41 +0530 | [diff] [blame^] | 14 | #ifdef CONFIG_JUMP_LABEL_FEATURE_CHECKS |
| 15 | #include <linux/jump_label.h> |
| 16 | |
| 17 | #define NUM_CPU_FTR_KEYS 64 |
| 18 | |
| 19 | extern struct static_key_true cpu_feature_keys[NUM_CPU_FTR_KEYS]; |
| 20 | |
| 21 | static __always_inline bool cpu_has_feature(unsigned long feature) |
| 22 | { |
| 23 | int i; |
| 24 | |
| 25 | BUILD_BUG_ON(!__builtin_constant_p(feature)); |
| 26 | |
| 27 | if (CPU_FTRS_ALWAYS & feature) |
| 28 | return true; |
| 29 | |
| 30 | if (!(CPU_FTRS_POSSIBLE & feature)) |
| 31 | return false; |
| 32 | |
| 33 | i = __builtin_ctzl(feature); |
| 34 | return static_branch_likely(&cpu_feature_keys[i]); |
| 35 | } |
| 36 | #else |
Kevin Hao | b92a226 | 2016-07-23 14:42:40 +0530 | [diff] [blame] | 37 | static inline bool cpu_has_feature(unsigned long feature) |
| 38 | { |
| 39 | return early_cpu_has_feature(feature); |
| 40 | } |
Kevin Hao | 4db7327 | 2016-07-23 14:42:41 +0530 | [diff] [blame^] | 41 | #endif |
Kevin Hao | b92a226 | 2016-07-23 14:42:40 +0530 | [diff] [blame] | 42 | |
| 43 | #endif /* __ASSEMBLY__ */ |
| 44 | #endif /* __ASM_POWERPC_CPUFEATURE_H */ |