|
8 | 8 |
|
9 | 9 | #include <linux/bitmap.h>
|
10 | 10 | #include <linux/jump_label.h>
|
| 11 | +#include <linux/kconfig.h> |
| 12 | +#include <linux/percpu-defs.h> |
| 13 | +#include <linux/threads.h> |
11 | 14 | #include <asm/hwcap.h>
|
12 |
| -#include <asm/alternative-macros.h> |
13 |
| -#include <asm/errno.h> |
| 15 | +#include <asm/cpufeature-macros.h> |
14 | 16 |
|
15 | 17 | /*
|
16 | 18 | * These are probed via a device_initcall(), via either the SBI or directly
|
@@ -103,61 +105,6 @@ extern const size_t riscv_isa_ext_count;
|
103 | 105 | extern bool riscv_isa_fallback;
|
104 | 106 |
|
105 | 107 | unsigned long riscv_isa_extension_base(const unsigned long *isa_bitmap);
|
106 |
| - |
107 |
| -#define STANDARD_EXT 0 |
108 |
| - |
109 |
| -bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, unsigned int bit); |
110 |
| -#define riscv_isa_extension_available(isa_bitmap, ext) \ |
111 |
| - __riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_##ext) |
112 |
| - |
113 |
| -static __always_inline bool __riscv_has_extension_likely(const unsigned long vendor, |
114 |
| - const unsigned long ext) |
115 |
| -{ |
116 |
| - asm goto(ALTERNATIVE("j %l[l_no]", "nop", %[vendor], %[ext], 1) |
117 |
| - : |
118 |
| - : [vendor] "i" (vendor), [ext] "i" (ext) |
119 |
| - : |
120 |
| - : l_no); |
121 |
| - |
122 |
| - return true; |
123 |
| -l_no: |
124 |
| - return false; |
125 |
| -} |
126 |
| - |
127 |
| -static __always_inline bool __riscv_has_extension_unlikely(const unsigned long vendor, |
128 |
| - const unsigned long ext) |
129 |
| -{ |
130 |
| - asm goto(ALTERNATIVE("nop", "j %l[l_yes]", %[vendor], %[ext], 1) |
131 |
| - : |
132 |
| - : [vendor] "i" (vendor), [ext] "i" (ext) |
133 |
| - : |
134 |
| - : l_yes); |
135 |
| - |
136 |
| - return false; |
137 |
| -l_yes: |
138 |
| - return true; |
139 |
| -} |
140 |
| - |
141 |
| -static __always_inline bool riscv_has_extension_unlikely(const unsigned long ext) |
142 |
| -{ |
143 |
| - compiletime_assert(ext < RISCV_ISA_EXT_MAX, "ext must be < RISCV_ISA_EXT_MAX"); |
144 |
| - |
145 |
| - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) |
146 |
| - return __riscv_has_extension_unlikely(STANDARD_EXT, ext); |
147 |
| - |
148 |
| - return __riscv_isa_extension_available(NULL, ext); |
149 |
| -} |
150 |
| - |
151 |
| -static __always_inline bool riscv_has_extension_likely(const unsigned long ext) |
152 |
| -{ |
153 |
| - compiletime_assert(ext < RISCV_ISA_EXT_MAX, "ext must be < RISCV_ISA_EXT_MAX"); |
154 |
| - |
155 |
| - if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE)) |
156 |
| - return __riscv_has_extension_likely(STANDARD_EXT, ext); |
157 |
| - |
158 |
| - return __riscv_isa_extension_available(NULL, ext); |
159 |
| -} |
160 |
| - |
161 | 108 | static __always_inline bool riscv_cpu_has_extension_likely(int cpu, const unsigned long ext)
|
162 | 109 | {
|
163 | 110 | compiletime_assert(ext < RISCV_ISA_EXT_MAX, "ext must be < RISCV_ISA_EXT_MAX");
|
|
0 commit comments