Skip to contentSkip to conversation

ARM: imx: bootaux: Fix macro misuse

PATCH In review Marek Vasut 3 participants 6 messages Dec 13, 2022 – Jan 31, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ARM: imx: bootaux: Fix macro misuse

There are no CONFIG_{TOOLS_,SPL_,TPL_,}IMX8M macros, nor is there one for ARM64. Use plain IS_ENABLED(CONFIG_IMX8M) and IS_ENABLED(CONFIG_ARM64) to avoid expanding the {TOOLS_,SPL_,TPL_,} part.

Fixes 56c2dbdabab5 ("imx: bootaux: cleanup code")

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Stefano Babic <[email protected]>

---
 arch/arm/mach-imx/imx_bootaux.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-imx/imx_bootaux.c +4 -4
index 8115bf40f1a..433c1f80cee 100644
@@ -15,7 +15,7 @@
 #include <cpu_func.h>
 
 /* Just to avoid build error */
-#if CONFIG_IS_ENABLED(IMX8M)
+#if IS_ENABLED(CONFIG_IMX8M)
 #define SRC_M4C_NON_SCLR_RST_MASK	BIT(0)
 #define SRC_M4_ENABLE_MASK		BIT(0)
 #define SRC_M4_REG_OFFSET		0
@@ -106,7 +106,7 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr)
 		if (!pc)
 			return CMD_RET_FAILURE;
 
-		if (!CONFIG_IS_ENABLED(ARM64))
+		if (!IS_ENABLED(CONFIG_ARM64))
 			stack = 0x0;
 	} else {
 		/*
@@ -128,7 +128,7 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr)
 	flush_dcache_all();
 
 	/* Enable M4 */
-	if (CONFIG_IS_ENABLED(IMX8M)) {
+	if (IS_ENABLED(CONFIG_IMX8M)) {
 		arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M4_START, 0, 0, 0, 0, 0, 0, NULL);
 	} else {
 		clrsetbits_le32(SRC_BASE_ADDR + SRC_M4_REG_OFFSET,
@@ -143,7 +143,7 @@ int arch_auxiliary_core_check_up(u32 core_id)
 	struct arm_smccc_res res;
 	unsigned int val;
 
-	if (CONFIG_IS_ENABLED(IMX8M)) {
+	if (IS_ENABLED(CONFIG_IMX8M)) {
 		arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M4_STARTED, 0, 0, 0, 0, 0, 0, &res);
 		return res.a0;
 	}
Signature · 1 line
2.35.1
#1 lore raw

PATCH 2/2 ARM: imx: bootaux: Fix LTO -Wlto-type-mismatch

Commit 56c2dbdabab5 ("imx: bootaux: cleanup code") introduces the following LTO related warning:

"
arch/arm/mach-imx/imx_bootaux.c:24:31: warning: type of ‘hostmap’ does not match original declaration [-Wlto-type-mismatch]
24 | const __weak struct rproc_att hostmap[] = { };
| ^
arch/arm/mach-imx/imx8m/soc.c:1590:24: note: array types have different bounds
1590 | const struct rproc_att hostmap[] = {
| ^
arch/arm/mach-imx/imx8m/soc.c:1590:24: note: ‘hostmap’ was previously declared here ../aarch64-linux-gnu/bin/ld: warning: u-boot has a LOAD segment with RWX permissions
"

This is because the weak empty array of structures "hostmap" is eventually replaced by non-empty array of structures with different number of elements. Fix this by avoiding weak variable size array, instead use a weak function which returns single pointer to the array.

Fixes 56c2dbdabab5 ("imx: bootaux: cleanup code")

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Stefano Babic <[email protected]>

---
 arch/arm/include/asm/mach-imx/sys_proto.h | 2 ++
 arch/arm/mach-imx/imx8m/soc.c             | 5 +++++
 arch/arm/mach-imx/imx_bootaux.c           | 7 +++++--
 arch/arm/mach-imx/mx7/soc.c               | 5 +++++
 4 files changed, 17 insertions(+), 2 deletions(-)
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
index dd0d3f29333..27fdc16cd50 100644
@@ -149,6 +149,8 @@ struct rproc_att {
 	u32 size; /* size of reg range */
 };
 
+const struct rproc_att *imx_bootaux_get_hostmap(void);
+
 struct rom_api {
 	u16 ver;
 	u16 tag;
arch/arm/mach-imx/imx8m/soc.c +5 -0
index a4863281e36..5e92f8143cf 100644
@@ -1610,4 +1610,9 @@ const struct rproc_att hostmap[] = {
 	{ 0x40000000, 0x40000000, 0x80000000 },
 	{ /* sentinel */ }
 };
+
+const struct rproc_att *imx_bootaux_get_hostmap(void)
+{
+	return hostmap;
+}
 #endif
arch/arm/mach-imx/imx_bootaux.c +5 -2
index 433c1f80cee..888c53d6901 100644
@@ -21,11 +21,14 @@
 #define SRC_M4_REG_OFFSET		0
 #endif
 
-const __weak struct rproc_att hostmap[] = { };
+__weak const struct rproc_att *imx_bootaux_get_hostmap(void)
+{
+	return NULL;
+}
 
 static const struct rproc_att *get_host_mapping(unsigned long auxcore)
 {
-	const struct rproc_att *mmap = hostmap;
+	const struct rproc_att *mmap = imx_bootaux_get_hostmap();
 
 	while (mmap && mmap->size) {
 		if (mmap->da <= auxcore &&
arch/arm/mach-imx/mx7/soc.c +5 -0
index 02af0d568f2..689dbefe8ee 100644
@@ -224,6 +224,11 @@ const struct rproc_att hostmap[] = {
 	{ 0x80000000, 0x80000000, 0x60000000 }, /* DDRC */
 	{ /* sentinel */ }
 };
+
+const struct rproc_att *imx_bootaux_get_hostmap(void)
+{
+	return hostmap;
+}
 #endif
 
 #if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
Signature · 1 line
2.35.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] ARM: imx: bootaux: Fix LTO -Wlto-type-mismatch

Quoted 88 lines · Marek Vasut

Commit 56c2dbdabab5 ("imx: bootaux: cleanup code") introduces the following LTO related warning:

"
arch/arm/mach-imx/imx_bootaux.c:24:31: warning: type of ‘hostmap’ does not match original declaration [-Wlto-type-mismatch]

    24 | const __weak struct rproc_att hostmap[] = { };
       |                               ^

arch/arm/mach-imx/imx8m/soc.c:1590:24: note: array types have different bounds
1590 | const struct rproc_att hostmap[] = {
| ^
arch/arm/mach-imx/imx8m/soc.c:1590:24: note: ‘hostmap’ was previously declared here ../aarch64-linux-gnu/bin/ld: warning: u-boot has a LOAD segment with RWX permissions "

This is because the weak empty array of structures "hostmap" is eventually replaced by non-empty array of structures with different number of elements. Fix this by avoiding weak variable size array, instead use a weak function which returns single pointer to the array.

Fixes 56c2dbdabab5 ("imx: bootaux: cleanup code")

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Stefano Babic <[email protected]>

---
  arch/arm/include/asm/mach-imx/sys_proto.h | 2 ++
  arch/arm/mach-imx/imx8m/soc.c             | 5 +++++
  arch/arm/mach-imx/imx_bootaux.c           | 7 +++++--
  arch/arm/mach-imx/mx7/soc.c               | 5 +++++
  4 files changed, 17 insertions(+), 2 deletions(-)
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
index dd0d3f29333..27fdc16cd50 100644
@@ -149,6 +149,8 @@ struct rproc_att {
  	u32 size; /* size of reg range */
  };
 
+const struct rproc_att *imx_bootaux_get_hostmap(void);
+
  struct rom_api {
  	u16 ver;
  	u16 tag;
arch/arm/mach-imx/imx8m/soc.c +5 -0
index a4863281e36..5e92f8143cf 100644
@@ -1610,4 +1610,9 @@ const struct rproc_att hostmap[] = {
  	{ 0x40000000, 0x40000000, 0x80000000 },
  	{ /* sentinel */ }
  };
+
+const struct rproc_att *imx_bootaux_get_hostmap(void)
+{
+	return hostmap;
+}
  #endif
arch/arm/mach-imx/imx_bootaux.c +5 -2
index 433c1f80cee..888c53d6901 100644
@@ -21,11 +21,14 @@
  #define SRC_M4_REG_OFFSET		0
  #endif
 
-const __weak struct rproc_att hostmap[] = { };
+__weak const struct rproc_att *imx_bootaux_get_hostmap(void)
+{
+	return NULL;
+}
 
  static const struct rproc_att *get_host_mapping(unsigned long auxcore)
  {
-	const struct rproc_att *mmap = hostmap;
+	const struct rproc_att *mmap = imx_bootaux_get_hostmap();
 
  	while (mmap && mmap->size) {
  		if (mmap->da <= auxcore &&
arch/arm/mach-imx/mx7/soc.c +0 -0
index 02af0d568f2..689dbefe8ee 100644
@@ -224,6 +224,11 @@ const struct rproc_att hostmap[] = {
  	{ 0x80000000, 0x80000000, 0x60000000 }, /* DDRC */

arch/arm/mach-imx/mx7/soc.c const struct rproc_att hostmap[] = { · line 234

Quoted 10 lines
arch/arm/mach-imx/mx7/soc.c +5 -0
  	{ /* sentinel */ }
  };
+
+const struct rproc_att *imx_bootaux_get_hostmap(void)
+{
+	return hostmap;
+}
  #endif
 
  #if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
#3 lore raw

PATCH 2/2 ARM: imx: bootaux: Fix LTO -Wlto-type-mismatch

In reply to Marek Vasut
Quoted 16 lines

Commit 56c2dbdabab5 ("imx: bootaux: cleanup code") introduces the
following LTO related warning:
"
arch/arm/mach-imx/imx_bootaux.c:24:31: warning: type of ‘hostmap’ does not match original declaration [-Wlto-type-mismatch]
24 | const __weak struct rproc_att hostmap[] = { };
| ^
arch/arm/mach-imx/imx8m/soc.c:1590:24: note: array types have different bounds
1590 | const struct rproc_att hostmap[] = {
| ^
arch/arm/mach-imx/imx8m/soc.c:1590:24: note: ‘hostmap’ was previously declared here ../aarch64-linux-gnu/bin/ld: warning: u-boot has a LOAD segment with RWX permissions
"
This is because the weak empty array of structures "hostmap" is eventually
replaced by non-empty array of structures with different number of elements.
Fix this by avoiding weak variable size array, instead use a weak function
which returns single pointer to the array.

Quoted 3 lines
Fixes 56c2dbdabab5 ("imx: bootaux: cleanup code")

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================
Reviewed-by on v1 1/2
#4 lore raw
In reply to Marek Vasut
Quoted 48 lines · Marek Vasut

There are no CONFIG_{TOOLS_,SPL_,TPL_,}IMX8M macros, nor is there one for ARM64. Use plain IS_ENABLED(CONFIG_IMX8M) and IS_ENABLED(CONFIG_ARM64) to avoid expanding the {TOOLS_,SPL_,TPL_,} part.

Fixes 56c2dbdabab5 ("imx: bootaux: cleanup code")

---
Cc: "NXP i.MX U-Boot Team" <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Stefano Babic <[email protected]>

---
  arch/arm/mach-imx/imx_bootaux.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-imx/imx_bootaux.c +3 -3
index 8115bf40f1a..433c1f80cee 100644
@@ -15,7 +15,7 @@
  #include <cpu_func.h>
 
  /* Just to avoid build error */
-#if CONFIG_IS_ENABLED(IMX8M)
+#if IS_ENABLED(CONFIG_IMX8M)
  #define SRC_M4C_NON_SCLR_RST_MASK	BIT(0)
  #define SRC_M4_ENABLE_MASK		BIT(0)
  #define SRC_M4_REG_OFFSET		0
@@ -106,7 +106,7 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr)
  		if (!pc)
  			return CMD_RET_FAILURE;
 
-		if (!CONFIG_IS_ENABLED(ARM64))
+		if (!IS_ENABLED(CONFIG_ARM64))
  			stack = 0x0;
  	} else {
  		/*
@@ -128,7 +128,7 @@ int arch_auxiliary_core_up(u32 core_id, ulong addr)
  	flush_dcache_all();
 
  	/* Enable M4 */
-	if (CONFIG_IS_ENABLED(IMX8M)) {
+	if (IS_ENABLED(CONFIG_IMX8M)) {
  		arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M4_START, 0, 0, 0, 0, 0, 0, NULL);
  	} else {
  		clrsetbits_le32(SRC_BASE_ADDR + SRC_M4_REG_OFFSET,

arch/arm/mach-imx/imx_bootaux.c int arch_auxiliary_core_check_up(u32 core_id) · line 149

Quoted 8 lines
arch/arm/mach-imx/imx_bootaux.c +1 -1
@@ -143,7 +143,7 @@ int arch_auxiliary_core_check_up(u32 core_id)
  	struct arm_smccc_res res;
  	unsigned int val;
 
-	if (CONFIG_IS_ENABLED(IMX8M)) {
+	if (IS_ENABLED(CONFIG_IMX8M)) {
  		arm_smccc_smc(IMX_SIP_SRC, IMX_SIP_SRC_M4_STARTED, 0, 0, 0, 0, 0, 0, &res);
  		return res.a0;
  	}
#5 lore raw

PATCH 1/2 ARM: imx: bootaux: Fix macro misuse

In reply to Marek Vasut
Quoted 6 lines

There are no CONFIG_{TOOLS_,SPL_,TPL_,}IMX8M macros, nor is there one for ARM64. Use plain IS_ENABLED(CONFIG_IMX8M) and IS_ENABLED(CONFIG_ARM64) to avoid expanding the {TOOLS_,SPL_,TPL_,} part.

Fixes 56c2dbdabab5 ("imx: bootaux: cleanup code")

Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [email protected]
=====================================================================