mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically
@ 2023-04-04 10:17 Ahmad Fatoum
  2023-04-04 10:17 ` [PATCH v2 2/2] treewide: remove no-longer needed IMD_USED_OF Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2023-04-04 10:17 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We currently require IMD_OF_USED to get the DT compatible into the
barebox image data meta section. As the PBL is already referencing the
DT to pass it along to barebox proper, let's add a reference from the DT
to the image data section to make IMD_OF_USED unnecessary.

Suggested-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
--
v1 -> v2:
  - use dword, to fix build for 64-bit (Sascha)
  - place IMD reference before STRUCT_ALIGNMENT
---
 scripts/gen-dtb-s | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index c5c46a4d8675..6309a814a483 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -49,6 +49,9 @@ echo "__dtb_${name}_start:"
 echo ".incbin \"$dtb\""
 echo "__dtb_${name}_end:"
 echo ".global __dtb_${name}_end"
+if [ "$imd" = "y" ]; then
+	echo ".dword __barebox_imd_OF_${name}"
+fi
 echo ".balign STRUCT_ALIGNMENT"
 
 compressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb.z)
@@ -65,5 +68,8 @@ printf ".int 0x%08x\n"  $uncompressed
 echo ".incbin \"$dtb.z\""
 echo "__dtb_z_${name}_end:"
 echo ".global __dtb_z_${name}_end"
+if [ "$imd" = "y" ]; then
+	echo ".dword __barebox_imd_OF_${name}"
+fi
 echo ".balign STRUCT_ALIGNMENT"
 echo "#endif"
-- 
2.39.2




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

* [PATCH v2 2/2] treewide: remove no-longer needed IMD_USED_OF
  2023-04-04 10:17 [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically Ahmad Fatoum
@ 2023-04-04 10:17 ` Ahmad Fatoum
  2023-04-11 13:10 ` [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically Sascha Hauer
  2023-04-12 10:58 ` Sascha Hauer
  2 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2023-04-04 10:17 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Now that a __dtb* reference automatically pulls in the IMD tag if
support is compiled in, we can drop all IMD_USED_OF and turn the macro
into a no-op until we remove it completely.

Theoretically, an out-of-tree board could reference a DT via IMD_USED_OF
and not actually reference it via __dtb_*_start. So instead of makign
IMD_USED_OF a no-top, let's print a warning for a few releases until
we remove it completely.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - drop <image-metadata.h> header where applicable (Marco)
  - add depreciation warning for macro
---
 arch/arm/boards/innocomm-imx8mm-wb15/lowlevel.c  |  3 ---
 arch/arm/boards/ls1046ardb/lowlevel.c            |  2 --
 arch/arm/boards/nxp-imx8mm-evk/lowlevel.c        |  3 ---
 arch/arm/boards/nxp-imx8mp-evk/lowlevel.c        |  3 ---
 arch/arm/boards/nxp-imx8mq-evk/lowlevel.c        |  3 ---
 arch/arm/boards/phytec-som-imx6/lowlevel.c       |  1 -
 arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c |  3 ---
 arch/arm/boards/tqmls1046a/lowlevel.c            |  3 ---
 arch/arm/boards/zii-imx8mq-dev/lowlevel.c        |  4 ----
 include/image-metadata.h                         | 10 ++++++----
 10 files changed, 6 insertions(+), 29 deletions(-)

diff --git a/arch/arm/boards/innocomm-imx8mm-wb15/lowlevel.c b/arch/arm/boards/innocomm-imx8mm-wb15/lowlevel.c
index f7753bd32671..30cb7d9cae1a 100644
--- a/arch/arm/boards/innocomm-imx8mm-wb15/lowlevel.c
+++ b/arch/arm/boards/innocomm-imx8mm-wb15/lowlevel.c
@@ -13,7 +13,6 @@
 #include <mfd/bd71837.h>
 #include <mach/xload.h>
 #include <soc/imx8m/ddr.h>
-#include <image-metadata.h>
 
 #include "lowlevel.h"
 
@@ -74,8 +73,6 @@ void innocomm_wb15_power_init_board(void)
 
 ENTRY_FUNCTION(start_innocomm_wb15_evk, r0, r1, r2)
 {
-	IMD_USED_OF(imx8mm_innocomm_wb15_evk);
-
 	imx8mm_cpu_lowlevel_init();
 
 	relocate_to_current_adr();
diff --git a/arch/arm/boards/ls1046ardb/lowlevel.c b/arch/arm/boards/ls1046ardb/lowlevel.c
index 055e5f4c9995..b5265cd986b2 100644
--- a/arch/arm/boards/ls1046ardb/lowlevel.c
+++ b/arch/arm/boards/ls1046ardb/lowlevel.c
@@ -202,8 +202,6 @@ static noinline __noreturn void ls1046ardb_r_entry(unsigned long memsize)
 	debug_ll_init();
 	ls1046a_init_lowlevel();
 
-	IMD_USED_OF(fsl_ls1046a_rdb);
-
 	i2c = ls1046_i2c_init(IOMEM(LSCH2_I2C1_BASE_ADDR));
 	ret = spd_read_eeprom(i2c, 0x51, &spd_eeprom);
 	if (ret) {
diff --git a/arch/arm/boards/nxp-imx8mm-evk/lowlevel.c b/arch/arm/boards/nxp-imx8mm-evk/lowlevel.c
index 6132df53ec75..5dbb4962cf57 100644
--- a/arch/arm/boards/nxp-imx8mm-evk/lowlevel.c
+++ b/arch/arm/boards/nxp-imx8mm-evk/lowlevel.c
@@ -18,7 +18,6 @@
 #include <mfd/bd71837.h>
 #include <mach/xload.h>
 #include <soc/imx8m/ddr.h>
-#include <image-metadata.h>
 
 extern char __dtb_z_imx8mm_evk_start[];
 
@@ -119,7 +118,5 @@ ENTRY_FUNCTION(start_nxp_imx8mm_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
-	IMD_USED_OF(imx8mm_evk);
-
 	nxp_imx8mm_evk_start();
 }
diff --git a/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c b/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
index 3cb24df1ca3f..a62e2ba27efd 100644
--- a/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
+++ b/arch/arm/boards/nxp-imx8mp-evk/lowlevel.c
@@ -4,7 +4,6 @@
 #include <common.h>
 #include <debug_ll.h>
 #include <firmware.h>
-#include <image-metadata.h>
 #include <asm/mmu.h>
 #include <asm/cache.h>
 #include <asm/sections.h>
@@ -134,7 +133,5 @@ ENTRY_FUNCTION(start_nxp_imx8mp_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
-	IMD_USED_OF(imx8mp_evk);
-
 	nxp_imx8mp_evk_start();
 }
diff --git a/arch/arm/boards/nxp-imx8mq-evk/lowlevel.c b/arch/arm/boards/nxp-imx8mq-evk/lowlevel.c
index 0c9f6345ff30..8d57fecff36e 100644
--- a/arch/arm/boards/nxp-imx8mq-evk/lowlevel.c
+++ b/arch/arm/boards/nxp-imx8mq-evk/lowlevel.c
@@ -2,7 +2,6 @@
 
 #include <common.h>
 #include <firmware.h>
-#include <image-metadata.h>
 #include <linux/sizes.h>
 #include <mach/generic.h>
 #include <asm/barebox-arm-head.h>
@@ -107,7 +106,5 @@ ENTRY_FUNCTION(start_nxp_imx8mq_evk, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
-	IMD_USED_OF(imx8mq_evk);
-
 	nxp_imx8mq_evk_start();
 }
diff --git a/arch/arm/boards/phytec-som-imx6/lowlevel.c b/arch/arm/boards/phytec-som-imx6/lowlevel.c
index 62a1c8de7309..31c1e056aa1f 100644
--- a/arch/arm/boards/phytec-som-imx6/lowlevel.c
+++ b/arch/arm/boards/phytec-som-imx6/lowlevel.c
@@ -75,7 +75,6 @@ static void __noreturn start_imx6_phytec_common(uint32_t size,
 		extern char __dtb_##fdt_name##_start[];			\
 									\
 		IMD_USED(physom_mx6_memsize_##memory_size);		\
-		IMD_USED_OF(fdt_name);					\
 									\
 		start_imx6_phytec_common(memory_size, do_early_uart_config, \
 					 __dtb_##fdt_name##_start);	\
diff --git a/arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c b/arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c
index bfae39ea522e..80a1e44b3263 100644
--- a/arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c
+++ b/arch/arm/boards/protonic-imx8m/lowlevel-prt8mm.c
@@ -2,7 +2,6 @@
 
 #include <asm/barebox-arm.h>
 #include <common.h>
-#include <image-metadata.h>
 #include <debug_ll.h>
 #include <firmware.h>
 #include <mach/atf.h>
@@ -87,7 +86,5 @@ ENTRY_FUNCTION(start_prt_prt8mm, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
-	IMD_USED_OF(imx8mm_prt8mm);
-
 	prt_prt8mm_start();
 }
diff --git a/arch/arm/boards/tqmls1046a/lowlevel.c b/arch/arm/boards/tqmls1046a/lowlevel.c
index 99dcf1eff7ab..072be0599342 100644
--- a/arch/arm/boards/tqmls1046a/lowlevel.c
+++ b/arch/arm/boards/tqmls1046a/lowlevel.c
@@ -1,7 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 #include <common.h>
 #include <debug_ll.h>
-#include <image-metadata.h>
 #include <platform_data/mmc-esdhc-imx.h>
 #include <soc/fsl/fsl_ddr_sdram.h>
 #include <soc/fsl/immap_lsch2.h>
@@ -109,8 +108,6 @@ static noinline __noreturn void tqmls1046a_r_entry(void)
 	udelay(500);
 	putc_ll('>');
 
-	IMD_USED_OF(fsl_tqmls1046a_mbls10xxa);
-
 	fsl_ddr_set_memctl_regs(&ddrc[0], 0);
 
 	ls1046a_errata_post_ddr();
diff --git a/arch/arm/boards/zii-imx8mq-dev/lowlevel.c b/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
index cf53fb2defd6..311e61fb1da4 100644
--- a/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
+++ b/arch/arm/boards/zii-imx8mq-dev/lowlevel.c
@@ -6,7 +6,6 @@
 
 #include <common.h>
 #include <firmware.h>
-#include <image-metadata.h>
 #include <linux/sizes.h>
 #include <mach/generic.h>
 #include <asm/barebox-arm-head.h>
@@ -201,8 +200,5 @@ ENTRY_FUNCTION(start_zii_imx8mq_dev, r0, r1, r2)
 	relocate_to_current_adr();
 	setup_c();
 
-	IMD_USED_OF(imx8mq_zii_ultra_rmb3);
-	IMD_USED_OF(imx8mq_zii_ultra_zest);
-
 	zii_imx8mq_dev_start();
 }
diff --git a/include/image-metadata.h b/include/image-metadata.h
index bf4e08d98a47..615632f9ce81 100644
--- a/include/image-metadata.h
+++ b/include/image-metadata.h
@@ -156,10 +156,12 @@ static inline void imd_used(const void *unused)
 
 #define IMD_USED(_name) \
 	imd_used(&__barebox_imd_##_name)
-#define IMD_USED_OF(_name) ({ \
-	extern char __barebox_imd_OF_ ## _name[]; \
-	imd_used(&__barebox_imd_OF_ ## _name); \
-	})
+
+__attribute__((deprecated("IMD entries are now always referenced if DT itself is")))
+static inline void IMD_USED_OF(void)
+{}
+
+#define IMD_USED_OF(_name) IMD_USED_OF()
 
 #endif /* __BAREBOX__ */
 
-- 
2.39.2




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

* Re: [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically
  2023-04-04 10:17 [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically Ahmad Fatoum
  2023-04-04 10:17 ` [PATCH v2 2/2] treewide: remove no-longer needed IMD_USED_OF Ahmad Fatoum
@ 2023-04-11 13:10 ` Sascha Hauer
  2023-04-12 10:58 ` Sascha Hauer
  2 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2023-04-11 13:10 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Tue, Apr 04, 2023 at 12:17:05PM +0200, Ahmad Fatoum wrote:
> We currently require IMD_OF_USED to get the DT compatible into the
> barebox image data meta section. As the PBL is already referencing the
> DT to pass it along to barebox proper, let's add a reference from the DT
> to the image data section to make IMD_OF_USED unnecessary.
> 
> Suggested-by: Antony Pavlov <antonynpavlov@gmail.com>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> --
> v1 -> v2:
>   - use dword, to fix build for 64-bit (Sascha)
>   - place IMD reference before STRUCT_ALIGNMENT
> ---
>  scripts/gen-dtb-s | 6 ++++++
>  1 file changed, 6 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
> index c5c46a4d8675..6309a814a483 100755
> --- a/scripts/gen-dtb-s
> +++ b/scripts/gen-dtb-s
> @@ -49,6 +49,9 @@ echo "__dtb_${name}_start:"
>  echo ".incbin \"$dtb\""
>  echo "__dtb_${name}_end:"
>  echo ".global __dtb_${name}_end"
> +if [ "$imd" = "y" ]; then
> +	echo ".dword __barebox_imd_OF_${name}"
> +fi
>  echo ".balign STRUCT_ALIGNMENT"
>  
>  compressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb.z)
> @@ -65,5 +68,8 @@ printf ".int 0x%08x\n"  $uncompressed
>  echo ".incbin \"$dtb.z\""
>  echo "__dtb_z_${name}_end:"
>  echo ".global __dtb_z_${name}_end"
> +if [ "$imd" = "y" ]; then
> +	echo ".dword __barebox_imd_OF_${name}"
> +fi
>  echo ".balign STRUCT_ALIGNMENT"
>  echo "#endif"
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically
  2023-04-04 10:17 [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically Ahmad Fatoum
  2023-04-04 10:17 ` [PATCH v2 2/2] treewide: remove no-longer needed IMD_USED_OF Ahmad Fatoum
  2023-04-11 13:10 ` [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically Sascha Hauer
@ 2023-04-12 10:58 ` Sascha Hauer
  2023-04-12 11:22   ` [PATCH] fixup! " Ahmad Fatoum
  2 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2023-04-12 10:58 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Tue, Apr 04, 2023 at 12:17:05PM +0200, Ahmad Fatoum wrote:
> We currently require IMD_OF_USED to get the DT compatible into the
> barebox image data meta section. As the PBL is already referencing the
> DT to pass it along to barebox proper, let's add a reference from the DT
> to the image data section to make IMD_OF_USED unnecessary.
> 
> Suggested-by: Antony Pavlov <antonynpavlov@gmail.com>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> --
> v1 -> v2:
>   - use dword, to fix build for 64-bit (Sascha)

Indeed it fixes it for 64-bit, but now breaks it for 32-bit. Do we have
to #ifdef this or is there something clever we can do about this?

Sascha

>   - place IMD reference before STRUCT_ALIGNMENT
> ---
>  scripts/gen-dtb-s | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
> index c5c46a4d8675..6309a814a483 100755
> --- a/scripts/gen-dtb-s
> +++ b/scripts/gen-dtb-s
> @@ -49,6 +49,9 @@ echo "__dtb_${name}_start:"
>  echo ".incbin \"$dtb\""
>  echo "__dtb_${name}_end:"
>  echo ".global __dtb_${name}_end"
> +if [ "$imd" = "y" ]; then
> +	echo ".dword __barebox_imd_OF_${name}"
> +fi
>  echo ".balign STRUCT_ALIGNMENT"
>  
>  compressed=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" $dtb.z)
> @@ -65,5 +68,8 @@ printf ".int 0x%08x\n"  $uncompressed
>  echo ".incbin \"$dtb.z\""
>  echo "__dtb_z_${name}_end:"
>  echo ".global __dtb_z_${name}_end"
> +if [ "$imd" = "y" ]; then
> +	echo ".dword __barebox_imd_OF_${name}"
> +fi
>  echo ".balign STRUCT_ALIGNMENT"
>  echo "#endif"
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* [PATCH] fixup! scripts: gen-dtb-s: reference OF IMD entries automatically
  2023-04-12 10:58 ` Sascha Hauer
@ 2023-04-12 11:22   ` Ahmad Fatoum
  2023-04-12 14:12     ` Sascha Hauer
  2023-04-13  7:26     ` Sascha Hauer
  0 siblings, 2 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2023-04-12 11:22 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Apparently, .dword is not supported for 32-bit ARM builds.

Let's define ASM_PTR that expands to either .dword or .word and use
that instead.

The definition is taken from RISCV_PTR in arch/riscv/include/asm/asm.h.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Sascha, how about this?
---
 include/asm-generic/pointer.h | 30 ++++++++++++++++++++++++++++++
 scripts/gen-dtb-s             |  5 +++--
 2 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 include/asm-generic/pointer.h

diff --git a/include/asm-generic/pointer.h b/include/asm-generic/pointer.h
new file mode 100644
index 000000000000..a0ea084b983c
--- /dev/null
+++ b/include/asm-generic/pointer.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_GENERIC_PTR_H___
+#define __ASM_GENERIC_PTR_H___
+
+#if __SIZEOF_POINTER__ == 8
+#ifdef __ASSEMBLY__
+#define ASM_PTR		.dword
+#define ASM_SZPTR	8
+#define ASM_LGPTR	3
+#else
+#define ASM_PTR		".dword"
+#define ASM_SZPTR	"8"
+#define ASM_LGPTR	"3"
+#endif
+#elif __SIZEOF_POINTER__ == 4
+#ifdef __ASSEMBLY__
+#define ASM_PTR		.word
+#define ASM_SZPTR	4
+#define ASM_LGPTR	2
+#else
+#define ASM_PTR		".word"
+#define ASM_SZPTR	"4"
+#define ASM_LGPTR	"2"
+#endif
+#else
+#error "Unexpected __SIZEOF_POINTER__"
+#endif
+
+#endif /* __ASM_GENERIC_PTR_H___ */
diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index 6309a814a483..6a624e0bd5d0 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -5,6 +5,7 @@ dtb=$2
 imd=$3
 
 echo "#include <asm/barebox.lds.h>"
+echo "#include <asm-generic/pointer.h>"
 
 le32() {
 	printf ".byte 0x%02x, 0x%02x, 0x%02x, 0x%02x\n" \
@@ -50,7 +51,7 @@ echo ".incbin \"$dtb\""
 echo "__dtb_${name}_end:"
 echo ".global __dtb_${name}_end"
 if [ "$imd" = "y" ]; then
-	echo ".dword __barebox_imd_OF_${name}"
+	echo "ASM_PTR __barebox_imd_OF_${name}"
 fi
 echo ".balign STRUCT_ALIGNMENT"
 
@@ -69,7 +70,7 @@ echo ".incbin \"$dtb.z\""
 echo "__dtb_z_${name}_end:"
 echo ".global __dtb_z_${name}_end"
 if [ "$imd" = "y" ]; then
-	echo ".dword __barebox_imd_OF_${name}"
+	echo "ASM_PTR __barebox_imd_OF_${name}"
 fi
 echo ".balign STRUCT_ALIGNMENT"
 echo "#endif"
-- 
2.39.2




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

* Re: [PATCH] fixup! scripts: gen-dtb-s: reference OF IMD entries automatically
  2023-04-12 11:22   ` [PATCH] fixup! " Ahmad Fatoum
@ 2023-04-12 14:12     ` Sascha Hauer
  2023-04-13  7:26     ` Sascha Hauer
  1 sibling, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2023-04-12 14:12 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Wed, Apr 12, 2023 at 01:22:32PM +0200, Ahmad Fatoum wrote:
> Apparently, .dword is not supported for 32-bit ARM builds.
> 
> Let's define ASM_PTR that expands to either .dword or .word and use
> that instead.
> 
> The definition is taken from RISCV_PTR in arch/riscv/include/asm/asm.h.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> Sascha, how about this?

Ok, let's give it a try.

Sascha

> ---
>  include/asm-generic/pointer.h | 30 ++++++++++++++++++++++++++++++
>  scripts/gen-dtb-s             |  5 +++--
>  2 files changed, 33 insertions(+), 2 deletions(-)
>  create mode 100644 include/asm-generic/pointer.h
> 
> diff --git a/include/asm-generic/pointer.h b/include/asm-generic/pointer.h
> new file mode 100644
> index 000000000000..a0ea084b983c
> --- /dev/null
> +++ b/include/asm-generic/pointer.h
> @@ -0,0 +1,30 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef __ASM_GENERIC_PTR_H___
> +#define __ASM_GENERIC_PTR_H___
> +
> +#if __SIZEOF_POINTER__ == 8
> +#ifdef __ASSEMBLY__
> +#define ASM_PTR		.dword
> +#define ASM_SZPTR	8
> +#define ASM_LGPTR	3
> +#else
> +#define ASM_PTR		".dword"
> +#define ASM_SZPTR	"8"
> +#define ASM_LGPTR	"3"
> +#endif
> +#elif __SIZEOF_POINTER__ == 4
> +#ifdef __ASSEMBLY__
> +#define ASM_PTR		.word
> +#define ASM_SZPTR	4
> +#define ASM_LGPTR	2
> +#else
> +#define ASM_PTR		".word"
> +#define ASM_SZPTR	"4"
> +#define ASM_LGPTR	"2"
> +#endif
> +#else
> +#error "Unexpected __SIZEOF_POINTER__"
> +#endif
> +
> +#endif /* __ASM_GENERIC_PTR_H___ */
> diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
> index 6309a814a483..6a624e0bd5d0 100755
> --- a/scripts/gen-dtb-s
> +++ b/scripts/gen-dtb-s
> @@ -5,6 +5,7 @@ dtb=$2
>  imd=$3
>  
>  echo "#include <asm/barebox.lds.h>"
> +echo "#include <asm-generic/pointer.h>"
>  
>  le32() {
>  	printf ".byte 0x%02x, 0x%02x, 0x%02x, 0x%02x\n" \
> @@ -50,7 +51,7 @@ echo ".incbin \"$dtb\""
>  echo "__dtb_${name}_end:"
>  echo ".global __dtb_${name}_end"
>  if [ "$imd" = "y" ]; then
> -	echo ".dword __barebox_imd_OF_${name}"
> +	echo "ASM_PTR __barebox_imd_OF_${name}"
>  fi
>  echo ".balign STRUCT_ALIGNMENT"
>  
> @@ -69,7 +70,7 @@ echo ".incbin \"$dtb.z\""
>  echo "__dtb_z_${name}_end:"
>  echo ".global __dtb_z_${name}_end"
>  if [ "$imd" = "y" ]; then
> -	echo ".dword __barebox_imd_OF_${name}"
> +	echo "ASM_PTR __barebox_imd_OF_${name}"
>  fi
>  echo ".balign STRUCT_ALIGNMENT"
>  echo "#endif"
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH] fixup! scripts: gen-dtb-s: reference OF IMD entries automatically
  2023-04-12 11:22   ` [PATCH] fixup! " Ahmad Fatoum
  2023-04-12 14:12     ` Sascha Hauer
@ 2023-04-13  7:26     ` Sascha Hauer
  1 sibling, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2023-04-13  7:26 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Wed, Apr 12, 2023 at 01:22:32PM +0200, Ahmad Fatoum wrote:
> Apparently, .dword is not supported for 32-bit ARM builds.
> 
> Let's define ASM_PTR that expands to either .dword or .word and use
> that instead.
> 
> The definition is taken from RISCV_PTR in arch/riscv/include/asm/asm.h.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> Sascha, how about this?
> ---
>  include/asm-generic/pointer.h | 30 ++++++++++++++++++++++++++++++
>  scripts/gen-dtb-s             |  5 +++--
>  2 files changed, 33 insertions(+), 2 deletions(-)
>  create mode 100644 include/asm-generic/pointer.h
> 
> diff --git a/include/asm-generic/pointer.h b/include/asm-generic/pointer.h
> new file mode 100644
> index 000000000000..a0ea084b983c
> --- /dev/null
> +++ b/include/asm-generic/pointer.h
> @@ -0,0 +1,30 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef __ASM_GENERIC_PTR_H___
> +#define __ASM_GENERIC_PTR_H___
> +
> +#if __SIZEOF_POINTER__ == 8
> +#ifdef __ASSEMBLY__
> +#define ASM_PTR		.dword
> +#define ASM_SZPTR	8
> +#define ASM_LGPTR	3
> +#else
> +#define ASM_PTR		".dword"

We're still not there. .dword is not known by x86. I changed to .quad
now.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH] fixup! scripts: gen-dtb-s: reference OF IMD entries automatically
  2023-04-14 14:11 Ahmad Fatoum
@ 2023-04-17  7:00 ` Sascha Hauer
  0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2023-04-17  7:00 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Fri, Apr 14, 2023 at 04:11:54PM +0200, Ahmad Fatoum wrote:
> While the reference is just there, so linker garbage collection doesn't
> remove it, it's still a reference and it will be relocated.
> 
> This means it must be aligned, otherwise we will crash doing an unaligned
> access during relocation if device tree size isn't evenly divisible by
> pointer length...
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  scripts/gen-dtb-s | 2 ++
>  1 file changed, 2 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
> index 6a624e0bd5d0..f6fa1525933e 100755
> --- a/scripts/gen-dtb-s
> +++ b/scripts/gen-dtb-s
> @@ -51,6 +51,7 @@ echo ".incbin \"$dtb\""
>  echo "__dtb_${name}_end:"
>  echo ".global __dtb_${name}_end"
>  if [ "$imd" = "y" ]; then
> +	echo ".balign ASM_SZPTR"
>  	echo "ASM_PTR __barebox_imd_OF_${name}"
>  fi
>  echo ".balign STRUCT_ALIGNMENT"
> @@ -70,6 +71,7 @@ echo ".incbin \"$dtb.z\""
>  echo "__dtb_z_${name}_end:"
>  echo ".global __dtb_z_${name}_end"
>  if [ "$imd" = "y" ]; then
> +	echo ".balign ASM_SZPTR"
>  	echo "ASM_PTR __barebox_imd_OF_${name}"
>  fi
>  echo ".balign STRUCT_ALIGNMENT"
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* [PATCH] fixup! scripts: gen-dtb-s: reference OF IMD entries automatically
@ 2023-04-14 14:11 Ahmad Fatoum
  2023-04-17  7:00 ` Sascha Hauer
  0 siblings, 1 reply; 9+ messages in thread
From: Ahmad Fatoum @ 2023-04-14 14:11 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

While the reference is just there, so linker garbage collection doesn't
remove it, it's still a reference and it will be relocated.

This means it must be aligned, otherwise we will crash doing an unaligned
access during relocation if device tree size isn't evenly divisible by
pointer length...

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/gen-dtb-s | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s
index 6a624e0bd5d0..f6fa1525933e 100755
--- a/scripts/gen-dtb-s
+++ b/scripts/gen-dtb-s
@@ -51,6 +51,7 @@ echo ".incbin \"$dtb\""
 echo "__dtb_${name}_end:"
 echo ".global __dtb_${name}_end"
 if [ "$imd" = "y" ]; then
+	echo ".balign ASM_SZPTR"
 	echo "ASM_PTR __barebox_imd_OF_${name}"
 fi
 echo ".balign STRUCT_ALIGNMENT"
@@ -70,6 +71,7 @@ echo ".incbin \"$dtb.z\""
 echo "__dtb_z_${name}_end:"
 echo ".global __dtb_z_${name}_end"
 if [ "$imd" = "y" ]; then
+	echo ".balign ASM_SZPTR"
 	echo "ASM_PTR __barebox_imd_OF_${name}"
 fi
 echo ".balign STRUCT_ALIGNMENT"
-- 
2.39.2




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

end of thread, other threads:[~2023-04-17  7:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-04 10:17 [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically Ahmad Fatoum
2023-04-04 10:17 ` [PATCH v2 2/2] treewide: remove no-longer needed IMD_USED_OF Ahmad Fatoum
2023-04-11 13:10 ` [PATCH v2 1/2] scripts: gen-dtb-s: reference OF IMD entries automatically Sascha Hauer
2023-04-12 10:58 ` Sascha Hauer
2023-04-12 11:22   ` [PATCH] fixup! " Ahmad Fatoum
2023-04-12 14:12     ` Sascha Hauer
2023-04-13  7:26     ` Sascha Hauer
2023-04-14 14:11 Ahmad Fatoum
2023-04-17  7:00 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox