Skip to content

Commit 01db473

Browse files
SiFiveHollandakpm00
authored andcommitted
powerpc: implement ARCH_HAS_KERNEL_FPU_SUPPORT
PowerPC provides an equivalent to the common kernel-mode FPU API, but in a different header and using different function names. The PowerPC API also requires a non-preemptible context. Add a wrapper header, and export the CFLAGS adjustments. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Samuel Holland <[email protected]> Acked-by: Michael Ellerman <[email protected]> (powerpc) Reviewed-by: Christoph Hellwig <[email protected]> Acked-by: Christian König <[email protected]> Cc: Alex Deucher <[email protected]> Cc: Borislav Petkov (AMD) <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nicolas Schier <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Russell King <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: WANG Xuerui <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 372f662 commit 01db473

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ config PPC
137137
select ARCH_HAS_GCOV_PROFILE_ALL
138138
select ARCH_HAS_HUGEPD if HUGETLB_PAGE
139139
select ARCH_HAS_KCOV
140+
select ARCH_HAS_KERNEL_FPU_SUPPORT if PPC_FPU
140141
select ARCH_HAS_MEMBARRIER_CALLBACKS
141142
select ARCH_HAS_MEMBARRIER_SYNC_CORE
142143
select ARCH_HAS_MEMREMAP_COMPAT_ALIGN if PPC_64S_HASH_MMU

arch/powerpc/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD))
149149

150150
CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
151151

152+
CC_FLAGS_FPU := $(call cc-option,-mhard-float)
153+
CC_FLAGS_NO_FPU := $(call cc-option,-msoft-float)
154+
152155
ifdef CONFIG_FUNCTION_TRACER
153156
ifdef CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY
154157
KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
@@ -170,7 +173,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
170173

171174
KBUILD_CPPFLAGS += -I $(srctree)/arch/powerpc $(asinstr)
172175
KBUILD_AFLAGS += $(AFLAGS-y)
173-
KBUILD_CFLAGS += $(call cc-option,-msoft-float)
176+
KBUILD_CFLAGS += $(CC_FLAGS_NO_FPU)
174177
KBUILD_CFLAGS += $(CFLAGS-y)
175178
CPP = $(CC) -E $(KBUILD_CFLAGS)
176179

arch/powerpc/include/asm/fpu.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (C) 2023 SiFive
4+
*/
5+
6+
#ifndef _ASM_POWERPC_FPU_H
7+
#define _ASM_POWERPC_FPU_H
8+
9+
#include <linux/preempt.h>
10+
11+
#include <asm/cpu_has_feature.h>
12+
#include <asm/switch_to.h>
13+
14+
#define kernel_fpu_available() (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE))
15+
16+
static inline void kernel_fpu_begin(void)
17+
{
18+
preempt_disable();
19+
enable_kernel_fp();
20+
}
21+
22+
static inline void kernel_fpu_end(void)
23+
{
24+
disable_kernel_fp();
25+
preempt_enable();
26+
}
27+
28+
#endif /* ! _ASM_POWERPC_FPU_H */

0 commit comments

Comments
 (0)