linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: tegra: remove board_init_funcs array
@ 2016-06-22 12:39 Arnd Bergmann
  2016-06-22 12:50 ` Thierry Reding
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2016-06-22 12:39 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Arnd Bergmann, Thierry Reding, Alexandre Courbot,
	linux-arm-kernel, linux-tegra, linux-kernel

In a configuration that enables CONFIG_UBSAN_SANITIZE_ALL, I am getting
a section mismatch warning for tegra20:

WARNING: arch/arm/mach-tegra/built-in.o(.data+0x6e0): Section mismatch in reference from the variable board_init_funcs to the function .init.text:paz00_init()

The array is no longer useful here since there is only one entry,
so we can simply call the function directly after checking
of_machine_is_compatible(). This fixes the section mismatch
and is easier to read.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm/mach-tegra/tegra.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index 2378fa560a21..42d7ee9658fa 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -118,32 +118,14 @@ out:
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, parent);
 }
 
-static void __init paz00_init(void)
-{
-	if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC))
-		tegra_paz00_wifikill_init();
-}
-
-static struct {
-	char *machine;
-	void (*init)(void);
-} board_init_funcs[] = {
-	{ "compal,paz00", paz00_init },
-};
-
 static void __init tegra_dt_init_late(void)
 {
-	int i;
-
 	tegra_init_suspend();
 	tegra_cpuidle_init();
 
-	for (i = 0; i < ARRAY_SIZE(board_init_funcs); i++) {
-		if (of_machine_is_compatible(board_init_funcs[i].machine)) {
-			board_init_funcs[i].init();
-			break;
-		}
-	}
+	if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
+	    of_machine_is_compatible("compal,paz00"))
+		tegra_paz00_wifikill_init();
 }
 
 static const char * const tegra_dt_board_compat[] = {
-- 
2.9.0

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

* Re: [PATCH] ARM: tegra: remove board_init_funcs array
  2016-06-22 12:39 [PATCH] ARM: tegra: remove board_init_funcs array Arnd Bergmann
@ 2016-06-22 12:50 ` Thierry Reding
  2016-06-22 13:05   ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Thierry Reding @ 2016-06-22 12:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Stephen Warren, Alexandre Courbot, linux-arm-kernel, linux-tegra,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

On Wed, Jun 22, 2016 at 02:39:41PM +0200, Arnd Bergmann wrote:
> In a configuration that enables CONFIG_UBSAN_SANITIZE_ALL, I am getting
> a section mismatch warning for tegra20:
> 
> WARNING: arch/arm/mach-tegra/built-in.o(.data+0x6e0): Section mismatch in reference from the variable board_init_funcs to the function .init.text:paz00_init()
> 
> The array is no longer useful here since there is only one entry,
> so we can simply call the function directly after checking
> of_machine_is_compatible(). This fixes the section mismatch
> and is easier to read.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/arm/mach-tegra/tegra.c | 24 +++---------------------
>  1 file changed, 3 insertions(+), 21 deletions(-)

Shouldn't these section mismatches show up with default builds? I
haven't seen any when building Tegra configurations.

I'm going to apply this patch because I think it's useful, but it sure
would be nice to know why I need to enable this new UBSAN stuff to get
these warnings now.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] ARM: tegra: remove board_init_funcs array
  2016-06-22 12:50 ` Thierry Reding
@ 2016-06-22 13:05   ` Arnd Bergmann
  2016-06-22 13:34     ` Thierry Reding
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2016-06-22 13:05 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Thierry Reding, linux-tegra, Alexandre Courbot, linux-kernel,
	Stephen Warren

On Wednesday, June 22, 2016 2:50:13 PM CEST Thierry Reding wrote:
> 
> Not enough information to check signature validity.
> On Wed, Jun 22, 2016 at 02:39:41PM +0200, Arnd Bergmann wrote:
> > In a configuration that enables CONFIG_UBSAN_SANITIZE_ALL, I am getting
> > a section mismatch warning for tegra20:
> > 
> > WARNING: arch/arm/mach-tegra/built-in.o(.data+0x6e0): Section mismatch in reference from the variable board_init_funcs to the function .init.text:paz00_init()
> > 
> > The array is no longer useful here since there is only one entry,
> > so we can simply call the function directly after checking
> > of_machine_is_compatible(). This fixes the section mismatch
> > and is easier to read.
> > 
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  arch/arm/mach-tegra/tegra.c | 24 +++---------------------
> >  1 file changed, 3 insertions(+), 21 deletions(-)
> 
> Shouldn't these section mismatches show up with default builds? I
> haven't seen any when building Tegra configurations.
> 
> I'm going to apply this patch because I think it's useful, but it sure
> would be nice to know why I need to enable this new UBSAN stuff to get
> these warnings now.

It depends on the how aggressive the inlining works. Without UBSAN,
gcc seems to completely optimze away the loop and just the function
directly, which it can do because 'board_init_funcs' is static.

I assume that the UBSAN object overflow check has the effect of
not dropping the symbol so it can check the size.

	Arnd

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

* Re: [PATCH] ARM: tegra: remove board_init_funcs array
  2016-06-22 13:05   ` Arnd Bergmann
@ 2016-06-22 13:34     ` Thierry Reding
  0 siblings, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2016-06-22 13:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, linux-tegra, Alexandre Courbot, linux-kernel,
	Stephen Warren

[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]

On Wed, Jun 22, 2016 at 03:05:35PM +0200, Arnd Bergmann wrote:
> On Wednesday, June 22, 2016 2:50:13 PM CEST Thierry Reding wrote:
> > 
> > Not enough information to check signature validity.
> > On Wed, Jun 22, 2016 at 02:39:41PM +0200, Arnd Bergmann wrote:
> > > In a configuration that enables CONFIG_UBSAN_SANITIZE_ALL, I am getting
> > > a section mismatch warning for tegra20:
> > > 
> > > WARNING: arch/arm/mach-tegra/built-in.o(.data+0x6e0): Section mismatch in reference from the variable board_init_funcs to the function .init.text:paz00_init()
> > > 
> > > The array is no longer useful here since there is only one entry,
> > > so we can simply call the function directly after checking
> > > of_machine_is_compatible(). This fixes the section mismatch
> > > and is easier to read.
> > > 
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > > ---
> > >  arch/arm/mach-tegra/tegra.c | 24 +++---------------------
> > >  1 file changed, 3 insertions(+), 21 deletions(-)
> > 
> > Shouldn't these section mismatches show up with default builds? I
> > haven't seen any when building Tegra configurations.
> > 
> > I'm going to apply this patch because I think it's useful, but it sure
> > would be nice to know why I need to enable this new UBSAN stuff to get
> > these warnings now.
> 
> It depends on the how aggressive the inlining works. Without UBSAN,
> gcc seems to completely optimze away the loop and just the function
> directly, which it can do because 'board_init_funcs' is static.
> 
> I assume that the UBSAN object overflow check has the effect of
> not dropping the symbol so it can check the size.

Ah, I see. Thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2016-06-22 13:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22 12:39 [PATCH] ARM: tegra: remove board_init_funcs array Arnd Bergmann
2016-06-22 12:50 ` Thierry Reding
2016-06-22 13:05   ` Arnd Bergmann
2016-06-22 13:34     ` Thierry Reding

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