From d74f123045bf3657f65c477b0bd874cb0215b439 Mon Sep 17 00:00:00 2001 From: WHR Date: Tue, 14 Mar 2023 21:25:25 +0800 Subject: [PATCH] Refactor CONFIG_SPE check on Linux/powerpc Commit 5401472 adds a check to call enable_kernel_spe and disable_kernel_spe only if CONFIG_SPE is defined. Refactor this check in a way similar to what CONFIG_ALTIVEC and CONFIG_VSX are checked, in order to remove redundant kfpu_begin() and kfpu_end() implementations. Reviewed-by: Tino Reichardt Reviewed-by: Brian Behlendorf Signed-off-by: WHR Closes #14623 --- include/os/linux/kernel/linux/simd_powerpc.h | 50 ++++++++------------ 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/include/os/linux/kernel/linux/simd_powerpc.h b/include/os/linux/kernel/linux/simd_powerpc.h index b9ff69ac88..a649790ce5 100644 --- a/include/os/linux/kernel/linux/simd_powerpc.h +++ b/include/os/linux/kernel/linux/simd_powerpc.h @@ -80,40 +80,32 @@ #define ENABLE_KERNEL_VSX #define DISABLE_KERNEL_VSX #endif -#ifdef CONFIG_SPE -#define kfpu_begin() \ - { \ - preempt_disable(); \ - ENABLE_KERNEL_ALTIVEC \ - ENABLE_KERNEL_VSX \ - enable_kernel_spe(); \ - } -#define kfpu_end() \ - { \ - disable_kernel_spe(); \ - DISABLE_KERNEL_VSX \ - DISABLE_KERNEL_ALTIVEC \ - preempt_enable(); \ - } -#else /* CONFIG_SPE */ -#define kfpu_begin() \ - { \ - preempt_disable(); \ - ENABLE_KERNEL_ALTIVEC \ - ENABLE_KERNEL_VSX \ - } -#define kfpu_end() \ - { \ - DISABLE_KERNEL_VSX \ - DISABLE_KERNEL_ALTIVEC \ - preempt_enable(); \ - } +#ifdef CONFIG_SPE +#define ENABLE_KERNEL_SPE enable_kernel_spe(); +#define DISABLE_KERNEL_SPE disable_kernel_spe(); +#else +#define ENABLE_KERNEL_SPE +#define DISABLE_KERNEL_SPE #endif +#define kfpu_begin() \ + { \ + preempt_disable(); \ + ENABLE_KERNEL_ALTIVEC \ + ENABLE_KERNEL_VSX \ + ENABLE_KERNEL_SPE \ + } +#define kfpu_end() \ + { \ + DISABLE_KERNEL_SPE \ + DISABLE_KERNEL_VSX \ + DISABLE_KERNEL_ALTIVEC \ + preempt_enable(); \ + } #else /* seems that before 4.5 no-one bothered */ #define kfpu_begin() #define kfpu_end() preempt_enable() -#endif +#endif /* Linux version >= 4.5 */ #define kfpu_init() 0 #define kfpu_fini() ((void) 0)