diff options
author | Alan Kao <alankao@andestech.com> | 2018-10-09 04:18:34 +0200 |
---|---|---|
committer | Palmer Dabbelt <palmer@sifive.com> | 2018-10-23 02:02:23 +0200 |
commit | 9411ec60c23d868124d9c1b1d491937aebe07afa (patch) | |
tree | b099a760ac5b284dd79281ded728e35ec30d2e77 /arch/riscv/kernel/cpufeature.c | |
parent | Allow to disable FPU support (diff) | |
download | linux-9411ec60c23d868124d9c1b1d491937aebe07afa.tar.xz linux-9411ec60c23d868124d9c1b1d491937aebe07afa.zip |
Auto-detect whether a FPU exists
We expect that a kernel with CONFIG_FPU=y can still support no-FPU
machines. To do so, the kernel should first examine the existence of a
FPU, then do nothing if a FPU does exist; otherwise, it should
disable/bypass all FPU-related functions.
In this patch, a new global variable, has_fpu, is created and determined
when parsing the hardware capability from device tree during booting.
This variable is used in those FPU-related functions.
Signed-off-by: Alan Kao <alankao@andestech.com>
Cc: Greentime Hu <greentime@andestech.com>
Cc: Vincent Chen <vincentc@andestech.com>
Cc: Zong Li <zong@andestech.com>
Cc: Nick Hu <nickhu@andestech.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Diffstat (limited to 'arch/riscv/kernel/cpufeature.c')
-rw-r--r-- | arch/riscv/kernel/cpufeature.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 17011a870044..46942e635266 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -22,6 +22,9 @@ #include <asm/hwcap.h> unsigned long elf_hwcap __read_mostly; +#ifdef CONFIG_FPU +bool has_fpu __read_mostly; +#endif void riscv_fill_hwcap(void) { @@ -58,4 +61,9 @@ void riscv_fill_hwcap(void) elf_hwcap |= isa2hwcap[(unsigned char)(isa[i])]; pr_info("elf_hwcap is 0x%lx", elf_hwcap); + +#ifdef CONFIG_FPU + if (elf_hwcap & (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D)) + has_fpu = true; +#endif } |