linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] powerpc/64: Set default CPU in Kconfig
@ 2022-12-07 13:38 Christophe Leroy
  2022-12-08 19:13 ` Pali Rohár
  2022-12-15 20:42 ` Pali Rohár
  0 siblings, 2 replies; 6+ messages in thread
From: Christophe Leroy @ 2022-12-07 13:38 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin
  Cc: Christophe Leroy, linux-kernel, linuxppc-dev, Pali Rohár

Since 0069f3d14e7a ("powerpc/64e: Tie PPC_BOOK3E_64 to PPC_E500MC"),
the only possible BOOK3E/64 are E500, so no need of a default CPU
over the E5500.
When the user selects book3e, he must have a e500 compatible compiler,
and it won't work anymore with the default -mcpu=power64, see
commit d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12
(unrecognized opcode: `wrteei')")

For book3s/64, replace GENERIC_CPU by POWERPC64_CPU to match the PPC32
POWERPC_CPU, and set a default mpcu value in Kconfig directly.

When a user selects a particular CPU, he must ensure his compiler has
the requested capability. Therefore, remove hidden fallback, instead
offer user the possibility to say he wants to use toolchain default.

Reported-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/Makefile                  | 22 +++++-----------------
 arch/powerpc/platforms/Kconfig.cputype | 12 +++++++-----
 2 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index dc4cbf0a5ca9..bf5f0a998273 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -146,19 +146,6 @@ CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option, $(MULTIPLEWORD))
 
 CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
 
-ifdef CONFIG_PPC_BOOK3S_64
-ifdef CONFIG_CPU_LITTLE_ENDIAN
-CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
-else
-CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
-endif
-CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power10,	\
-				  $(call cc-option,-mtune=power9,	\
-				  $(call cc-option,-mtune=power8)))
-else ifdef CONFIG_PPC_BOOK3E_64
-CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
-endif
-
 ifdef CONFIG_FUNCTION_TRACER
 CC_FLAGS_FTRACE := -pg
 ifdef CONFIG_MPROFILE_KERNEL
@@ -166,11 +153,12 @@ CC_FLAGS_FTRACE += -mprofile-kernel
 endif
 endif
 
-CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
-AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
+CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
+AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
 
-CFLAGS-$(CONFIG_E5500_CPU) += $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
-CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
+CFLAGS-$(CONFIG_POWERPC64_CPU) += $(call cc-option,-mtune=power10,	\
+				  $(call cc-option,-mtune=power9,	\
+				  $(call cc-option,-mtune=power8)))
 
 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
 
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 9563336e3348..31cea2eeb59e 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -118,19 +118,18 @@ endchoice
 
 choice
 	prompt "CPU selection"
-	default GENERIC_CPU
 	help
 	  This will create a kernel which is optimised for a particular CPU.
 	  The resulting kernel may not run on other CPUs, so use this with care.
 
 	  If unsure, select Generic.
 
-config GENERIC_CPU
+config POWERPC64_CPU
 	bool "Generic (POWER5 and PowerPC 970 and above)"
 	depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
 	select PPC_64S_HASH_MMU
 
-config GENERIC_CPU
+config POWERPC64_CPU
 	bool "Generic (POWER8 and above)"
 	depends on PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN
 	select ARCH_HAS_FAST_MULTIPLIER
@@ -233,13 +232,12 @@ config E500MC_CPU
 
 config TOOLCHAIN_DEFAULT_CPU
 	bool "Rely on the toolchain's implicit default CPU"
-	depends on PPC32
 
 endchoice
 
 config TARGET_CPU_BOOL
 	bool
-	default !GENERIC_CPU && !TOOLCHAIN_DEFAULT_CPU
+	default !TOOLCHAIN_DEFAULT_CPU
 
 config TARGET_CPU
 	string
@@ -251,6 +249,10 @@ config TARGET_CPU
 	default "power8" if POWER8_CPU
 	default "power9" if POWER9_CPU
 	default "power10" if POWER10_CPU
+	default "e500mc64" if E5500_CPU
+	default "e6500" if E6500_CPU
+	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
+	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
 	default "405" if 405_CPU
 	default "440" if 440_CPU
 	default "464" if 464_CPU
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] powerpc/64: Set default CPU in Kconfig
  2022-12-07 13:38 [PATCH v1] powerpc/64: Set default CPU in Kconfig Christophe Leroy
@ 2022-12-08 19:13 ` Pali Rohár
  2022-12-15 20:42 ` Pali Rohár
  1 sibling, 0 replies; 6+ messages in thread
From: Pali Rohár @ 2022-12-08 19:13 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Michael Ellerman, Nicholas Piggin, linux-kernel, linuxppc-dev

On Wednesday 07 December 2022 14:38:40 Christophe Leroy wrote:
> Since 0069f3d14e7a ("powerpc/64e: Tie PPC_BOOK3E_64 to PPC_E500MC"),
> the only possible BOOK3E/64 are E500, so no need of a default CPU
> over the E5500.
> When the user selects book3e, he must have a e500 compatible compiler,
> and it won't work anymore with the default -mcpu=power64, see
> commit d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12
> (unrecognized opcode: `wrteei')")
> 
> For book3s/64, replace GENERIC_CPU by POWERPC64_CPU to match the PPC32
> POWERPC_CPU, and set a default mpcu value in Kconfig directly.
> 
> When a user selects a particular CPU, he must ensure his compiler has
> the requested capability. Therefore, remove hidden fallback, instead
> offer user the possibility to say he wants to use toolchain default.
> 
> Reported-by: Pali Rohár <pali@kernel.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Tested-by: Pali Rohár <pali@kernel.org>

$ make ARCH=powerpc CROSS_COMPILE=powerpc64-linux-gnu- corenet64_smp_defconfig
...
# configuration written to .config

$ grep CONFIG_TARGET_CPU .config
CONFIG_TARGET_CPU_BOOL=y
CONFIG_TARGET_CPU="e500mc64"

Without this patch CONFIG_TARGET_CPU is not set but CONFIG_TARGET_CPU_BOOL is.

> ---
>  arch/powerpc/Makefile                  | 22 +++++-----------------
>  arch/powerpc/platforms/Kconfig.cputype | 12 +++++++-----
>  2 files changed, 12 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index dc4cbf0a5ca9..bf5f0a998273 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -146,19 +146,6 @@ CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option, $(MULTIPLEWORD))
>  
>  CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
>  
> -ifdef CONFIG_PPC_BOOK3S_64
> -ifdef CONFIG_CPU_LITTLE_ENDIAN
> -CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
> -else
> -CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
> -endif
> -CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power10,	\
> -				  $(call cc-option,-mtune=power9,	\
> -				  $(call cc-option,-mtune=power8)))
> -else ifdef CONFIG_PPC_BOOK3E_64
> -CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
> -endif
> -
>  ifdef CONFIG_FUNCTION_TRACER
>  CC_FLAGS_FTRACE := -pg
>  ifdef CONFIG_MPROFILE_KERNEL
> @@ -166,11 +153,12 @@ CC_FLAGS_FTRACE += -mprofile-kernel
>  endif
>  endif
>  
> -CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
> -AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
> +CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
> +AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
>  
> -CFLAGS-$(CONFIG_E5500_CPU) += $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
> -CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
> +CFLAGS-$(CONFIG_POWERPC64_CPU) += $(call cc-option,-mtune=power10,	\
> +				  $(call cc-option,-mtune=power9,	\
> +				  $(call cc-option,-mtune=power8)))
>  
>  asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
>  
> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
> index 9563336e3348..31cea2eeb59e 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -118,19 +118,18 @@ endchoice
>  
>  choice
>  	prompt "CPU selection"
> -	default GENERIC_CPU
>  	help
>  	  This will create a kernel which is optimised for a particular CPU.
>  	  The resulting kernel may not run on other CPUs, so use this with care.
>  
>  	  If unsure, select Generic.
>  
> -config GENERIC_CPU
> +config POWERPC64_CPU
>  	bool "Generic (POWER5 and PowerPC 970 and above)"
>  	depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
>  	select PPC_64S_HASH_MMU
>  
> -config GENERIC_CPU
> +config POWERPC64_CPU
>  	bool "Generic (POWER8 and above)"
>  	depends on PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN
>  	select ARCH_HAS_FAST_MULTIPLIER
> @@ -233,13 +232,12 @@ config E500MC_CPU
>  
>  config TOOLCHAIN_DEFAULT_CPU
>  	bool "Rely on the toolchain's implicit default CPU"
> -	depends on PPC32
>  
>  endchoice
>  
>  config TARGET_CPU_BOOL
>  	bool
> -	default !GENERIC_CPU && !TOOLCHAIN_DEFAULT_CPU
> +	default !TOOLCHAIN_DEFAULT_CPU
>  
>  config TARGET_CPU
>  	string
> @@ -251,6 +249,10 @@ config TARGET_CPU
>  	default "power8" if POWER8_CPU
>  	default "power9" if POWER9_CPU
>  	default "power10" if POWER10_CPU
> +	default "e500mc64" if E5500_CPU
> +	default "e6500" if E6500_CPU
> +	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
> +	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
>  	default "405" if 405_CPU
>  	default "440" if 440_CPU
>  	default "464" if 464_CPU
> -- 
> 2.38.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] powerpc/64: Set default CPU in Kconfig
  2022-12-07 13:38 [PATCH v1] powerpc/64: Set default CPU in Kconfig Christophe Leroy
  2022-12-08 19:13 ` Pali Rohár
@ 2022-12-15 20:42 ` Pali Rohár
  2022-12-16 19:15   ` Segher Boessenkool
  1 sibling, 1 reply; 6+ messages in thread
From: Pali Rohár @ 2022-12-15 20:42 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Michael Ellerman, Nicholas Piggin, linux-kernel, linuxppc-dev

Hello!

On Wednesday 07 December 2022 14:38:40 Christophe Leroy wrote:
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
...
> @@ -166,11 +153,12 @@ CC_FLAGS_FTRACE += -mprofile-kernel
>  endif
>  endif
>  
> -CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
> -AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
> +CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
> +AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
>  
> -CFLAGS-$(CONFIG_E5500_CPU) += $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
> -CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
> +CFLAGS-$(CONFIG_POWERPC64_CPU) += $(call cc-option,-mtune=power10,	\
> +				  $(call cc-option,-mtune=power9,	\
> +				  $(call cc-option,-mtune=power8)))
>  
>  asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
>  
> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
...
> @@ -251,6 +249,10 @@ config TARGET_CPU
>  	default "power8" if POWER8_CPU
>  	default "power9" if POWER9_CPU
>  	default "power10" if POWER10_CPU
> +	default "e500mc64" if E5500_CPU

Now I'm looking at this change again... and should not E5500_CPU rather
enforce -mcpu=e5500 flag? I know that your patch moves e500mc64 flag
from the Makefile to Kconfig, but maybe it could be changed in some
other followup patch...

Anyway, do you know what is e500mc64 core? I was trying to find some
information about it, but it looks like some unreleased freescale core
which predates e5500 core. ISA (without extensions like altivec) seems
to be same for e500mc64, e5500 and e6500 cores and difference is only
pipeline definitions in gcc config files. So if my understanding is
correct then kernel binary compiled with any of these -mcpu= flag should
work on any of those cores. Just for mismatches core binary will not be
optimized for speed.

> +	default "e6500" if E6500_CPU
> +	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
> +	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
>  	default "405" if 405_CPU
>  	default "440" if 440_CPU
>  	default "464" if 464_CPU
> -- 
> 2.38.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] powerpc/64: Set default CPU in Kconfig
  2022-12-15 20:42 ` Pali Rohár
@ 2022-12-16 19:15   ` Segher Boessenkool
  2022-12-16 22:23     ` Pali Rohár
  0 siblings, 1 reply; 6+ messages in thread
From: Segher Boessenkool @ 2022-12-16 19:15 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Christophe Leroy, linuxppc-dev, linux-kernel, Nicholas Piggin

Hi!

On Thu, Dec 15, 2022 at 09:42:02PM +0100, Pali Rohár wrote:
> On Wednesday 07 December 2022 14:38:40 Christophe Leroy wrote:
> >  	default "power8" if POWER8_CPU
> >  	default "power9" if POWER9_CPU
> >  	default "power10" if POWER10_CPU
> > +	default "e500mc64" if E5500_CPU
> 
> Now I'm looking at this change again... and should not E5500_CPU rather
> enforce -mcpu=e5500 flag? I know that your patch moves e500mc64 flag
> from the Makefile to Kconfig, but maybe it could be changed in some
> other followup patch...
> 
> Anyway, do you know what is e500mc64 core? I was trying to find some
> information about it, but it looks like some unreleased freescale core
> which predates e5500 core.

It looks that way yes.  It was submitted at
<https://gcc.gnu.org/pipermail/gcc-patches/2009-November/273251.html>
and committed as <https://gcc.gnu.org/g:b17f98b1c541>.  It looks as if
it was based on the e500mc core, while e5500 is a new core (or
significantly different anyway).

> ISA (without extensions like altivec) seems
> to be same for e500mc64, e5500 and e6500 cores and difference is only
> pipeline definitions in gcc config files. So if my understanding is
> correct then kernel binary compiled with any of these -mcpu= flag should
> work on any of those cores. Just for mismatches core binary will not be
> optimized for speed.

It appears the E500MC64 never made it outside of FSL, so it is best not
to use it at all, imo.


Segher

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] powerpc/64: Set default CPU in Kconfig
  2022-12-16 19:15   ` Segher Boessenkool
@ 2022-12-16 22:23     ` Pali Rohár
  2022-12-16 23:02       ` Segher Boessenkool
  0 siblings, 1 reply; 6+ messages in thread
From: Pali Rohár @ 2022-12-16 22:23 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Christophe Leroy, linuxppc-dev, linux-kernel, Nicholas Piggin

On Friday 16 December 2022 13:15:43 Segher Boessenkool wrote:
> > Anyway, do you know what is e500mc64 core? I was trying to find some
> > information about it, but it looks like some unreleased freescale core
> > which predates e5500 core.
> 
> It looks that way yes.  It was submitted at
> <https://gcc.gnu.org/pipermail/gcc-patches/2009-November/273251.html>
> and committed as <https://gcc.gnu.org/g:b17f98b1c541>.  It looks as if
> it was based on the e500mc core, while e5500 is a new core (or
> significantly different anyway).

Just a two old Freescale PDF files which I found and mention e500mc-64:
https://web.archive.org/web/20121215191707/http://www.freescale.com/files/ftf_2010/Americas/FTF10_ENT_F0453.pdf
https://web.archive.org/web/20120905164305/http://www.freescale.com/files/ftf_2010/Americas/FTF10_ENT_F0273.pdf

On page 6 in both documents is described P5020 with e500mc-64 cores. But
production version of P5020 contains e5500 cores.

Some other documents are also on nxp.com website:
https://www.google.com/search?q=%22e500mc-64%22+site%3Anxp.com

https://www.nxp.com/files-static/training/doc/MULTICORE_MORE.pdf
https://www.nxp.com/docs/en/supporting-information/WBNR_FTF10_NET_F0707.pdf
https://www.nxp.com/docs/en/supporting-information/WBNR_FTF10_NET_F0704.pdf

> > ISA (without extensions like altivec) seems
> > to be same for e500mc64, e5500 and e6500 cores and difference is only
> > pipeline definitions in gcc config files. So if my understanding is
> > correct then kernel binary compiled with any of these -mcpu= flag should
> > work on any of those cores. Just for mismatches core binary will not be
> > optimized for speed.
> 
> It appears the E500MC64 never made it outside of FSL, so it is best not
> to use it at all, imo.

Yes, it really makes sense to not use e500mc64 flag. Maybe gcc
documentation could be updated to mention this fact?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] powerpc/64: Set default CPU in Kconfig
  2022-12-16 22:23     ` Pali Rohár
@ 2022-12-16 23:02       ` Segher Boessenkool
  0 siblings, 0 replies; 6+ messages in thread
From: Segher Boessenkool @ 2022-12-16 23:02 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Christophe Leroy, linuxppc-dev, linux-kernel, Nicholas Piggin

On Fri, Dec 16, 2022 at 11:23:59PM +0100, Pali Rohár wrote:
> > It appears the E500MC64 never made it outside of FSL, so it is best not
> > to use it at all, imo.
> 
> Yes, it really makes sense to not use e500mc64 flag. Maybe gcc
> documentation could be updated to mention this fact?

Thanks.  I filed <https://gcc.gnu.org/PR108149> so that we don't forget
about this.


Segher

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-16 23:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07 13:38 [PATCH v1] powerpc/64: Set default CPU in Kconfig Christophe Leroy
2022-12-08 19:13 ` Pali Rohár
2022-12-15 20:42 ` Pali Rohár
2022-12-16 19:15   ` Segher Boessenkool
2022-12-16 22:23     ` Pali Rohár
2022-12-16 23:02       ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).