Skip to contentSkip to conversation

powerpc: add enable_kernel_fp() stub for ALTIVEC without PPC_FPU

PATCH In review Randy Dunlap 3 participants 5 messages Apr 18, 2021 – Apr 19, 2021 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 powerpc: add enable_kernel_fp() stub for ALTIVEC without PPC_FPU

On a kernel config with ALTIVEC=y and PPC_FPU not set/enabled, there is a build error:

drivers/cpufreq/pmac32-cpufreq.c:262:2: error: implicit declaration of function 'enable_kernel_fp' [-Werror,-Wimplicit-function-declaration]

           enable_kernel_fp();

so add a stub function for that when PPC_FPU is not set.

---
 arch/powerpc/include/asm/switch_to.h |    1 +
 1 file changed, 1 insertion(+)
arch/powerpc/include/asm/switch_to.h +1 -0
@@ -48,6 +48,7 @@ static inline void disable_kernel_fp(voi
 #else
 static inline void save_fpu(struct task_struct *t) { }
 static inline void flush_fp_to_thread(struct task_struct *t) { }
+static inline void enable_kernel_fp(void) { }
 #endif
 
 #ifdef CONFIG_ALTIVEC
#1 lore raw

PATCH 2/2 powerpc: add ALTIVEC support to lib/ when PPC_FPU not set

When PPC_FPU is not set and ALTIVEC=y, arch/powerpc/lib/ldstfp.c is not being built, but it is also needed when ALTIVEC=y for get_vr() and put_vr().

../arch/powerpc/lib/sstep.c: In function 'do_vec_load':
../arch/powerpc/lib/sstep.c:637:3: error: implicit declaration of function 'put_vr' [-Werror=implicit-function-declaration]

  637 |   put_vr(rn, &u.v);
      |   ^~~~~~
../arch/powerpc/lib/sstep.c: In function 'do_vec_store':
../arch/powerpc/lib/sstep.c:660:3: error: implicit declaration of function 'get_vr'; did you mean 'get_oc'? [-Werror=implicit-function-declaration]
  660 |   get_vr(rn, &u.v);
      |   ^~~~~~

Add ldstfp.o to the Makefile for CONFIG_ALTIVEC and add externs for get_vr() and put_vr() in lib/sstep.c to fix the build errors.

This was seen in a kernel config from kernel test robot <[email protected]> that reported a different build issue (for pmac32-cpufreq.c).

Cc Michael Ellerman <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Segher Boessenkool <[email protected]>
---
 arch/powerpc/lib/Makefile |    1 +
 arch/powerpc/lib/sstep.c  |    5 +++++
 2 files changed, 6 insertions(+)
arch/powerpc/lib/Makefile +1 -0
@@ -54,6 +54,7 @@ obj-y			+= checksum_$(BITS).o checksum_w
 
 obj-y			+= sstep.o
 obj-$(CONFIG_PPC_FPU)	+= ldstfp.o
+obj-$(CONFIG_ALTIVEC)	+= ldstfp.o
 obj64-y			+= quad.o
 
 obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
arch/powerpc/lib/sstep.c +5 -0
@@ -50,6 +50,11 @@ extern void conv_sp_to_dp(const float *s
 extern void conv_dp_to_sp(const double *dp, float *sp);
 #endif
 
+#ifdef CONFIG_ALTIVEC
+extern void get_vr(int rn, __vector128 *p);
+extern void put_vr(int rn, __vector128 *p);
+#endif /* CONFIG_ALTIVEC */
+
 #ifdef __powerpc64__
 /*
  * Functions in quad.S
#2 lore raw

Re: [PATCH 2/2] powerpc: add ALTIVEC support to lib/ when PPC_FPU not set

Hi!

Quoted 6 lines · Randy Dunlap

Add ldstfp.o to the Makefile for CONFIG_ALTIVEC and add externs for get_vr() and put_vr() in lib/sstep.c to fix the build errors.

obj-$(CONFIG_PPC_FPU) += ldstfp.o
+obj-$(CONFIG_ALTIVEC) += ldstfp.o

It is probably a good idea to split ldstfp.S into two, one for each of the two configuration options?

Segher

#3 lore raw

Re: [PATCH 2/2] powerpc: add ALTIVEC support to lib/ when PPC_FPU not set

Le 19/04/2021 à 15:32, Segher Boessenkool a écrit :

Quoted 7 lines

Hi!

Quoted 3 lines · Randy Dunlap

Add ldstfp.o to the Makefile for CONFIG_ALTIVEC and add externs for get_vr() and put_vr() in lib/sstep.c to fix the build errors.

Quoted 6 lines
Quoted 2 lines

obj-$(CONFIG_PPC_FPU) += ldstfp.o
+obj-$(CONFIG_ALTIVEC) += ldstfp.o

It is probably a good idea to split ldstfp.S into two, one for each of the two configuration options?

Or we can build it all the time and #ifdef the FPU part.

Because it contains FPU, ALTIVEC and VSX stuff.

Christophe

#4 lore raw

Re: [PATCH 2/2] powerpc: add ALTIVEC support to lib/ when PPC_FPU not set

Quoted 9 lines · Christophe Leroy

Le 19/04/2021 à 15:32, Segher Boessenkool a écrit :

Quoted 8 lines · Randy Dunlap
Quoted 6 lines

Add ldstfp.o to the Makefile for CONFIG_ALTIVEC and add externs for get_vr() and put_vr() in lib/sstep.c to fix the build errors.

obj-$(CONFIG_PPC_FPU) += ldstfp.o
+obj-$(CONFIG_ALTIVEC) += ldstfp.o

Quoted 7 lines
Quoted 3 lines

It is probably a good idea to split ldstfp.S into two, one for each of the two configuration options?

Or we can build it all the time and #ifdef the FPU part.

Because it contains FPU, ALTIVEC and VSX stuff.

So it becomes an empty object file if none of the options are selected? Good idea :-)

Segher