Skip to content

Commit 5d0fbbb

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: switch has_fpu() to the unified static key mechanism
This is to use the unified static key mechanism instead of putting static key related here and there. Signed-off-by: Jisheng Zhang <[email protected]> Reviewed-by: Atish Patra <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent c360cbe commit 5d0fbbb

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

arch/riscv/include/asm/switch_to.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/jump_label.h>
1010
#include <linux/sched/task_stack.h>
11+
#include <asm/hwcap.h>
1112
#include <asm/processor.h>
1213
#include <asm/ptrace.h>
1314
#include <asm/csr.h>
@@ -56,10 +57,9 @@ static inline void __switch_to_aux(struct task_struct *prev,
5657
fstate_restore(next, task_pt_regs(next));
5758
}
5859

59-
extern struct static_key_false cpu_hwcap_fpu;
6060
static __always_inline bool has_fpu(void)
6161
{
62-
return static_branch_likely(&cpu_hwcap_fpu);
62+
return static_branch_likely(&riscv_isa_ext_keys[RISCV_ISA_EXT_KEY_FPU]);
6363
}
6464
#else
6565
static __always_inline bool has_fpu(void) { return false; }

arch/riscv/kernel/cpufeature.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ unsigned long elf_hwcap __read_mostly;
2727
/* Host ISA bitmap */
2828
static DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX) __read_mostly;
2929

30-
#ifdef CONFIG_FPU
31-
__ro_after_init DEFINE_STATIC_KEY_FALSE(cpu_hwcap_fpu);
32-
#endif
3330
__ro_after_init DEFINE_STATIC_KEY_ARRAY_FALSE(riscv_isa_ext_keys, RISCV_ISA_EXT_KEY_MAX);
3431
EXPORT_SYMBOL(riscv_isa_ext_keys);
3532

@@ -245,10 +242,6 @@ void __init riscv_fill_hwcap(void)
245242
if (j >= 0)
246243
static_branch_enable(&riscv_isa_ext_keys[j]);
247244
}
248-
#ifdef CONFIG_FPU
249-
if (elf_hwcap & (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D))
250-
static_branch_enable(&cpu_hwcap_fpu);
251-
#endif
252245
}
253246

254247
#ifdef CONFIG_RISCV_ALTERNATIVE

0 commit comments

Comments
 (0)