linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig
@ 2021-03-12 15:14 Masahiro Yamada
  2021-03-13  8:57 ` Max Filippov
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2021-03-12 15:14 UTC (permalink / raw)
  To: Chris Zankel, Max Filippov, linux-xtensa; +Cc: Masahiro Yamada, linux-kernel

Move the definition of CONFIG_CPU_*_ENDIAN to Kconfig, the best place
for CONFIG options.

I slightly simplified the test code. You can use the -P option to suppress
linemarker generation. The grep command is unneeded.

  $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -
  # 1 "<stdin>"
  # 1 "<built-in>"
  # 1 "<command-line>"
  # 1 "<stdin>"
  1

  $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -P -
  1

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

If I understood correctly, xtensa compilers can support either
big-endian or little-endian. We cannot change it via a command option.
Actually, it does not understand -mbig-endian or -mlittle-endian.
(Is this correct?)

  $ xtensa-linux-gcc   -mbig-endian  /dev/null  -c -o /dev/null
  xtensa-linux-gcc: error: unrecognized command-line option '-mbig-endian'

I see -mbig-endian / -mlittle-endian in old GCC manual.
  https://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Xtensa-Options.html
But, I cannot see them in recent gcc manuals.
So, I have no idea better than checking __XTENSA_EB__ or __XTENSA_EL__.
I just moved the logic to Kconfig from Makefile.


 arch/xtensa/Kconfig  | 6 ++++++
 arch/xtensa/Makefile | 9 +--------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 9ad6b7b82707..37b04ccc0a7f 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -84,6 +84,12 @@ config KASAN_SHADOW_OFFSET
 	hex
 	default 0x6e400000
 
+config CPU_BIG_ENDIAN
+	def_bool $(success,test "$(shell,echo __XTENSA_EB__ | $(CC) -E -P -)" = 1)
+
+config CPU_LITTLE_ENDIAN
+	def_bool !CPU_BIG_ENDIAN
+
 menu "Processor type and features"
 
 choice
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
index cf0940708702..f43c731dec89 100644
--- a/arch/xtensa/Makefile
+++ b/arch/xtensa/Makefile
@@ -52,14 +52,7 @@ ifneq ($(CONFIG_LD_NO_RELAX),)
 KBUILD_LDFLAGS := --no-relax
 endif
 
-ifeq ($(shell echo __XTENSA_EB__ | $(CC) -E - | grep -v "\#"),1)
-CHECKFLAGS += -D__XTENSA_EB__
-KBUILD_CPPFLAGS += -DCONFIG_CPU_BIG_ENDIAN
-endif
-ifeq ($(shell echo __XTENSA_EL__ | $(CC) -E - | grep -v "\#"),1)
-CHECKFLAGS += -D__XTENSA_EL__
-KBUILD_CPPFLAGS += -DCONFIG_CPU_LITTLE_ENDIAN
-endif
+CHECKFLAGS += -D $(if $(CONFIG_CPU_BIG_ENDIAN),__XTENSA_EB__,__XTENSA_EL__)
 
 vardirs := $(patsubst %,arch/xtensa/variants/%/,$(variant-y))
 plfdirs := $(patsubst %,arch/xtensa/platforms/%/,$(platform-y))
-- 
2.27.0


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

* Re: [PATCH] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig
  2021-03-12 15:14 [PATCH] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Masahiro Yamada
@ 2021-03-13  8:57 ` Max Filippov
  2021-03-13 12:03   ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Max Filippov @ 2021-03-13  8:57 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Chris Zankel, open list:TENSILICA XTENSA PORT (xtensa), LKML

On Fri, Mar 12, 2021 at 7:14 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Move the definition of CONFIG_CPU_*_ENDIAN to Kconfig, the best place
> for CONFIG options.
>
> I slightly simplified the test code. You can use the -P option to suppress
> linemarker generation. The grep command is unneeded.
>
>   $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -
>   # 1 "<stdin>"
>   # 1 "<built-in>"
>   # 1 "<command-line>"
>   # 1 "<stdin>"
>   1
>
>   $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -P -
>   1
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---

> If I understood correctly, xtensa compilers can support either
> big-endian or little-endian. We cannot change it via a command option.
> Actually, it does not understand -mbig-endian or -mlittle-endian.
> (Is this correct?)

This is correct. The idea is that specific xtensa core has fixed endianness,
but it can be either little or big. The toolchain is configured for the specific
xtensa core at build time, so there's no need for a runtime endian switch.

>   $ xtensa-linux-gcc   -mbig-endian  /dev/null  -c -o /dev/null
>   xtensa-linux-gcc: error: unrecognized command-line option '-mbig-endian'
>
> I see -mbig-endian / -mlittle-endian in old GCC manual.
>   https://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Xtensa-Options.html
> But, I cannot see them in recent gcc manuals.
> So, I have no idea better than checking __XTENSA_EB__ or __XTENSA_EL__.
> I just moved the logic to Kconfig from Makefile.
>
>
>  arch/xtensa/Kconfig  | 6 ++++++
>  arch/xtensa/Makefile | 9 +--------
>  2 files changed, 7 insertions(+), 8 deletions(-)

Acked-by: Max Filippov <jcmvbkbc@gmail.com>
Please let me know if I should take it into the xtensa tree or you will
carry it in the kbuild tree.

-- 
Thanks.
-- Max

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

* Re: [PATCH] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig
  2021-03-13  8:57 ` Max Filippov
@ 2021-03-13 12:03   ` Masahiro Yamada
  2021-03-13 12:10     ` Masahiro Yamada
  0 siblings, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2021-03-13 12:03 UTC (permalink / raw)
  To: Max Filippov; +Cc: Chris Zankel, open list:TENSILICA XTENSA PORT (xtensa), LKML

On Sat, Mar 13, 2021 at 5:57 PM Max Filippov <jcmvbkbc@gmail.com> wrote:
>
> On Fri, Mar 12, 2021 at 7:14 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Move the definition of CONFIG_CPU_*_ENDIAN to Kconfig, the best place
> > for CONFIG options.
> >
> > I slightly simplified the test code. You can use the -P option to suppress
> > linemarker generation. The grep command is unneeded.
> >
> >   $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -
> >   # 1 "<stdin>"
> >   # 1 "<built-in>"
> >   # 1 "<command-line>"
> >   # 1 "<stdin>"
> >   1
> >
> >   $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -P -
> >   1
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
>
> > If I understood correctly, xtensa compilers can support either
> > big-endian or little-endian. We cannot change it via a command option.
> > Actually, it does not understand -mbig-endian or -mlittle-endian.
> > (Is this correct?)
>
> This is correct. The idea is that specific xtensa core has fixed endianness,
> but it can be either little or big. The toolchain is configured for the specific
> xtensa core at build time, so there's no need for a runtime endian switch.
>
> >   $ xtensa-linux-gcc   -mbig-endian  /dev/null  -c -o /dev/null
> >   xtensa-linux-gcc: error: unrecognized command-line option '-mbig-endian'
> >
> > I see -mbig-endian / -mlittle-endian in old GCC manual.
> >   https://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Xtensa-Options.html
> > But, I cannot see them in recent gcc manuals.
> > So, I have no idea better than checking __XTENSA_EB__ or __XTENSA_EL__.
> > I just moved the logic to Kconfig from Makefile.
> >
> >
> >  arch/xtensa/Kconfig  | 6 ++++++
> >  arch/xtensa/Makefile | 9 +--------
> >  2 files changed, 7 insertions(+), 8 deletions(-)
>
> Acked-by: Max Filippov <jcmvbkbc@gmail.com>
> Please let me know if I should take it into the xtensa tree or you will
> carry it in the kbuild tree.


Please apply it to the xtensa tree.


I also submitted 3 patches to clean up xtensa syscall table generation.

https://lore.kernel.org/patchwork/project/lkml/list/?series=487007

They should go to the xtensa tree as well.



-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig
  2021-03-13 12:03   ` Masahiro Yamada
@ 2021-03-13 12:10     ` Masahiro Yamada
  0 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2021-03-13 12:10 UTC (permalink / raw)
  To: Max Filippov; +Cc: Chris Zankel, open list:TENSILICA XTENSA PORT (xtensa), LKML

On Sat, Mar 13, 2021 at 9:03 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Sat, Mar 13, 2021 at 5:57 PM Max Filippov <jcmvbkbc@gmail.com> wrote:
> >
> > On Fri, Mar 12, 2021 at 7:14 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > Move the definition of CONFIG_CPU_*_ENDIAN to Kconfig, the best place
> > > for CONFIG options.
> > >
> > > I slightly simplified the test code. You can use the -P option to suppress
> > > linemarker generation. The grep command is unneeded.
> > >
> > >   $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -
> > >   # 1 "<stdin>"
> > >   # 1 "<built-in>"
> > >   # 1 "<command-line>"
> > >   # 1 "<stdin>"
> > >   1
> > >
> > >   $ echo __XTENSA_EB__ | xtensa-linux-gcc -E -P -
> > >   1
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > ---
> >
> > > If I understood correctly, xtensa compilers can support either
> > > big-endian or little-endian. We cannot change it via a command option.
> > > Actually, it does not understand -mbig-endian or -mlittle-endian.
> > > (Is this correct?)
> >
> > This is correct. The idea is that specific xtensa core has fixed endianness,
> > but it can be either little or big. The toolchain is configured for the specific
> > xtensa core at build time, so there's no need for a runtime endian switch.
> >
> > >   $ xtensa-linux-gcc   -mbig-endian  /dev/null  -c -o /dev/null
> > >   xtensa-linux-gcc: error: unrecognized command-line option '-mbig-endian'
> > >
> > > I see -mbig-endian / -mlittle-endian in old GCC manual.
> > >   https://gcc.gnu.org/onlinedocs/gcc-3.3.5/gcc/Xtensa-Options.html
> > > But, I cannot see them in recent gcc manuals.
> > > So, I have no idea better than checking __XTENSA_EB__ or __XTENSA_EL__.
> > > I just moved the logic to Kconfig from Makefile.
> > >
> > >
> > >  arch/xtensa/Kconfig  | 6 ++++++
> > >  arch/xtensa/Makefile | 9 +--------
> > >  2 files changed, 7 insertions(+), 8 deletions(-)
> >
> > Acked-by: Max Filippov <jcmvbkbc@gmail.com>
> > Please let me know if I should take it into the xtensa tree or you will
> > carry it in the kbuild tree.
>
>
> Please apply it to the xtensa tree.
>

Ah, wait.

I think I can do a little more cleanups.

arch/xtensa/boot/Makefile:BIG_ENDIAN        := $(shell echo
__XTENSA_EB__ | $(CC) -E - | grep -v "\#")


Will send v2.

-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2021-03-13 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12 15:14 [PATCH] xtensa: move CONFIG_CPU_*_ENDIAN defines to Kconfig Masahiro Yamada
2021-03-13  8:57 ` Max Filippov
2021-03-13 12:03   ` Masahiro Yamada
2021-03-13 12:10     ` Masahiro Yamada

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).