diff mbox series

[1/4] sparc32: Add support for specifying -mcpu

Message ID 20231229200726.GA4034411@ravnborg.org
State New
Headers show
Series sparc32: Use CAS for atomic support | expand

Commit Message

Sam Ravnborg Dec. 29, 2023, 8:07 p.m. UTC
Add support for selecting the CPU architecture.
The default is leon3 - which is the minimum required as the kernel uses
CAS instructions.

Inspired by (from gaisler-buildroot-2023.02-1.0):
    0001-sparc32-leon-Build-with-mcpu-leon3-for-SPARC_LEON.patch
    0028-sparc32-leon-Make-what-mcpu-to-be-used-configurable-.patch

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Arnd Bergmann <arnd@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
---
 arch/sparc/Kconfig  | 24 ++++++++++++++++++++++++
 arch/sparc/Makefile | 13 +++++--------
 2 files changed, 29 insertions(+), 8 deletions(-)

Comments

Andreas Larsson April 26, 2024, 4:52 p.m. UTC | #1
On 2023-12-29 21:07, Sam Ravnborg wrote:
> Add support for selecting the CPU architecture.
> The default is leon3 - which is the minimum required as the kernel uses
> CAS instructions.
> 
> Inspired by (from gaisler-buildroot-2023.02-1.0):
>     0001-sparc32-leon-Build-with-mcpu-leon3-for-SPARC_LEON.patch
>     0028-sparc32-leon-Make-what-mcpu-to-be-used-configurable-.patch
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Andreas Larsson <andreas@gaisler.com>
> Cc: Arnd Bergmann <arnd@kernel.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> ---
>  arch/sparc/Kconfig  | 24 ++++++++++++++++++++++++
>  arch/sparc/Makefile | 13 +++++--------
>  2 files changed, 29 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
> index 1b9cf7f3c500..e94783ceb409 100644
> --- a/arch/sparc/Kconfig
> +++ b/arch/sparc/Kconfig
> @@ -161,6 +161,30 @@ config ARCH_SUPPORTS_UPROBES
>  
>  menu "Processor type and features"
>  
> +choice
> +	prompt "LEON architecture"
> +	default SPARC_CPU_LEON3
> +	help
> +	  Select the architecture the kernel shall be built for
> +
> +config SPARC_CPU_LEON3
> +	prompt "LEON 3"

This should rather be bool than prompt...

> +	help
> +	  Build the kernel for the LEON 3 architecture
> +
> +config SPARC_CPU_LEON5
> +	prompt "LEON 5"

...and the same here.

> +	help
> +	  Build the kernel for the LEON 5 architecture
> +
> +config SPARC_CPU_DEFAULT
> +	bool "Toolchain default"
> +	help
> +	  Build the kernel with no -mcpu option, getting the default
> +	  for the toolchain that is being used.
> +
> +endchoice
> +
>  config SMP
>  	bool "Symmetric multi-processing support"
>  	help
> diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
> index 5f6035936131..3c3a1fd8c873 100644
> --- a/arch/sparc/Makefile
> +++ b/arch/sparc/Makefile
> @@ -25,14 +25,11 @@ KBUILD_LDFLAGS := -m elf32_sparc
>  export BITS    := 32
>  UTS_MACHINE    := sparc
>  
> -# We are adding -Wa,-Av8 to KBUILD_CFLAGS to deal with a specs bug in some
> -# versions of gcc.  Some gcc versions won't pass -Av8 to binutils when you
> -# give -mcpu=v8.  This silently worked with older bintutils versions but
> -# does not any more.
> -KBUILD_CFLAGS  += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
> -KBUILD_CFLAGS  += -Wa,-Av8
> -
> -KBUILD_AFLAGS  += -m32 -Wa,-Av8
> +cpuflags-$(CONFIG_SPARC_CPU_LEON3)	:= -mcpu=leon3
> +cpuflags-$(CONFIG_SPARC_CPU_LEON5)	:= -mcpu=leon5
> +
> +KBUILD_CFLAGS  += -m32 $(cpuflags-y) -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
> +KBUILD_AFLAGS  += -m32 $(cpuflags-y)
>  
>  else
>  #####

As said in the sunset thread, more vetting is needed from my side, so no
need to respin this series yet.

Thanks,
Andreas
diff mbox series

Patch

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 1b9cf7f3c500..e94783ceb409 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -161,6 +161,30 @@  config ARCH_SUPPORTS_UPROBES
 
 menu "Processor type and features"
 
+choice
+	prompt "LEON architecture"
+	default SPARC_CPU_LEON3
+	help
+	  Select the architecture the kernel shall be built for
+
+config SPARC_CPU_LEON3
+	prompt "LEON 3"
+	help
+	  Build the kernel for the LEON 3 architecture
+
+config SPARC_CPU_LEON5
+	prompt "LEON 5"
+	help
+	  Build the kernel for the LEON 5 architecture
+
+config SPARC_CPU_DEFAULT
+	bool "Toolchain default"
+	help
+	  Build the kernel with no -mcpu option, getting the default
+	  for the toolchain that is being used.
+
+endchoice
+
 config SMP
 	bool "Symmetric multi-processing support"
 	help
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index 5f6035936131..3c3a1fd8c873 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -25,14 +25,11 @@  KBUILD_LDFLAGS := -m elf32_sparc
 export BITS    := 32
 UTS_MACHINE    := sparc
 
-# We are adding -Wa,-Av8 to KBUILD_CFLAGS to deal with a specs bug in some
-# versions of gcc.  Some gcc versions won't pass -Av8 to binutils when you
-# give -mcpu=v8.  This silently worked with older bintutils versions but
-# does not any more.
-KBUILD_CFLAGS  += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
-KBUILD_CFLAGS  += -Wa,-Av8
-
-KBUILD_AFLAGS  += -m32 -Wa,-Av8
+cpuflags-$(CONFIG_SPARC_CPU_LEON3)	:= -mcpu=leon3
+cpuflags-$(CONFIG_SPARC_CPU_LEON5)	:= -mcpu=leon5
+
+KBUILD_CFLAGS  += -m32 $(cpuflags-y) -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
+KBUILD_AFLAGS  += -m32 $(cpuflags-y)
 
 else
 #####