U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 0/3] Static initcalls
@ 2025-04-04 13:50 Jerome Forissier
  2025-04-04 13:50 ` [PATCH v6 1/3] arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set Jerome Forissier
                   ` (5 more replies)
  0 siblings, 6 replies; 25+ messages in thread
From: Jerome Forissier @ 2025-04-04 13:50 UTC (permalink / raw)
  To: u-boot; +Cc: Ilias Apalodimas, Jerome Forissier

This series replaces the dynamic initcalls (with function pointers) with
static calls, and gets rid of initcall_run_list(), init_sequence_f,
init_sequence_f_r and init_sequence_r. This makes the code simpler and the
binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).

Execution time doesn't seem to change noticeably. There is no impact on
the SPL.

The inline assembly fixes, although they look unrelated, are triggered
on some platforms with LTO enabled. For example: kirkwood_defconfig.

CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514

Changes in v6:
- Rebase on next branch

Changes in v5:
- Fix mistake in initcall_run_r(): CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
should have been !CONFIG_IS_ENABLED(...). As a result, several CI tests
were failing. (Tom R.)
- Restore fixes in test/py/tests/test_trace.py and arch/sh/lib/board.c
which had unexpectedly disappeared from v4 and caused CI errors.
- Fix CI error caused by wrong conditionals on the fix_fdt() call:
  tools/buildman/buildman -o /tmp -seP powerpc
  [...]
  common/board_f.c:752:12: error: 'fix_fdt' defined but not used [-Werror=unused-function]
- Add "arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set"
to fix a build error with LTO detecting mcr/mrc instructions emitted in
Thumb mode on a CPU that doesn't support it:
  make sheevaplug_defconfig
  make -j$(nproc) CROSS_COMPILE="ccache arm-linux-gnueabi-"
  [...]
    LTO     u-boot
  {standard input}: Assembler messages:
  {standard input}:9241: Error: selected processor does not support `mcr p15,1,r0,c15,c11,0' in Thumb mode
  {standard input}:19196: Error: selected processor does not support `mrc p15,1,r3,c15,c1,0' in Thumb mode
  {standard input}:19223: Error: selected processor does not support `mcr p15,1,r3,c15,c1,0' in Thumb mode
  {standard input}:19241: Error: selected processor does not support `mrc p15,1,r3,c15,c1,0' in Thumb mode
  {standard input}:19268: Error: selected processor does not support `mcr p15,1,r3,c15,c1,0' in Thumb mode
  {standard input}:19286: Error: selected processor does not support `mrc p15,1,r3,c15,c1,0' in Thumb mode
  {standard input}:19321: Error: selected processor does not support `mcr p15,1,r3,c15,c1,0' in Thumb mode
  {standard input}:19341: Error: selected processor does not support `mrc p15,0,r3,c1,c0,0' in Thumb mode
  {standard input}:19372: Error: selected processor does not support `mcr p15,0,r3,c1,c0,0' in Thumb mode
  make[1]: *** [/tmp/ccu1wZWX.mk:11: /tmp/ccIab81n.ltrans3.ltrans.o] Error 1

Changes in v4:
- Fold all changes to board_init_*() into a single patch
- Use '#if CONFIG_IS_ENABLED(FOO) INITCALL(init_foo) #endif' instead of
'CONFIG_IS_ENABLED(FOO, (INITCALL(init_foo);));' (Caleb C., Simon G.).
As a consequence, drop Michal's patch ("common: board: Simplify array
with function pointers with CONFIG_IS_ENABLED").
- Rebase on next

Changes in v3:
- Use printf() rather than debug() to report initcall failures
(Quentin S.)
- initcall_run_f(): replace one erroneous call to WATCHDOG_INIT() with
WATCHDOG_RESET() (Ilias A.)
- Fix relocate_code() in arch/sh/lib/board.c to address CI failures with
r2dplus (https://lists.denx.de/pipermail/u-boot/2025-January/576213.html)
(Tom R.)
- Add comments to initcall_run_f() and initcall_run_r() (Simon G.)

Changes in v2:
- INTICALL() and INITCALL_EVT() now call hang() immediately on error
- Fixed typo: s/intcall_run_f_r/initcall_run_f_r/


Jerome Forissier (3):
  arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set
  common: board: make initcalls static
  initcall: remove initcall_run_list()

 arch/arm/include/asm/system.h             |  22 +-
 arch/arm/lib/cache.c                      |   5 +-
 arch/arm/mach-kirkwood/include/mach/cpu.h |   9 +-
 arch/sh/lib/board.c                       |   9 +-
 common/board_f.c                          | 223 +++++++++----------
 common/board_r.c                          | 247 +++++++++++-----------
 include/initcall.h                        |  45 ++--
 lib/Makefile                              |   1 -
 lib/initcall.c                            | 102 ---------
 test/py/tests/test_trace.py               |   8 +-
 10 files changed, 295 insertions(+), 376 deletions(-)
 delete mode 100644 lib/initcall.c

-- 
2.43.0


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

* [PATCH v6 1/3] arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set
  2025-04-04 13:50 [PATCH v6 0/3] Static initcalls Jerome Forissier
@ 2025-04-04 13:50 ` Jerome Forissier
  2025-04-04 13:50 ` [PATCH v6 2/3] common: board: make initcalls static Jerome Forissier
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 25+ messages in thread
From: Jerome Forissier @ 2025-04-04 13:50 UTC (permalink / raw)
  To: u-boot
  Cc: Ilias Apalodimas, Jerome Forissier, Tom Rini, Stefan Roese,
	Andre Przywara, Peter Hoyes, Sam Protsenko, Simon Glass,
	Patrick Rudolph, Marek Vasut, Caleb Connolly

The mcr and msr instructions are available in Thumb mode only if
Thumb2 is supported. Therefore, if __thumb2__ is not set, make
sure we switch to ARM mode by inserting a .arm directive in the
inline assembly.

Fixes LTO link errors with kirkwood platforms, triggered by a later
commit:

 tools/buildman/buildman -o /tmp/build -eP sheevaplug
 [...]
 {standard input}:24085: Error: selected processor does not support `mrc p15,0,r3,c1,c0,0' in Thumb mode

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 arch/arm/include/asm/system.h             | 22 +++++++++++++++++-----
 arch/arm/lib/cache.c                      |  5 +++--
 arch/arm/mach-kirkwood/include/mach/cpu.h |  9 +++++----
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 849b3d0efb7..4c1b81483c9 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -428,11 +428,21 @@ void switch_to_hypervisor_ret(void);
 #define wfi()
 #endif
 
+#if !defined(__thumb2__)
+/*
+ * We will need to switch to ARM mode (.arm) for some instructions such as
+ * mrc p15 etc.
+ */
+#define asm_arm_or_thumb2(insn) asm volatile(".arm\n\t" insn)
+#else
+#define asm_arm_or_thumb2(insn) asm volatile(insn)
+#endif
+
 static inline unsigned long read_mpidr(void)
 {
 	unsigned long val;
 
-	asm volatile("mrc p15, 0, %0, c0, c0, 5" : "=r" (val));
+	asm_arm_or_thumb2("mrc p15, 0, %0, c0, c0, 5" : "=r" (val));
 
 	return val;
 }
@@ -461,11 +471,13 @@ static inline unsigned int get_cr(void)
 	unsigned int val;
 
 	if (is_hyp())
-		asm volatile("mrc p15, 4, %0, c1, c0, 0	@ get CR" : "=r" (val)
+		asm_arm_or_thumb2("mrc p15, 4, %0, c1, c0, 0	@ get CR"
+								  : "=r" (val)
 								  :
 								  : "cc");
 	else
-		asm volatile("mrc p15, 0, %0, c1, c0, 0	@ get CR" : "=r" (val)
+		asm_arm_or_thumb2("mrc p15, 0, %0, c1, c0, 0	@ get CR"
+								  : "=r" (val)
 								  :
 								  : "cc");
 	return val;
@@ -474,11 +486,11 @@ static inline unsigned int get_cr(void)
 static inline void set_cr(unsigned int val)
 {
 	if (is_hyp())
-		asm volatile("mcr p15, 4, %0, c1, c0, 0	@ set CR" :
+		asm_arm_or_thumb2("mcr p15, 4, %0, c1, c0, 0	@ set CR" :
 								  : "r" (val)
 								  : "cc");
 	else
-		asm volatile("mcr p15, 0, %0, c1, c0, 0	@ set CR" :
+		asm_arm_or_thumb2("mcr p15, 0, %0, c1, c0, 0	@ set CR" :
 								  : "r" (val)
 								  : "cc");
 	isb();
diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index dd19bd3e4fb..ed6f15cb570 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -10,6 +10,7 @@
 #include <malloc.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
+#include <asm/system.h>
 #include <linux/errno.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -126,8 +127,8 @@ void invalidate_l2_cache(void)
 {
 	unsigned int val = 0;
 
-	asm volatile("mcr p15, 1, %0, c15, c11, 0 @ invl l2 cache"
-		: : "r" (val) : "cc");
+	asm_arm_or_thumb2("mcr p15, 1, %0, c15, c11, 0 @ invl l2 cache"
+			  : : "r" (val) : "cc");
 	isb();
 }
 #endif
diff --git a/arch/arm/mach-kirkwood/include/mach/cpu.h b/arch/arm/mach-kirkwood/include/mach/cpu.h
index 9eec786fe8f..dce190ddee2 100644
--- a/arch/arm/mach-kirkwood/include/mach/cpu.h
+++ b/arch/arm/mach-kirkwood/include/mach/cpu.h
@@ -85,8 +85,9 @@ struct mbus_win {
 static inline unsigned int readfr_extra_feature_reg(void)
 {
 	unsigned int val;
-	asm volatile ("mrc p15, 1, %0, c15, c1, 0 @ readfr exfr":"=r"
-			(val)::"cc");
+
+	asm_arm_or_thumb2("mrc p15, 1, %0, c15, c1, 0 @ readfr exfr":"=r"
+			  (val)::"cc");
 	return val;
 }
 
@@ -96,8 +97,8 @@ static inline unsigned int readfr_extra_feature_reg(void)
  */
 static inline void writefr_extra_feature_reg(unsigned int val)
 {
-	asm volatile ("mcr p15, 1, %0, c15, c1, 0 @ writefr exfr"::"r"
-			(val):"cc");
+	asm_arm_or_thumb2("mcr p15, 1, %0, c15, c1, 0 @ writefr exfr"::"r"
+			  (val):"cc");
 	isb();
 }
 
-- 
2.43.0


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

* [PATCH v6 2/3] common: board: make initcalls static
  2025-04-04 13:50 [PATCH v6 0/3] Static initcalls Jerome Forissier
  2025-04-04 13:50 ` [PATCH v6 1/3] arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set Jerome Forissier
@ 2025-04-04 13:50 ` Jerome Forissier
  2025-04-12 20:52   ` Marek Vasut
  2025-06-03 15:22   ` Simon Glass
  2025-04-04 13:50 ` [PATCH v6 3/3] initcall: remove initcall_run_list() Jerome Forissier
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 25+ messages in thread
From: Jerome Forissier @ 2025-04-04 13:50 UTC (permalink / raw)
  To: u-boot
  Cc: Ilias Apalodimas, Jerome Forissier, Marek Vasut,
	Nobuhiro Iwamatsu, Tom Rini, Simon Glass, Jonas Karlman,
	Raymond Mao, Evgeny Bachinin, Michal Simek, Christian Marangi,
	Mattijs Korpershoek, Caleb Connolly

Change board_init_f(), board_init_f_r() and board_init_r() to make
static calls instead of iterating over the init_sequence_f,
init_sequence_f_r and init_sequence_r arrays, respectively. This makes
the code a simpler (and even more so when initcall_run_list() is
later removed) and it reduces the binary size as well. Tested with
xilinx_zynqmp_kria_defconfig; bloat-o-meter results:

- With LTO
add/remove: 106/196 grow/shrink: 10/28 up/down: 31548/-33829 (-2281)
Total: Before=1070471, After=1068190, chg -0.21%
- Without LTO
add/remove: 0/54 grow/shrink: 3/0 up/down: 2322/-2832 (-510)
Total: Before=1121723, After=1121213, chg -0.05%

Execution time does not change in a noticeable way.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 arch/sh/lib/board.c         |   9 +-
 common/board_f.c            | 223 ++++++++++++++++----------------
 common/board_r.c            | 247 ++++++++++++++++++------------------
 include/initcall.h          |  27 ++++
 test/py/tests/test_trace.py |   8 +-
 5 files changed, 273 insertions(+), 241 deletions(-)

diff --git a/arch/sh/lib/board.c b/arch/sh/lib/board.c
index 53b1c147c2e..2daf54e7c33 100644
--- a/arch/sh/lib/board.c
+++ b/arch/sh/lib/board.c
@@ -19,18 +19,13 @@ int dram_init(void)
 
 void relocate_code(ulong start_addr_sp, gd_t *new_gd, ulong relocaddr)
 {
-	void (*reloc_board_init_r)(gd_t *gd, ulong dest) = board_init_r;
-
-	if (new_gd->reloc_off) {
+	if (new_gd->reloc_off)
 		memcpy((void *)new_gd->relocaddr,
 		       (void *)(new_gd->relocaddr - new_gd->reloc_off),
 		       new_gd->mon_len);
 
-		reloc_board_init_r += new_gd->reloc_off;
-	}
-
 	__asm__ __volatile__("mov.l %0, r15\n" : : "m" (new_gd->start_addr_sp));
 
 	while (1)
-		reloc_board_init_r(new_gd, 0x0);
+		board_init_r(new_gd, 0x0);
 }
diff --git a/common/board_f.c b/common/board_f.c
index baf98fb8ec8..a1bb8a01be5 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -38,6 +38,7 @@
 #include <spl.h>
 #include <status_led.h>
 #include <sysreset.h>
+#include <time.h>
 #include <timer.h>
 #include <trace.h>
 #include <upl.h>
@@ -753,7 +754,7 @@ static int setup_reloc(void)
 	return 0;
 }
 
-#ifdef CONFIG_OF_BOARD_FIXUP
+#if CONFIG_IS_ENABLED(OF_BOARD_FIXUP)
 static int fix_fdt(void)
 {
 	return board_fix_fdt((void *)gd->fdt_blob);
@@ -881,81 +882,86 @@ static int initf_upl(void)
 	return 0;
 }
 
-static const init_fnc_t init_sequence_f[] = {
-	setup_mon_len,
-#ifdef CONFIG_OF_CONTROL
-	fdtdec_setup,
+static void initcall_run_f(void)
+{
+	/*
+	 * Please do not add logic to this function (variables, if (), etc.).
+	 * For simplicity it should remain an ordered list of function calls.
+	 */
+	INITCALL(setup_mon_len);
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+	INITCALL(fdtdec_setup);
 #endif
-#ifdef CONFIG_TRACE_EARLY
-	trace_early_init,
+#if CONFIG_IS_ENABLED(TRACE_EARLY)
+	INITCALL(trace_early_init);
 #endif
-	initf_malloc,
-	initf_upl,
-	log_init,
-	initf_bootstage,	/* uses its own timer, so does not need DM */
-	event_init,
-	bloblist_maybe_init,
-	setup_spl_handoff,
-#if defined(CONFIG_CONSOLE_RECORD_INIT_F)
-	console_record_init,
+	INITCALL(initf_malloc);
+	INITCALL(initf_upl);
+	INITCALL(log_init);
+	INITCALL(initf_bootstage); /* uses its own timer, so does not need DM */
+	INITCALL(event_init);
+	INITCALL(bloblist_maybe_init);
+	INITCALL(setup_spl_handoff);
+#if CONFIG_IS_ENABLED(CONSOLE_RECORD_INIT_F)
+	INITCALL(console_record_init);
 #endif
-	INITCALL_EVENT(EVT_FSP_INIT_F),
-	arch_cpu_init,		/* basic arch cpu dependent setup */
-	mach_cpu_init,		/* SoC/machine dependent CPU setup */
-	initf_dm,
-#if defined(CONFIG_BOARD_EARLY_INIT_F)
-	board_early_init_f,
+	INITCALL_EVT(EVT_FSP_INIT_F);
+	INITCALL(arch_cpu_init);	/* basic arch cpu dependent setup */
+	INITCALL(mach_cpu_init);	/* SoC/machine dependent CPU setup */
+	INITCALL(initf_dm);
+#if CONFIG_IS_ENABLED(BOARD_EARLY_INIT_F)
+	INITCALL(board_early_init_f);
 #endif
 #if defined(CONFIG_PPC) || defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
 	/* get CPU and bus clocks according to the environment variable */
-	get_clocks,		/* get CPU and bus clocks (etc.) */
+	INITCALL(get_clocks);		/* get CPU and bus clocks (etc.) */
 #endif
 #if !defined(CONFIG_M68K) || (defined(CONFIG_M68K) && !defined(CONFIG_MCFTMR))
-	timer_init,		/* initialize timer */
+	INITCALL(timer_init);		/* initialize timer */
 #endif
-#if defined(CONFIG_BOARD_POSTCLK_INIT)
-	board_postclk_init,
+#if CONFIG_IS_ENABLED(BOARD_POSTCLK_INIT)
+	INITCALL(board_postclk_init);
 #endif
-	env_init,		/* initialize environment */
-	init_baud_rate,		/* initialze baudrate settings */
-	serial_init,		/* serial communications setup */
-	console_init_f,		/* stage 1 init of console */
-	display_options,	/* say that we are here */
-	display_text_info,	/* show debugging info if required */
-	checkcpu,
-#if defined(CONFIG_SYSRESET)
-	print_resetinfo,
+	INITCALL(env_init);		/* initialize environment */
+	INITCALL(init_baud_rate);	/* initialze baudrate settings */
+	INITCALL(serial_init);		/* serial communications setup */
+	INITCALL(console_init_f);	/* stage 1 init of console */
+	INITCALL(display_options);	/* say that we are here */
+	INITCALL(display_text_info);	/* show debugging info if required */
+	INITCALL(checkcpu);
+#if CONFIG_IS_ENABLED(SYSRESET)
+	INITCALL(print_resetinfo);
 #endif
-#if defined(CONFIG_DISPLAY_CPUINFO)
-	print_cpuinfo,		/* display cpu info (and speed) */
+	/* display cpu info (and speed) */
+#if CONFIG_IS_ENABLED(DISPLAY_CPUINFO)
+	INITCALL(print_cpuinfo);
 #endif
-#if defined(CONFIG_DTB_RESELECT)
-	embedded_dtb_select,
+#if CONFIG_IS_ENABLED(DTB_RESELECT)
+	INITCALL(embedded_dtb_select);
 #endif
-#if defined(CONFIG_DISPLAY_BOARDINFO)
-	show_board_info,
+#if CONFIG_IS_ENABLED(DISPLAY_BOARDINFO)
+	INITCALL(show_board_info);
 #endif
-	INIT_FUNC_WATCHDOG_INIT
-	INITCALL_EVENT(EVT_MISC_INIT_F),
-	INIT_FUNC_WATCHDOG_RESET
+	WATCHDOG_INIT();
+	INITCALL_EVT(EVT_MISC_INIT_F);
+	WATCHDOG_RESET();
 #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
-	init_func_i2c,
+	INITCALL(init_func_i2c);
 #endif
-	announce_dram_init,
-	dram_init,		/* configure available RAM banks */
-#ifdef CONFIG_POST
-	post_init_f,
+	INITCALL(announce_dram_init);
+	INITCALL(dram_init);		/* configure available RAM banks */
+#if CONFIG_IS_ENABLED(POST)
+	INITCALL(post_init_f);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
+	WATCHDOG_RESET();
 #if defined(CFG_SYS_DRAM_TEST)
-	testdram,
+	INITCALL(testdram);
 #endif /* CFG_SYS_DRAM_TEST */
-	INIT_FUNC_WATCHDOG_RESET
-
-#ifdef CONFIG_POST
-	init_post,
+	WATCHDOG_RESET();
+#if CONFIG_IS_ENABLED(POST)
+	INITCALL(init_post);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
+	WATCHDOG_RESET();
 	/*
 	 * Now that we have DRAM mapped and working, we can
 	 * relocate the code and continue running from DRAM.
@@ -968,48 +974,51 @@ static const init_fnc_t init_sequence_f[] = {
 	 *  - monitor code
 	 *  - board info struct
 	 */
-	setup_dest_addr,
-#if defined(CONFIG_OF_BOARD_FIXUP) && !defined(CONFIG_OF_INITIAL_DTB_READONLY)
-	fix_fdt,
+	INITCALL(setup_dest_addr);
+#if CONFIG_IS_ENABLED(OF_BOARD_FIXUP) && \
+    !CONFIG_IS_ENABLED(OF_INITIAL_DTB_READONLY)
+	INITCALL(fix_fdt);
 #endif
 #ifdef CFG_PRAM
-	reserve_pram,
+	INITCALL(reserve_pram);
 #endif
-	reserve_round_4k,
-	setup_relocaddr_from_bloblist,
-	arch_reserve_mmu,
-	reserve_video,
-	reserve_trace,
-	reserve_uboot,
-	reserve_malloc,
-	reserve_board,
-	reserve_global_data,
-	reserve_fdt,
-#if defined(CONFIG_OF_BOARD_FIXUP) && defined(CONFIG_OF_INITIAL_DTB_READONLY)
-	reloc_fdt,
-	fix_fdt,
+	INITCALL(reserve_round_4k);
+	INITCALL(setup_relocaddr_from_bloblist);
+	INITCALL(arch_reserve_mmu);
+	INITCALL(reserve_video);
+	INITCALL(reserve_trace);
+	INITCALL(reserve_uboot);
+	INITCALL(reserve_malloc);
+	INITCALL(reserve_board);
+	INITCALL(reserve_global_data);
+	INITCALL(reserve_fdt);
+#if CONFIG_IS_ENABLED(OF_BOARD_FIXUP) && \
+    CONFIG_IS_ENABLED(OF_INITIAL_DTB_READONLY)
+	INITCALL(reloc_fdt);
+	INITCALL(fix_fdt);
 #endif
-	reserve_bootstage,
-	reserve_bloblist,
-	reserve_arch,
-	reserve_stacks,
-	dram_init_banksize,
-	show_dram_config,
-	INIT_FUNC_WATCHDOG_RESET
-	setup_bdinfo,
-	display_new_sp,
-	INIT_FUNC_WATCHDOG_RESET
-#if !defined(CONFIG_OF_BOARD_FIXUP) || !defined(CONFIG_OF_INITIAL_DTB_READONLY)
-	reloc_fdt,
+	INITCALL(reserve_bootstage);
+	INITCALL(reserve_bloblist);
+	INITCALL(reserve_arch);
+	INITCALL(reserve_stacks);
+	INITCALL(dram_init_banksize);
+	INITCALL(show_dram_config);
+	WATCHDOG_RESET();
+	INITCALL(setup_bdinfo);
+	INITCALL(display_new_sp);
+	WATCHDOG_RESET();
+#if !CONFIG_IS_ENABLED(OF_BOARD_FIXUP) || \
+    !CONFIG_IS_ENABLED(INITIAL_DTB_READONLY)
+	INITCALL(reloc_fdt);
 #endif
-	reloc_bootstage,
-	reloc_bloblist,
-	setup_reloc,
-#if defined(CONFIG_X86) || defined(CONFIG_ARC)
-	copy_uboot_to_ram,
-	do_elf_reloc_fixups,
+	INITCALL(reloc_bootstage);
+	INITCALL(reloc_bloblist);
+	INITCALL(setup_reloc);
+#if CONFIG_IS_ENABLED(X86) || CONFIG_IS_ENABLED(ARC)
+	INITCALL(copy_uboot_to_ram);
+	INITCALL(do_elf_reloc_fixups);
 #endif
-	clear_bss,
+	INITCALL(clear_bss);
 	/*
 	 * Deregister all cyclic functions before relocation, so that
 	 * gd->cyclic_list does not contain any references to pre-relocation
@@ -1019,12 +1028,11 @@ static const init_fnc_t init_sequence_f[] = {
 	 * This should happen as late as possible so that the window where a
 	 * watchdog device is not serviced is as small as possible.
 	 */
-	cyclic_unregister_all,
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
-	jump_to_copy,
+	INITCALL(cyclic_unregister_all);
+#if !CONFIG_IS_ENABLED(ARM) && !CONFIG_IS_ENABLED(SANDBOX)
+	INITCALL(jump_to_copy);
 #endif
-	NULL,
-};
+}
 
 void board_init_f(ulong boot_flags)
 {
@@ -1034,8 +1042,7 @@ void board_init_f(ulong boot_flags)
 	gd->flags &= ~GD_FLG_HAVE_CONSOLE;
 	gd->boardf = &boardf;
 
-	if (initcall_run_list(init_sequence_f))
-		hang();
+	initcall_run_f();
 
 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
 		!defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64) && \
@@ -1049,8 +1056,8 @@ void board_init_f(ulong boot_flags)
 /*
  * For now this code is only used on x86.
  *
- * init_sequence_f_r is the list of init functions which are run when
- * U-Boot is executing from Flash with a semi-limited 'C' environment.
+ * Run init functions which are run when U-Boot is executing from Flash with a
+ * semi-limited 'C' environment.
  * The following limitations must be considered when implementing an
  * '_f_r' function:
  *  - 'static' variables are read-only
@@ -1063,18 +1070,16 @@ void board_init_f(ulong boot_flags)
  * NOTE: At present only x86 uses this route, but it is intended that
  * all archs will move to this when generic relocation is implemented.
  */
-static const init_fnc_t init_sequence_f_r[] = {
-#if !CONFIG_IS_ENABLED(X86_64)
-	init_cache_f_r,
+static void initcall_run_f_r(void)
+{
+#if CONFIG_IS_ENABLED(X86_64)
+	INITCALL(init_cache_f_r);
 #endif
-
-	NULL,
-};
+}
 
 void board_init_f_r(void)
 {
-	if (initcall_run_list(init_sequence_f_r))
-		hang();
+	initcall_run_f_r();
 
 	/*
 	 * The pre-relocation drivers may be using memory that has now gone
diff --git a/common/board_r.c b/common/board_r.c
index 8d69db1875d..643431d9db7 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -602,21 +602,24 @@ static int run_main_loop(void)
 }
 
 /*
- * Over time we hope to remove these functions with code fragments and
- * stub functions, and instead call the relevant function directly.
- *
- * We also hope to remove most of the driver-related init and do it if/when
- * the driver is later used.
+ * Over time we hope to remove most of the driver-related init and do it
+ * if/when the driver is later used.
  *
  * TODO: perhaps reset the watchdog in the initcall function after each call?
  */
-static init_fnc_t init_sequence_r[] = {
-	initr_trace,
-	initr_reloc,
-	event_init,
+
+static void initcall_run_r(void)
+{
+	/*
+	 * Please do not add logic to this function (variables, if (), etc.).
+	 * For simplicity it should remain an ordered list of function calls.
+	 */
+	INITCALL(initr_trace);
+	INITCALL(initr_reloc);
+	INITCALL(event_init);
 	/* TODO: could x86/PPC have this also perhaps? */
-#if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
-	initr_caches,
+#if CONFIG_IS_ENABLED(ARM) || CONFIG_IS_ENABLED(RISCV)
+	INITCALL(initr_caches);
 	/* Note: For Freescale LS2 SoCs, new MMU table is created in DDR.
 	 *	 A temporary mapping of IFC high region is since removed,
 	 *	 so environmental variables in NOR flash is not available
@@ -624,29 +627,30 @@ static init_fnc_t init_sequence_r[] = {
 	 *	 region.
 	 */
 #endif
-	initr_reloc_global_data,
-#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
-	initr_unlock_ram_in_cache,
+	INITCALL(initr_reloc_global_data);
+#if CONFIG_IS_ENABLED(SYS_INIT_RAM_LOCK) && CONFIG_IS_ENABLED(E500)
+	INITCALL(initr_unlock_ram_in_cache);
 #endif
-	initr_barrier,
-	initr_malloc,
-	log_init,
-	initr_bootstage,	/* Needs malloc() but has its own timer */
-#if defined(CONFIG_CONSOLE_RECORD)
-	console_record_init,
+	INITCALL(initr_barrier);
+	INITCALL(initr_malloc);
+	INITCALL(log_init);
+	INITCALL(initr_bootstage); /* Needs malloc() but has its own timer */
+#if CONFIG_IS_ENABLED(CONSOLE_RECORD)
+	INITCALL(console_record_init);
 #endif
-#ifdef CONFIG_SYS_NONCACHED_MEMORY
-	noncached_init,
+#if CONFIG_IS_ENABLED(SYS_NONCACHED_MEMORY)
+	INITCALL(noncached_init);
 #endif
-	initr_of_live,
-#ifdef CONFIG_DM
-	initr_dm,
+	INITCALL(initr_of_live);
+#if CONFIG_IS_ENABLED(DM)
+	INITCALL(initr_dm);
 #endif
-#ifdef CONFIG_ADDR_MAP
-	init_addr_map,
+#if CONFIG_IS_ENABLED(ADDR_MAP)
+	INITCALL(init_addr_map);
 #endif
-#if defined(CONFIG_ARM) || defined(CONFIG_RISCV) || defined(CONFIG_SANDBOX)
-	board_init,	/* Setup chipselects */
+#if CONFIG_IS_ENABLED(ARM) || CONFIG_IS_ENABLED(RISCV) || \
+    CONFIG_IS_ENABLED(SANDBOX)
+	INITCALL(board_init);	/* Setup chipselects */
 #endif
 	/*
 	 * TODO: printing of the clock inforamtion of the board is now
@@ -654,139 +658,141 @@ static init_fnc_t init_sequence_r[] = {
 	 * davinci SOC's is added. Remove this check once all the board
 	 * implement this.
 	 */
-#ifdef CONFIG_CLOCKS
-	set_cpu_clk_info, /* Setup clock information */
+#if CONFIG_IS_ENABLED(CLOCKS)
+	INITCALL(set_cpu_clk_info);
 #endif
-	initr_lmb,
-#ifdef CONFIG_EFI_LOADER
-	efi_memory_init,
+	INITCALL(initr_lmb);
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+	INITCALL(efi_memory_init);
 #endif
-#ifdef CONFIG_BINMAN_FDT
-	initr_binman,
+#if CONFIG_IS_ENABLED(BINMAN_FDT)
+	INITCALL(initr_binman);
 #endif
-#ifdef CONFIG_FSP_VERSION2
-	arch_fsp_init_r,
+#if CONFIG_IS_ENABLED(FSP_VERSION2)
+	INITCALL(arch_fsp_init_r);
 #endif
-	initr_dm_devices,
-	stdio_init_tables,
-	serial_initialize,
-	initr_announce,
-	dm_announce,
+	INITCALL(initr_dm_devices);
+	INITCALL(stdio_init_tables);
+	INITCALL(serial_initialize);
+	INITCALL(initr_announce);
+	INITCALL(dm_announce);
 #if CONFIG_IS_ENABLED(WDT)
-	initr_watchdog,
+	INITCALL(initr_watchdog);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
-	arch_initr_trap,
-#if defined(CONFIG_BOARD_EARLY_INIT_R)
-	board_early_init_r,
+	WATCHDOG_RESET();
+	INITCALL(arch_initr_trap);
+#if CONFIG_IS_ENABLED(BOARD_EARLY_INIT_R)
+	INITCALL(board_early_init_r);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
-#ifdef CONFIG_POST
-	post_output_backlog,
+	WATCHDOG_RESET();
+#if CONFIG_IS_ENABLED(POST)
+	INITCALL(post_output_backlog);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_PCI_INIT_R) && defined(CONFIG_SYS_EARLY_PCI_INIT)
+	WATCHDOG_RESET();
+#if CONFIG_IS_ENABLED(PCI_INIT_R) && CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
 	/*
 	 * Do early PCI configuration _before_ the flash gets initialised,
 	 * because PCU resources are crucial for flash access on some boards.
 	 */
-	pci_init,
+	INITCALL(pci_init);
 #endif
-#ifdef CONFIG_ARCH_EARLY_INIT_R
-	arch_early_init_r,
+#if CONFIG_IS_ENABLED(ARCH_EARLY_INIT_R)
+	INITCALL(arch_early_init_r);
 #endif
-	power_init_board,
-#ifdef CONFIG_MTD_NOR_FLASH
-	initr_flash,
+	INITCALL(power_init_board);
+#if CONFIG_IS_ENABLED(MTD_NOR_FLASH)
+	INITCALL(initr_flash);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86)
+	WATCHDOG_RESET();
+#if CONFIG_IS_ENABLED(PPC) || CONFIG_IS_ENABLED(M68K) || CONFIG_IS_ENABLED(X86)
 	/* initialize higher level parts of CPU like time base and timers */
-	cpu_init_r,
+	INITCALL(cpu_init_r);
 #endif
-#ifdef CONFIG_EFI_LOADER
-	efi_init_early,
+#if CONFIG_IS_ENABLED(EFI_LOADER)
+	INITCALL(efi_init_early);
 #endif
-#ifdef CONFIG_CMD_NAND
-	initr_nand,
+#if CONFIG_IS_ENABLED(CMD_NAND)
+	INITCALL(initr_nand);
 #endif
-#ifdef CONFIG_CMD_ONENAND
-	initr_onenand,
+#if CONFIG_IS_ENABLED(CMD_ONENAND)
+	INITCALL(initr_onenand);
 #endif
-#ifdef CONFIG_MMC
-	initr_mmc,
+#if CONFIG_IS_ENABLED(MMC)
+	INITCALL(initr_mmc);
 #endif
-#ifdef CONFIG_XEN
-	xen_init,
+#if CONFIG_IS_ENABLED(XEN)
+	INITCALL(xen_init);
 #endif
-#ifdef CONFIG_PVBLOCK
-	initr_pvblock,
+#if CONFIG_IS_ENABLED(PVBLOCK)
+	INITCALL(initr_pvblock);
 #endif
-	initr_env,
-#ifdef CONFIG_SYS_MALLOC_BOOTPARAMS
-	initr_malloc_bootparams,
+	INITCALL(initr_env);
+#if CONFIG_IS_ENABLED(SYS_MALLOC_BOOTPARAMS)
+	INITCALL(initr_malloc_bootparams);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
-	cpu_secondary_init_r,
-#if defined(CONFIG_ID_EEPROM)
-	mac_read_from_eeprom,
+	WATCHDOG_RESET();
+	INITCALL(cpu_secondary_init_r);
+#if CONFIG_IS_ENABLED(ID_EEPROM)
+	INITCALL(mac_read_from_eeprom);
 #endif
-	INITCALL_EVENT(EVT_SETTINGS_R),
-	INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_PCI_INIT_R) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
+	INITCALL_EVT(EVT_SETTINGS_R);
+	WATCHDOG_RESET();
+#if CONFIG_IS_ENABLED(PCI_INIT_R) && !CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
 	/*
 	 * Do pci configuration
 	 */
-	pci_init,
+	INITCALL(pci_init);
 #endif
-	stdio_add_devices,
-	jumptable_init,
-#ifdef CONFIG_API
-	api_init,
+	INITCALL(stdio_add_devices);
+	INITCALL(jumptable_init);
+#if CONFIG_IS_ENABLED(API)
+	INITCALL(api_init);
 #endif
-	console_init_r,		/* fully init console as a device */
-#ifdef CONFIG_DISPLAY_BOARDINFO_LATE
-	console_announce_r,
-	show_board_info,
+	INITCALL(console_init_r);	/* fully init console as a device */
+#if CONFIG_IS_ENABLED(DISPLAY_BOARDINFO_LATE)
+	INITCALL(console_announce_r);
+	INITCALL(show_board_info);
 #endif
-#ifdef CONFIG_ARCH_MISC_INIT
-	arch_misc_init,		/* miscellaneous arch-dependent init */
+	/* miscellaneous arch-dependent init */
+#if CONFIG_IS_ENABLED(ARCH_MISC_INIT)
+	INITCALL(arch_misc_init);
 #endif
-#ifdef CONFIG_MISC_INIT_R
-	misc_init_r,		/* miscellaneous platform-dependent init */
+	/* miscellaneous platform-dependent init */
+#if CONFIG_IS_ENABLED(MISC_INIT_R)
+	INITCALL(misc_init_r);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
-#ifdef CONFIG_CMD_KGDB
-	kgdb_init,
+	WATCHDOG_RESET();
+#if CONFIG_IS_ENABLED(CMD_KGDB)
+	INITCALL(kgdb_init);
 #endif
-	interrupt_init,
+	INITCALL(interrupt_init);
 #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K)
-	timer_init,		/* initialize timer */
+	INITCALL(timer_init);		/* initialize timer */
 #endif
-	initr_status_led,
-	initr_boot_led_blink,
+	INITCALL(initr_status_led);
+	INITCALL(initr_boot_led_blink);
 	/* PPC has a udelay(20) here dating from 2002. Why? */
-#ifdef CONFIG_BOARD_LATE_INIT
-	board_late_init,
+#if CONFIG_IS_ENABLED(BOARD_LATE_INIT)
+	INITCALL(board_late_init);
 #endif
-#ifdef CONFIG_PCI_ENDPOINT
-	pci_ep_init,
+#if CONFIG_IS_ENABLED(PCI_ENDPOINT)
+	INITCALL(pci_ep_init);
 #endif
-#if defined(CONFIG_CMD_NET)
-	INIT_FUNC_WATCHDOG_RESET
-	initr_net,
+#if CONFIG_IS_ENABLED(CMD_NET)
+	WATCHDOG_RESET();
+	INITCALL(initr_net);
 #endif
-#ifdef CONFIG_POST
-	initr_post,
+#if CONFIG_IS_ENABLED(POST)
+	INITCALL(initr_post);
 #endif
-	INIT_FUNC_WATCHDOG_RESET
-	INITCALL_EVENT(EVT_LAST_STAGE_INIT),
+	WATCHDOG_RESET();
+	INITCALL_EVT(EVT_LAST_STAGE_INIT);
 #if defined(CFG_PRAM)
-	initr_mem,
+	INITCALL(initr_mem);
 #endif
-	initr_boot_led_on,
-	run_main_loop,
-};
+	INITCALL(initr_boot_led_on);
+	INITCALL(run_main_loop);
+}
 
 void board_init_r(gd_t *new_gd, ulong dest_addr)
 {
@@ -813,8 +819,7 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 #endif
 	gd->flags &= ~GD_FLG_LOG_READY;
 
-	if (initcall_run_list(init_sequence_r))
-		hang();
+	initcall_run_r();
 
 	/* NOTREACHED - run_main_loop() does not return */
 	hang();
diff --git a/include/initcall.h b/include/initcall.h
index 62d3bb67f08..8e22526dd9e 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -8,6 +8,7 @@
 
 #include <asm/types.h>
 #include <event.h>
+#include <hang.h>
 
 _Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits");
 
@@ -35,4 +36,30 @@ typedef int (*init_fnc_t)(void);
  */
 int initcall_run_list(const init_fnc_t init_sequence[]);
 
+#define INITCALL(_call) \
+	do { \
+		if (_call()) { \
+			printf("%s(): initcall %s() failed\n", __func__, \
+			       #_call); \
+			hang(); \
+		} \
+	} while (0)
+
+#define INITCALL_EVT(_evt) \
+	do { \
+		if (event_notify_null(_evt)) { \
+			printf("%s(): event %d/%s failed\n", __func__, _evt, \
+			       event_type_name(_evt)) ; \
+			hang(); \
+		} \
+	} while (0)
+
+#if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
+#define WATCHDOG_INIT() INITCALL(init_func_watchdog_init)
+#define WATCHDOG_RESET() INITCALL(init_func_watchdog_reset)
+#else
+#define WATCHDOG_INIT()
+#define WATCHDOG_RESET()
+#endif
+
 #endif
diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py
index 6ac1b225465..fcdcbe2c6db 100644
--- a/test/py/tests/test_trace.py
+++ b/test/py/tests/test_trace.py
@@ -201,7 +201,7 @@ def check_funcgraph(ubman, fname, proftool, map_fname, trace_dat):
     # Then look for this:
     #  u-boot-1     0.....   282.101375: funcgraph_exit:         0.006 us   |      }
     # Then check for this:
-    #  u-boot-1     0.....   282.101375: funcgraph_entry:        0.000 us   |    calc_reloc_ofs();
+    #  u-boot-1     0.....   282.101375: funcgraph_entry:        0.000 us   |    event_init();
 
     expected_indent = None
     found_start = False
@@ -224,8 +224,8 @@ def check_funcgraph(ubman, fname, proftool, map_fname, trace_dat):
                 found_end = True
 
     # The next function after initf_bootstage() exits should be
-    # initcall_is_event()
-    assert upto == 'calc_reloc_ofs()'
+    # event_init()
+    assert upto == 'event_init()'
 
     # Now look for initf_dm() and dm_timer_init() so we can check the bootstage
     # time
@@ -274,7 +274,7 @@ def check_flamegraph(ubman, fname, proftool, map_fname, trace_fg):
     # We expect dm_timer_init() to be called twice: once before relocation and
     # once after
     look1 = 'initf_dm;dm_timer_init 1'
-    look2 = 'board_init_r;initcall_run_list;initr_dm_devices;dm_timer_init 1'
+    look2 = 'board_init_r;initcall_run_r;initr_dm_devices;dm_timer_init 1'
     found = 0
     with open(trace_fg, 'r') as fd:
         for line in fd:
-- 
2.43.0


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

* [PATCH v6 3/3] initcall: remove initcall_run_list()
  2025-04-04 13:50 [PATCH v6 0/3] Static initcalls Jerome Forissier
  2025-04-04 13:50 ` [PATCH v6 1/3] arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set Jerome Forissier
  2025-04-04 13:50 ` [PATCH v6 2/3] common: board: make initcalls static Jerome Forissier
@ 2025-04-04 13:50 ` Jerome Forissier
  2025-04-14 20:07 ` [PATCH v6 0/3] Static initcalls Tom Rini
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 25+ messages in thread
From: Jerome Forissier @ 2025-04-04 13:50 UTC (permalink / raw)
  To: u-boot
  Cc: Ilias Apalodimas, Jerome Forissier, Tom Rini, Simon Glass,
	Raymond Mao, Mattijs Korpershoek, Philippe Reynes, Caleb Connolly

Now that all initcalls have been converted to static calls, remove
initcall_run_list().

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
---
 include/initcall.h |  24 -----------
 lib/Makefile       |   1 -
 lib/initcall.c     | 102 ---------------------------------------------
 3 files changed, 127 deletions(-)
 delete mode 100644 lib/initcall.c

diff --git a/include/initcall.h b/include/initcall.h
index 8e22526dd9e..220a55ad84d 100644
--- a/include/initcall.h
+++ b/include/initcall.h
@@ -12,30 +12,6 @@
 
 _Static_assert(EVT_COUNT < 256, "Can only support 256 event types with 8 bits");
 
-/**
- * init_fnc_t - Init function
- *
- * Return: 0 if OK -ve on error
- */
-typedef int (*init_fnc_t)(void);
-
-/* Top bit indicates that the initcall is an event */
-#define INITCALL_IS_EVENT	GENMASK(BITS_PER_LONG - 1, 8)
-#define INITCALL_EVENT_TYPE	GENMASK(7, 0)
-
-#define INITCALL_EVENT(_type)	(void *)((_type) | INITCALL_IS_EVENT)
-
-/**
- * initcall_run_list() - Run through a list of function calls
- *
- * This calls functions one after the other, stopping at the first error, or
- * when NULL is obtained.
- *
- * @init_sequence: NULL-terminated init sequence to run
- * Return: 0 if OK, or -ve error code from the first failure
- */
-int initcall_run_list(const init_fnc_t init_sequence[]);
-
 #define INITCALL(_call) \
 	do { \
 		if (_call()) { \
diff --git a/lib/Makefile b/lib/Makefile
index a30ce1595d5..072bd933843 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -43,7 +43,6 @@ endif
 
 obj-$(CONFIG_SMBIOS_PARSER) += smbios-parser.o
 obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
-obj-y += initcall.o
 obj-y += ldiv.o
 obj-$(CONFIG_XXHASH) += xxhash.o
 obj-y += net_utils.o
diff --git a/lib/initcall.c b/lib/initcall.c
deleted file mode 100644
index 2686b9aed5c..00000000000
--- a/lib/initcall.c
+++ /dev/null
@@ -1,102 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 2013 The Chromium OS Authors.
- */
-
-#include <efi.h>
-#include <initcall.h>
-#include <log.h>
-#include <relocate.h>
-#include <asm/global_data.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static ulong calc_reloc_ofs(void)
-{
-#ifdef CONFIG_EFI_APP
-	return (ulong)image_base;
-#endif
-	/*
-	 * Sandbox is relocated by the OS, so symbols always appear at
-	 * the relocated address.
-	 */
-	if (IS_ENABLED(CONFIG_SANDBOX) || (gd->flags & GD_FLG_RELOC))
-		return gd->reloc_off;
-
-	return 0;
-}
-
-/**
- * initcall_is_event() - Get the event number for an initcall
- *
- * func: Function pointer to check
- * Return: Event number, if this is an event, else 0
- */
-static int initcall_is_event(init_fnc_t func)
-{
-	ulong val = (ulong)func;
-
-	if ((val & INITCALL_IS_EVENT) == INITCALL_IS_EVENT)
-		return val & INITCALL_EVENT_TYPE;
-
-	return 0;
-}
-
-/*
- * To enable debugging. add #define DEBUG at the top of the including file.
- *
- * To find a symbol, use grep on u-boot.map
- */
-int initcall_run_list(const init_fnc_t init_sequence[])
-{
-	ulong reloc_ofs;
-	const init_fnc_t *ptr;
-	enum event_t type;
-	init_fnc_t func;
-	int ret = 0;
-
-	for (ptr = init_sequence; func = *ptr, func; ptr++) {
-		reloc_ofs = calc_reloc_ofs();
-		type = initcall_is_event(func);
-
-		if (type) {
-			if (!CONFIG_IS_ENABLED(EVENT))
-				continue;
-			debug("initcall: event %d/%s\n", type,
-			      event_type_name(type));
-		} else if (reloc_ofs) {
-			debug("initcall: %p (relocated to %p)\n",
-			      (char *)func - reloc_ofs, (char *)func);
-		} else {
-			debug("initcall: %p\n", (char *)func - reloc_ofs);
-		}
-
-		ret = type ? event_notify_null(type) : func();
-		if (ret)
-			break;
-	}
-
-	if (ret) {
-		if (CONFIG_IS_ENABLED(EVENT)) {
-			char buf[60];
-
-			/* don't worry about buf size as we are dying here */
-			if (type) {
-				sprintf(buf, "event %d/%s", type,
-					event_type_name(type));
-			} else {
-				sprintf(buf, "call %p",
-					(char *)func - reloc_ofs);
-			}
-
-			printf("initcall failed at %s (err=%dE)\n", buf, ret);
-		} else {
-			printf("initcall failed at call %p (err=%d)\n",
-			       (char *)func - reloc_ofs, ret);
-		}
-
-		return ret;
-	}
-
-	return 0;
-}
-- 
2.43.0


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

* Re: [PATCH v6 2/3] common: board: make initcalls static
  2025-04-04 13:50 ` [PATCH v6 2/3] common: board: make initcalls static Jerome Forissier
@ 2025-04-12 20:52   ` Marek Vasut
  2025-06-03 15:22   ` Simon Glass
  1 sibling, 0 replies; 25+ messages in thread
From: Marek Vasut @ 2025-04-12 20:52 UTC (permalink / raw)
  To: Jerome Forissier, u-boot
  Cc: Ilias Apalodimas, Nobuhiro Iwamatsu, Tom Rini, Simon Glass,
	Jonas Karlman, Raymond Mao, Evgeny Bachinin, Michal Simek,
	Christian Marangi, Mattijs Korpershoek, Caleb Connolly

On 4/4/25 3:50 PM, Jerome Forissier wrote:
> Change board_init_f(), board_init_f_r() and board_init_r() to make
> static calls instead of iterating over the init_sequence_f,
> init_sequence_f_r and init_sequence_r arrays, respectively. This makes
> the code a simpler (and even more so when initcall_run_list() is
> later removed) and it reduces the binary size as well. Tested with
> xilinx_zynqmp_kria_defconfig; bloat-o-meter results:
> 
> - With LTO
> add/remove: 106/196 grow/shrink: 10/28 up/down: 31548/-33829 (-2281)
> Total: Before=1070471, After=1068190, chg -0.21%
> - Without LTO
> add/remove: 0/54 grow/shrink: 3/0 up/down: 2322/-2832 (-510)
> Total: Before=1121723, After=1121213, chg -0.05%
> 
> Execution time does not change in a noticeable way.
> 
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
I don't want to block this, so this is fine by me.

Sorry for the extra delay.

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-04-04 13:50 [PATCH v6 0/3] Static initcalls Jerome Forissier
                   ` (2 preceding siblings ...)
  2025-04-04 13:50 ` [PATCH v6 3/3] initcall: remove initcall_run_list() Jerome Forissier
@ 2025-04-14 20:07 ` Tom Rini
  2025-04-29 21:52 ` [REGRESSION] " Marcel Ziswiler
  2025-07-04  2:33 ` Fabio Estevam
  5 siblings, 0 replies; 25+ messages in thread
From: Tom Rini @ 2025-04-14 20:07 UTC (permalink / raw)
  To: u-boot, Jerome Forissier; +Cc: Ilias Apalodimas

On Fri, 04 Apr 2025 15:50:34 +0200, Jerome Forissier wrote:

> This series replaces the dynamic initcalls (with function pointers) with
> static calls, and gets rid of initcall_run_list(), init_sequence_f,
> init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> 
> Execution time doesn't seem to change noticeably. There is no impact on
> the SPL.
> 
> [...]

Applied to u-boot/master, thanks!

[1/3] arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set
      commit: 6fe50e39508043f386fc1bd40bbc02b8a75c1940
[2/3] common: board: make initcalls static
      commit: 6c171f7a184cc2815b736c48aa6ac02367bbb67f
[3/3] initcall: remove initcall_run_list()
      commit: bbee3d41b33f5b8c88ae3707dc8af105acafdd55
-- 
Tom



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

* [REGRESSION] [PATCH v6 0/3] Static initcalls
  2025-04-04 13:50 [PATCH v6 0/3] Static initcalls Jerome Forissier
                   ` (3 preceding siblings ...)
  2025-04-14 20:07 ` [PATCH v6 0/3] Static initcalls Tom Rini
@ 2025-04-29 21:52 ` Marcel Ziswiler
  2025-04-30  7:11   ` [SPAM][REGRESSION] " Weijie Gao
  2025-04-30 13:54   ` [REGRESSION] " Simon Glass
  2025-07-04  2:33 ` Fabio Estevam
  5 siblings, 2 replies; 25+ messages in thread
From: Marcel Ziswiler @ 2025-04-29 21:52 UTC (permalink / raw)
  To: Jerome Forissier, u-boot
  Cc: Ilias Apalodimas, Jerome Forissier, Tom Rini, Stefan Roese,
	Andre Przywara, Peter Hoyes, Sam Protsenko, Simon Glass,
	Patrick Rudolph, Marek Vasut, Caleb Connolly

Hi Jerome

On Fri, 2025-04-04 at 15:50 +0200, Jerome Forissier wrote:
> This series replaces the dynamic initcalls (with function pointers) with
> static calls, and gets rid of initcall_run_list(), init_sequence_f,
> init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> 
> Execution time doesn't seem to change noticeably. There is no impact on
> the SPL.
> 
> The inline assembly fixes, although they look unrelated, are triggered
> on some platforms with LTO enabled. For example: kirkwood_defconfig.
> 
> CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514

This series seems to cause a regression on rock5b. E.g. on today's master:

=> pci enum
=> setenv ipaddr 192.168.10.2
=> ping 192.168.10.1
failed to initialize card: -12
failed to initialize card: -12
failed to initialize card: -12
failed to initialize card: -12
failed to initialize card: -12
failed to initialize card: -12
failed to initialize card: -12
failed to initialize card: -12
No ethernet found.
failed to initialize card: -12
failed to initialize card: -12
ping failed; host 192.168.10.1 is not alive

Seems the rtl8169 driver runs out of memory trying to allocate descriptors?

If I revert this series on top of today's master:

=> pci enum
=> setenv ipaddr 192.168.10.2
=> ping 192.168.10.1

Warning: eth_rtl8169 MAC addresses don't match:
Address in DT is		00:e0:4c:68:01:5a
Address in environment is	fe:b1:db:60:25:69
Using eth_rtl8169 device
host 192.168.10.1 is alive

I just completed the bisection and will now look into what exactly could be going on.

Any insights are much appreciated.

Thanks!

> Changes in v6:
> - Rebase on next branch
> 
> Changes in v5:
> - Fix mistake in initcall_run_r(): CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
> should have been !CONFIG_IS_ENABLED(...). As a result, several CI tests
> were failing. (Tom R.)
> - Restore fixes in test/py/tests/test_trace.py and arch/sh/lib/board.c
> which had unexpectedly disappeared from v4 and caused CI errors.
> - Fix CI error caused by wrong conditionals on the fix_fdt() call:
>   tools/buildman/buildman -o /tmp -seP powerpc
>   [...]
>   common/board_f.c:752:12: error: 'fix_fdt' defined but not used [-Werror=unused-function]
> - Add "arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set"
> to fix a build error with LTO detecting mcr/mrc instructions emitted in
> Thumb mode on a CPU that doesn't support it:
>   make sheevaplug_defconfig
>   make -j$(nproc) CROSS_COMPILE="ccache arm-linux-gnueabi-"
>   [...]
>     LTO     u-boot
>   {standard input}: Assembler messages:
>   {standard input}:9241: Error: selected processor does not support `mcr p15,1,r0,c15,c11,0' in Thumb mode
>   {standard input}:19196: Error: selected processor does not support `mrc p15,1,r3,c15,c1,0' in Thumb mode
>   {standard input}:19223: Error: selected processor does not support `mcr p15,1,r3,c15,c1,0' in Thumb mode
>   {standard input}:19241: Error: selected processor does not support `mrc p15,1,r3,c15,c1,0' in Thumb mode
>   {standard input}:19268: Error: selected processor does not support `mcr p15,1,r3,c15,c1,0' in Thumb mode
>   {standard input}:19286: Error: selected processor does not support `mrc p15,1,r3,c15,c1,0' in Thumb mode
>   {standard input}:19321: Error: selected processor does not support `mcr p15,1,r3,c15,c1,0' in Thumb mode
>   {standard input}:19341: Error: selected processor does not support `mrc p15,0,r3,c1,c0,0' in Thumb mode
>   {standard input}:19372: Error: selected processor does not support `mcr p15,0,r3,c1,c0,0' in Thumb mode
>   make[1]: *** [/tmp/ccu1wZWX.mk:11: /tmp/ccIab81n.ltrans3.ltrans.o] Error 1
> 
> Changes in v4:
> - Fold all changes to board_init_*() into a single patch
> - Use '#if CONFIG_IS_ENABLED(FOO) INITCALL(init_foo) #endif' instead of
> 'CONFIG_IS_ENABLED(FOO, (INITCALL(init_foo);));' (Caleb C., Simon G.).
> As a consequence, drop Michal's patch ("common: board: Simplify array
> with function pointers with CONFIG_IS_ENABLED").
> - Rebase on next
> 
> Changes in v3:
> - Use printf() rather than debug() to report initcall failures
> (Quentin S.)
> - initcall_run_f(): replace one erroneous call to WATCHDOG_INIT() with
> WATCHDOG_RESET() (Ilias A.)
> - Fix relocate_code() in arch/sh/lib/board.c to address CI failures with
> r2dplus (https://lists.denx.de/pipermail/u-boot/2025-January/576213.html)
> (Tom R.)
> - Add comments to initcall_run_f() and initcall_run_r() (Simon G.)
> 
> Changes in v2:
> - INTICALL() and INITCALL_EVT() now call hang() immediately on error
> - Fixed typo: s/intcall_run_f_r/initcall_run_f_r/
> 
> 
> Jerome Forissier (3):
>   arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set
>   common: board: make initcalls static
>   initcall: remove initcall_run_list()
> 
>  arch/arm/include/asm/system.h             |  22 +-
>  arch/arm/lib/cache.c                      |   5 +-
>  arch/arm/mach-kirkwood/include/mach/cpu.h |   9 +-
>  arch/sh/lib/board.c                       |   9 +-
>  common/board_f.c                          | 223 +++++++++----------
>  common/board_r.c                          | 247 +++++++++++-----------
>  include/initcall.h                        |  45 ++--
>  lib/Makefile                              |   1 -
>  lib/initcall.c                            | 102 ---------
>  test/py/tests/test_trace.py               |   8 +-
>  10 files changed, 295 insertions(+), 376 deletions(-)
>  delete mode 100644 lib/initcall.c

Cheers

Marcel

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

* Re: [SPAM][REGRESSION] [PATCH v6 0/3] Static initcalls
  2025-04-29 21:52 ` [REGRESSION] " Marcel Ziswiler
@ 2025-04-30  7:11   ` Weijie Gao
  2025-04-30  8:33     ` Marcel Ziswiler
  2025-04-30 13:54   ` [REGRESSION] " Simon Glass
  1 sibling, 1 reply; 25+ messages in thread
From: Weijie Gao @ 2025-04-30  7:11 UTC (permalink / raw)
  To: Marcel Ziswiler, Jerome Forissier, u-boot
  Cc: Ilias Apalodimas, Tom Rini, Stefan Roese, Andre Przywara,
	Peter Hoyes, Sam Protsenko, Simon Glass, Patrick Rudolph,
	Marek Vasut, Caleb Connolly

Hi Marcel,

This regression is also found with mtk_eth driver and I've sent a patch
to fix it:


https://patchwork.ozlabs.org/project/uboot/patch/20250429020424.48795-1-weijie.gao@mediatek.com/

This patch should also fix the regression on rtl8169 driver

BRs

Weijie

On Tue, 2025-04-29 at 23:52 +0200, Marcel Ziswiler wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Hi Jerome
> 
> On Fri, 2025-04-04 at 15:50 +0200, Jerome Forissier wrote:
> > This series replaces the dynamic initcalls (with function pointers)
> > with
> > static calls, and gets rid of initcall_run_list(), init_sequence_f,
> > init_sequence_f_r and init_sequence_r. This makes the code simpler
> > and the
> > binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and
> > -510
> > bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> > 
> > Execution time doesn't seem to change noticeably. There is no
> > impact on
> > the SPL.
> > 
> > The inline assembly fixes, although they look unrelated, are
> > triggered
> > on some platforms with LTO enabled. For example:
> > kirkwood_defconfig.
> > 
> > CI: 
> > https://urldefense.com/v3/__https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514__;!!CTRNKA9wMg0ARbw!h0Wu3dmAIj7GcAAl7DMcs-OyDvxKbcP6QQh7EuYYFMB-6OkCPTOUSbqHhuFZWzgImuvWUmPQMzSAwU-I9YiHvwbrcTzq_ymldg$
> 
> This series seems to cause a regression on rock5b. E.g. on today's
> master:
> 
> => pci enum
> => setenv ipaddr 192.168.10.2
> => ping 192.168.10.1
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> No ethernet found.
> failed to initialize card: -12
> failed to initialize card: -12
> ping failed; host 192.168.10.1 is not alive
> 
> Seems the rtl8169 driver runs out of memory trying to allocate
> descriptors?
> 
> If I revert this series on top of today's master:
> 
> => pci enum
> => setenv ipaddr 192.168.10.2
> => ping 192.168.10.1
> 
> Warning: eth_rtl8169 MAC addresses don't match:
> Address in DT is                00:e0:4c:68:01:5a
> Address in environment is       fe:b1:db:60:25:69
> Using eth_rtl8169 device
> host 192.168.10.1 is alive
> 
> I just completed the bisection and will now look into what exactly
> could be going on.
> 
> Any insights are much appreciated.
> 
> Thanks!
> 
> > Changes in v6:
> > - Rebase on next branch
> > 
> > Changes in v5:
> > - Fix mistake in initcall_run_r():
> > CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
> > should have been !CONFIG_IS_ENABLED(...). As a result, several CI
> > tests
> > were failing. (Tom R.)
> > - Restore fixes in test/py/tests/test_trace.py and
> > arch/sh/lib/board.c
> > which had unexpectedly disappeared from v4 and caused CI errors.
> > - Fix CI error caused by wrong conditionals on the fix_fdt() call:
> >   tools/buildman/buildman -o /tmp -seP powerpc
> >   [...]
> >   common/board_f.c:752:12: error: 'fix_fdt' defined but not used [-
> > Werror=unused-function]
> > - Add "arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is
> > not set"
> > to fix a build error with LTO detecting mcr/mrc instructions
> > emitted in
> > Thumb mode on a CPU that doesn't support it:
> >   make sheevaplug_defconfig
> >   make -j$(nproc) CROSS_COMPILE="ccache arm-linux-gnueabi-"
> >   [...]
> >     LTO     u-boot
> >   {standard input}: Assembler messages:
> >   {standard input}:9241: Error: selected processor does not support
> > `mcr p15,1,r0,c15,c11,0' in Thumb mode
> >   {standard input}:19196: Error: selected processor does not
> > support `mrc p15,1,r3,c15,c1,0' in Thumb mode
> >   {standard input}:19223: Error: selected processor does not
> > support `mcr p15,1,r3,c15,c1,0' in Thumb mode
> >   {standard input}:19241: Error: selected processor does not
> > support `mrc p15,1,r3,c15,c1,0' in Thumb mode
> >   {standard input}:19268: Error: selected processor does not
> > support `mcr p15,1,r3,c15,c1,0' in Thumb mode
> >   {standard input}:19286: Error: selected processor does not
> > support `mrc p15,1,r3,c15,c1,0' in Thumb mode
> >   {standard input}:19321: Error: selected processor does not
> > support `mcr p15,1,r3,c15,c1,0' in Thumb mode
> >   {standard input}:19341: Error: selected processor does not
> > support `mrc p15,0,r3,c1,c0,0' in Thumb mode
> >   {standard input}:19372: Error: selected processor does not
> > support `mcr p15,0,r3,c1,c0,0' in Thumb mode
> >   make[1]: *** [/tmp/ccu1wZWX.mk:11:
> > /tmp/ccIab81n.ltrans3.ltrans.o] Error 1
> > 
> > Changes in v4:
> > - Fold all changes to board_init_*() into a single patch
> > - Use '#if CONFIG_IS_ENABLED(FOO) INITCALL(init_foo) #endif'
> > instead of
> > 'CONFIG_IS_ENABLED(FOO, (INITCALL(init_foo);));' (Caleb C., Simon
> > G.).
> > As a consequence, drop Michal's patch ("common: board: Simplify
> > array
> > with function pointers with CONFIG_IS_ENABLED").
> > - Rebase on next
> > 
> > Changes in v3:
> > - Use printf() rather than debug() to report initcall failures
> > (Quentin S.)
> > - initcall_run_f(): replace one erroneous call to WATCHDOG_INIT()
> > with
> > WATCHDOG_RESET() (Ilias A.)
> > - Fix relocate_code() in arch/sh/lib/board.c to address CI failures
> > with
> > r2dplus (
> > https://urldefense.com/v3/__https://lists.denx.de/pipermail/u-boot/2025-January/576213.html__;!!CTRNKA9wMg0ARbw!h0Wu3dmAIj7GcAAl7DMcs-OyDvxKbcP6QQh7EuYYFMB-6OkCPTOUSbqHhuFZWzgImuvWUmPQMzSAwU-I9YiHvwbrcTyRLPlZiw$
> >  )
> > (Tom R.)
> > - Add comments to initcall_run_f() and initcall_run_r() (Simon G.)
> > 
> > Changes in v2:
> > - INTICALL() and INITCALL_EVT() now call hang() immediately on
> > error
> > - Fixed typo: s/intcall_run_f_r/initcall_run_f_r/
> > 
> > 
> > Jerome Forissier (3):
> >   arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set
> >   common: board: make initcalls static
> >   initcall: remove initcall_run_list()
> > 
> >  arch/arm/include/asm/system.h             |  22 +-
> >  arch/arm/lib/cache.c                      |   5 +-
> >  arch/arm/mach-kirkwood/include/mach/cpu.h |   9 +-
> >  arch/sh/lib/board.c                       |   9 +-
> >  common/board_f.c                          | 223 +++++++++---------
> > -
> >  common/board_r.c                          | 247 +++++++++++-------
> > ----
> >  include/initcall.h                        |  45 ++--
> >  lib/Makefile                              |   1 -
> >  lib/initcall.c                            | 102 ---------
> >  test/py/tests/test_trace.py               |   8 +-
> >  10 files changed, 295 insertions(+), 376 deletions(-)
> >  delete mode 100644 lib/initcall.c
> 
> Cheers
> 
> Marcel


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

* Re: [SPAM][REGRESSION] [PATCH v6 0/3] Static initcalls
  2025-04-30  7:11   ` [SPAM][REGRESSION] " Weijie Gao
@ 2025-04-30  8:33     ` Marcel Ziswiler
  0 siblings, 0 replies; 25+ messages in thread
From: Marcel Ziswiler @ 2025-04-30  8:33 UTC (permalink / raw)
  To: Weijie Gao, Jerome Forissier, u-boot
  Cc: Ilias Apalodimas, Tom Rini, Stefan Roese, Andre Przywara,
	Peter Hoyes, Sam Protsenko, Simon Glass, Patrick Rudolph,
	Marek Vasut, Caleb Connolly

Hi Weijie

On Wed, 2025-04-30 at 15:11 +0800, Weijie Gao wrote:
> Hi Marcel,
> 
> This regression is also found with mtk_eth driver and I've sent a patch
> to fix it:
> 
> 
> https://patchwork.ozlabs.org/project/uboot/patch/20250429020424.48795-1-weijie.gao@mediatek.com/
> 
> This patch should also fix the regression on rtl8169 driver

Yes, indeed. Thanks for spotting and fixing this :)

> BRs
> 
> Weijie
> 
> On Tue, 2025-04-29 at 23:52 +0200, Marcel Ziswiler wrote:
> > External email : Please do not click links or open attachments until
> > you have verified the sender or the content.
> > 
> > 
> > Hi Jerome
> > 
> > On Fri, 2025-04-04 at 15:50 +0200, Jerome Forissier wrote:
> > > This series replaces the dynamic initcalls (with function pointers)
> > > with
> > > static calls, and gets rid of initcall_run_list(), init_sequence_f,
> > > init_sequence_f_r and init_sequence_r. This makes the code simpler
> > > and the
> > > binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and
> > > -510
> > > bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> > > 
> > > Execution time doesn't seem to change noticeably. There is no
> > > impact on
> > > the SPL.
> > > 
> > > The inline assembly fixes, although they look unrelated, are
> > > triggered
> > > on some platforms with LTO enabled. For example:
> > > kirkwood_defconfig.
> > > 
> > > CI: 
> > > https://urldefense.com/v3/__https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514__;!!CTRNKA9wMg0ARbw!h0Wu3dmAIj7GcAAl7DMcs-OyDvxKbcP6QQh7EuYYFMB-6OkCPTOUSbqHhuFZWzgImuvWUmPQMzSAwU-I9YiHvwbrcTzq_ymldg$
> > 
> > This series seems to cause a regression on rock5b. E.g. on today's
> > master:
> > 
> > => pci enum
> > => setenv ipaddr 192.168.10.2
> > => ping 192.168.10.1
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > No ethernet found.
> > failed to initialize card: -12
> > failed to initialize card: -12
> > ping failed; host 192.168.10.1 is not alive
> > 
> > Seems the rtl8169 driver runs out of memory trying to allocate
> > descriptors?
> > 
> > If I revert this series on top of today's master:
> > 
> > => pci enum
> > => setenv ipaddr 192.168.10.2
> > => ping 192.168.10.1
> > 
> > Warning: eth_rtl8169 MAC addresses don't match:
> > Address in DT is                00:e0:4c:68:01:5a
> > Address in environment is       fe:b1:db:60:25:69
> > Using eth_rtl8169 device
> > host 192.168.10.1 is alive
> > 
> > I just completed the bisection and will now look into what exactly
> > could be going on.
> > 
> > Any insights are much appreciated.
> > 
> > Thanks!
> > 
> > > Changes in v6:
> > > - Rebase on next branch
> > > 
> > > Changes in v5:
> > > - Fix mistake in initcall_run_r():
> > > CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
> > > should have been !CONFIG_IS_ENABLED(...). As a result, several CI
> > > tests
> > > were failing. (Tom R.)
> > > - Restore fixes in test/py/tests/test_trace.py and
> > > arch/sh/lib/board.c
> > > which had unexpectedly disappeared from v4 and caused CI errors.
> > > - Fix CI error caused by wrong conditionals on the fix_fdt() call:
> > >   tools/buildman/buildman -o /tmp -seP powerpc
> > >   [...]
> > >   common/board_f.c:752:12: error: 'fix_fdt' defined but not used [-
> > > Werror=unused-function]
> > > - Add "arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is
> > > not set"
> > > to fix a build error with LTO detecting mcr/mrc instructions
> > > emitted in
> > > Thumb mode on a CPU that doesn't support it:
> > >   make sheevaplug_defconfig
> > >   make -j$(nproc) CROSS_COMPILE="ccache arm-linux-gnueabi-"
> > >   [...]
> > >     LTO     u-boot
> > >   {standard input}: Assembler messages:
> > >   {standard input}:9241: Error: selected processor does not support
> > > `mcr p15,1,r0,c15,c11,0' in Thumb mode
> > >   {standard input}:19196: Error: selected processor does not
> > > support `mrc p15,1,r3,c15,c1,0' in Thumb mode
> > >   {standard input}:19223: Error: selected processor does not
> > > support `mcr p15,1,r3,c15,c1,0' in Thumb mode
> > >   {standard input}:19241: Error: selected processor does not
> > > support `mrc p15,1,r3,c15,c1,0' in Thumb mode
> > >   {standard input}:19268: Error: selected processor does not
> > > support `mcr p15,1,r3,c15,c1,0' in Thumb mode
> > >   {standard input}:19286: Error: selected processor does not
> > > support `mrc p15,1,r3,c15,c1,0' in Thumb mode
> > >   {standard input}:19321: Error: selected processor does not
> > > support `mcr p15,1,r3,c15,c1,0' in Thumb mode
> > >   {standard input}:19341: Error: selected processor does not
> > > support `mrc p15,0,r3,c1,c0,0' in Thumb mode
> > >   {standard input}:19372: Error: selected processor does not
> > > support `mcr p15,0,r3,c1,c0,0' in Thumb mode
> > >   make[1]: *** [/tmp/ccu1wZWX.mk:11:
> > > /tmp/ccIab81n.ltrans3.ltrans.o] Error 1
> > > 
> > > Changes in v4:
> > > - Fold all changes to board_init_*() into a single patch
> > > - Use '#if CONFIG_IS_ENABLED(FOO) INITCALL(init_foo) #endif'
> > > instead of
> > > 'CONFIG_IS_ENABLED(FOO, (INITCALL(init_foo);));' (Caleb C., Simon
> > > G.).
> > > As a consequence, drop Michal's patch ("common: board: Simplify
> > > array
> > > with function pointers with CONFIG_IS_ENABLED").
> > > - Rebase on next
> > > 
> > > Changes in v3:
> > > - Use printf() rather than debug() to report initcall failures
> > > (Quentin S.)
> > > - initcall_run_f(): replace one erroneous call to WATCHDOG_INIT()
> > > with
> > > WATCHDOG_RESET() (Ilias A.)
> > > - Fix relocate_code() in arch/sh/lib/board.c to address CI failures
> > > with
> > > r2dplus (
> > > https://urldefense.com/v3/__https://lists.denx.de/pipermail/u-boot/2025-January/576213.html__;!!CTRNKA9wMg0ARbw!h0Wu3dmAIj7GcAAl7DMcs-OyDvxKbcP6QQh7EuYYFMB-6OkCPTOUSbqHhuFZWzgImuvWUmPQMzSAwU-I9YiHvwbrcTyRLPlZiw$
> > >  )
> > > (Tom R.)
> > > - Add comments to initcall_run_f() and initcall_run_r() (Simon G.)
> > > 
> > > Changes in v2:
> > > - INTICALL() and INITCALL_EVT() now call hang() immediately on
> > > error
> > > - Fixed typo: s/intcall_run_f_r/initcall_run_f_r/
> > > 
> > > 
> > > Jerome Forissier (3):
> > >   arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set
> > >   common: board: make initcalls static
> > >   initcall: remove initcall_run_list()
> > > 
> > >  arch/arm/include/asm/system.h             |  22 +-
> > >  arch/arm/lib/cache.c                      |   5 +-
> > >  arch/arm/mach-kirkwood/include/mach/cpu.h |   9 +-
> > >  arch/sh/lib/board.c                       |   9 +-
> > >  common/board_f.c                          | 223 +++++++++---------
> > > -
> > >  common/board_r.c                          | 247 +++++++++++-------
> > > ----
> > >  include/initcall.h                        |  45 ++--
> > >  lib/Makefile                              |   1 -
> > >  lib/initcall.c                            | 102 ---------
> > >  test/py/tests/test_trace.py               |   8 +-
> > >  10 files changed, 295 insertions(+), 376 deletions(-)
> > >  delete mode 100644 lib/initcall.c

Cheers

Marcel

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

* Re: [REGRESSION] [PATCH v6 0/3] Static initcalls
  2025-04-29 21:52 ` [REGRESSION] " Marcel Ziswiler
  2025-04-30  7:11   ` [SPAM][REGRESSION] " Weijie Gao
@ 2025-04-30 13:54   ` Simon Glass
  2025-04-30 14:15     ` Tom Rini
  1 sibling, 1 reply; 25+ messages in thread
From: Simon Glass @ 2025-04-30 13:54 UTC (permalink / raw)
  To: Marcel Ziswiler
  Cc: Jerome Forissier, u-boot, Ilias Apalodimas, Tom Rini,
	Stefan Roese, Andre Przywara, Peter Hoyes, Sam Protsenko,
	Patrick Rudolph, Marek Vasut, Caleb Connolly

Hi Tom,

On Tue, 29 Apr 2025 at 16:32, Marcel Ziswiler
<marcel.ziswiler@codethink.co.uk> wrote:
>
> Hi Jerome
>
> On Fri, 2025-04-04 at 15:50 +0200, Jerome Forissier wrote:
> > This series replaces the dynamic initcalls (with function pointers) with
> > static calls, and gets rid of initcall_run_list(), init_sequence_f,
> > init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> > binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> > bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> >
> > Execution time doesn't seem to change noticeably. There is no impact on
> > the SPL.
> >
> > The inline assembly fixes, although they look unrelated, are triggered
> > on some platforms with LTO enabled. For example: kirkwood_defconfig.
> >
> > CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
>
> This series seems to cause a regression on rock5b. E.g. on today's master:
>
> => pci enum
> => setenv ipaddr 192.168.10.2
> => ping 192.168.10.1
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> failed to initialize card: -12
> No ethernet found.
> failed to initialize card: -12
> failed to initialize card: -12
> ping failed; host 192.168.10.1 is not alive
>
> Seems the rtl8169 driver runs out of memory trying to allocate descriptors?
>
> If I revert this series on top of today's master:
>
> => pci enum
> => setenv ipaddr 192.168.10.2
> => ping 192.168.10.1
>
> Warning: eth_rtl8169 MAC addresses don't match:
> Address in DT is                00:e0:4c:68:01:5a
> Address in environment is       fe:b1:db:60:25:69
> Using eth_rtl8169 device
> host 192.168.10.1 is alive
>
> I just completed the bisection and will now look into what exactly could be going on.
>
> Any insights are much appreciated.
>
> Thanks!

I have one of these boards in my lab. Could you please apply the
pending lab patches, e.g. [1]? Also, can we get this board running
network tests?

Regards,
Simon

[1] https://patchwork.ozlabs.org/project/uboot/patch/20241218211020.742702-1-sjg@chromium.org/

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

* Re: [REGRESSION] [PATCH v6 0/3] Static initcalls
  2025-04-30 13:54   ` [REGRESSION] " Simon Glass
@ 2025-04-30 14:15     ` Tom Rini
  2025-04-30 15:00       ` Simon Glass
  0 siblings, 1 reply; 25+ messages in thread
From: Tom Rini @ 2025-04-30 14:15 UTC (permalink / raw)
  To: Simon Glass
  Cc: Marcel Ziswiler, Jerome Forissier, u-boot, Ilias Apalodimas,
	Stefan Roese, Andre Przywara, Peter Hoyes, Sam Protsenko,
	Patrick Rudolph, Marek Vasut, Caleb Connolly

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

On Wed, Apr 30, 2025 at 07:54:46AM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Tue, 29 Apr 2025 at 16:32, Marcel Ziswiler
> <marcel.ziswiler@codethink.co.uk> wrote:
> >
> > Hi Jerome
> >
> > On Fri, 2025-04-04 at 15:50 +0200, Jerome Forissier wrote:
> > > This series replaces the dynamic initcalls (with function pointers) with
> > > static calls, and gets rid of initcall_run_list(), init_sequence_f,
> > > init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> > > binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> > > bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> > >
> > > Execution time doesn't seem to change noticeably. There is no impact on
> > > the SPL.
> > >
> > > The inline assembly fixes, although they look unrelated, are triggered
> > > on some platforms with LTO enabled. For example: kirkwood_defconfig.
> > >
> > > CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
> >
> > This series seems to cause a regression on rock5b. E.g. on today's master:
> >
> > => pci enum
> > => setenv ipaddr 192.168.10.2
> > => ping 192.168.10.1
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > failed to initialize card: -12
> > No ethernet found.
> > failed to initialize card: -12
> > failed to initialize card: -12
> > ping failed; host 192.168.10.1 is not alive
> >
> > Seems the rtl8169 driver runs out of memory trying to allocate descriptors?
> >
> > If I revert this series on top of today's master:
> >
> > => pci enum
> > => setenv ipaddr 192.168.10.2
> > => ping 192.168.10.1
> >
> > Warning: eth_rtl8169 MAC addresses don't match:
> > Address in DT is                00:e0:4c:68:01:5a
> > Address in environment is       fe:b1:db:60:25:69
> > Using eth_rtl8169 device
> > host 192.168.10.1 is alive
> >
> > I just completed the bisection and will now look into what exactly could be going on.
> >
> > Any insights are much appreciated.
> >
> > Thanks!
> 
> I have one of these boards in my lab. Could you please apply the
> pending lab patches, e.g. [1]? Also, can we get this board running
> network tests?

Your lab patches sadly stopped applying, I think somewhere around where
you didn't comment on my feedback about needing to fix problems with how
modern i.MX platforms do/don't handle blobs, and also the "all" make
target.

-- 
Tom

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

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

* Re: [REGRESSION] [PATCH v6 0/3] Static initcalls
  2025-04-30 14:15     ` Tom Rini
@ 2025-04-30 15:00       ` Simon Glass
  2025-04-30 15:29         ` Tom Rini
  0 siblings, 1 reply; 25+ messages in thread
From: Simon Glass @ 2025-04-30 15:00 UTC (permalink / raw)
  To: Tom Rini
  Cc: Marcel Ziswiler, Jerome Forissier, u-boot, Ilias Apalodimas,
	Stefan Roese, Andre Przywara, Peter Hoyes, Sam Protsenko,
	Patrick Rudolph, Marek Vasut, Caleb Connolly

Hi Tom,

On Wed, 30 Apr 2025 at 08:15, Tom Rini <trini@konsulko.com> wrote:
>
> On Wed, Apr 30, 2025 at 07:54:46AM -0600, Simon Glass wrote:
> > Hi Tom,
> >
> > On Tue, 29 Apr 2025 at 16:32, Marcel Ziswiler
> > <marcel.ziswiler@codethink.co.uk> wrote:
> > >
> > > Hi Jerome
> > >
> > > On Fri, 2025-04-04 at 15:50 +0200, Jerome Forissier wrote:
> > > > This series replaces the dynamic initcalls (with function pointers) with
> > > > static calls, and gets rid of initcall_run_list(), init_sequence_f,
> > > > init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> > > > binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> > > > bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> > > >
> > > > Execution time doesn't seem to change noticeably. There is no impact on
> > > > the SPL.
> > > >
> > > > The inline assembly fixes, although they look unrelated, are triggered
> > > > on some platforms with LTO enabled. For example: kirkwood_defconfig.
> > > >
> > > > CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
> > >
> > > This series seems to cause a regression on rock5b. E.g. on today's master:
> > >
> > > => pci enum
> > > => setenv ipaddr 192.168.10.2
> > > => ping 192.168.10.1
> > > failed to initialize card: -12
> > > failed to initialize card: -12
> > > failed to initialize card: -12
> > > failed to initialize card: -12
> > > failed to initialize card: -12
> > > failed to initialize card: -12
> > > failed to initialize card: -12
> > > failed to initialize card: -12
> > > No ethernet found.
> > > failed to initialize card: -12
> > > failed to initialize card: -12
> > > ping failed; host 192.168.10.1 is not alive
> > >
> > > Seems the rtl8169 driver runs out of memory trying to allocate descriptors?
> > >
> > > If I revert this series on top of today's master:
> > >
> > > => pci enum
> > > => setenv ipaddr 192.168.10.2
> > > => ping 192.168.10.1
> > >
> > > Warning: eth_rtl8169 MAC addresses don't match:
> > > Address in DT is                00:e0:4c:68:01:5a
> > > Address in environment is       fe:b1:db:60:25:69
> > > Using eth_rtl8169 device
> > > host 192.168.10.1 is alive
> > >
> > > I just completed the bisection and will now look into what exactly could be going on.
> > >
> > > Any insights are much appreciated.
> > >
> > > Thanks!
> >
> > I have one of these boards in my lab. Could you please apply the
> > pending lab patches, e.g. [1]? Also, can we get this board running
> > network tests?
>
> Your lab patches sadly stopped applying, I think somewhere around where
> you didn't comment on my feedback about needing to fix problems with how
> modern i.MX platforms do/don't handle blobs, and also the "all" make
> target.

I believe it was when you didn't want to disable boards which don't
work (e.g. samus).

Still, any conflicts are trivial, so perhaps just apply them?

Regards,
SImon

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

* Re: [REGRESSION] [PATCH v6 0/3] Static initcalls
  2025-04-30 15:00       ` Simon Glass
@ 2025-04-30 15:29         ` Tom Rini
  0 siblings, 0 replies; 25+ messages in thread
From: Tom Rini @ 2025-04-30 15:29 UTC (permalink / raw)
  To: Simon Glass
  Cc: Marcel Ziswiler, Jerome Forissier, u-boot, Ilias Apalodimas,
	Stefan Roese, Andre Przywara, Peter Hoyes, Sam Protsenko,
	Patrick Rudolph, Marek Vasut, Caleb Connolly

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

On Wed, Apr 30, 2025 at 09:00:40AM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On Wed, 30 Apr 2025 at 08:15, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Wed, Apr 30, 2025 at 07:54:46AM -0600, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Tue, 29 Apr 2025 at 16:32, Marcel Ziswiler
> > > <marcel.ziswiler@codethink.co.uk> wrote:
> > > >
> > > > Hi Jerome
> > > >
> > > > On Fri, 2025-04-04 at 15:50 +0200, Jerome Forissier wrote:
> > > > > This series replaces the dynamic initcalls (with function pointers) with
> > > > > static calls, and gets rid of initcall_run_list(), init_sequence_f,
> > > > > init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> > > > > binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> > > > > bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> > > > >
> > > > > Execution time doesn't seem to change noticeably. There is no impact on
> > > > > the SPL.
> > > > >
> > > > > The inline assembly fixes, although they look unrelated, are triggered
> > > > > on some platforms with LTO enabled. For example: kirkwood_defconfig.
> > > > >
> > > > > CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
> > > >
> > > > This series seems to cause a regression on rock5b. E.g. on today's master:
> > > >
> > > > => pci enum
> > > > => setenv ipaddr 192.168.10.2
> > > > => ping 192.168.10.1
> > > > failed to initialize card: -12
> > > > failed to initialize card: -12
> > > > failed to initialize card: -12
> > > > failed to initialize card: -12
> > > > failed to initialize card: -12
> > > > failed to initialize card: -12
> > > > failed to initialize card: -12
> > > > failed to initialize card: -12
> > > > No ethernet found.
> > > > failed to initialize card: -12
> > > > failed to initialize card: -12
> > > > ping failed; host 192.168.10.1 is not alive
> > > >
> > > > Seems the rtl8169 driver runs out of memory trying to allocate descriptors?
> > > >
> > > > If I revert this series on top of today's master:
> > > >
> > > > => pci enum
> > > > => setenv ipaddr 192.168.10.2
> > > > => ping 192.168.10.1
> > > >
> > > > Warning: eth_rtl8169 MAC addresses don't match:
> > > > Address in DT is                00:e0:4c:68:01:5a
> > > > Address in environment is       fe:b1:db:60:25:69
> > > > Using eth_rtl8169 device
> > > > host 192.168.10.1 is alive
> > > >
> > > > I just completed the bisection and will now look into what exactly could be going on.
> > > >
> > > > Any insights are much appreciated.
> > > >
> > > > Thanks!
> > >
> > > I have one of these boards in my lab. Could you please apply the
> > > pending lab patches, e.g. [1]? Also, can we get this board running
> > > network tests?
> >
> > Your lab patches sadly stopped applying, I think somewhere around where
> > you didn't comment on my feedback about needing to fix problems with how
> > modern i.MX platforms do/don't handle blobs, and also the "all" make
> > target.
> 
> I believe it was when you didn't want to disable boards which don't
> work (e.g. samus).
> 
> Still, any conflicts are trivial, so perhaps just apply them?

Then I have to worry if the lab setup is working too. Please rebase them
to master, test and re-post.

-- 
Tom

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

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

* Re: [PATCH v6 2/3] common: board: make initcalls static
  2025-04-04 13:50 ` [PATCH v6 2/3] common: board: make initcalls static Jerome Forissier
  2025-04-12 20:52   ` Marek Vasut
@ 2025-06-03 15:22   ` Simon Glass
  2025-06-03 16:10     ` Tom Rini
  1 sibling, 1 reply; 25+ messages in thread
From: Simon Glass @ 2025-06-03 15:22 UTC (permalink / raw)
  To: Jerome Forissier
  Cc: u-boot, Ilias Apalodimas, Marek Vasut, Nobuhiro Iwamatsu,
	Tom Rini, Jonas Karlman, Raymond Mao, Evgeny Bachinin,
	Michal Simek, Christian Marangi, Mattijs Korpershoek,
	Caleb Connolly

Hi Jerome,

On Fri, 4 Apr 2025 at 07:50, Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> Change board_init_f(), board_init_f_r() and board_init_r() to make
> static calls instead of iterating over the init_sequence_f,
> init_sequence_f_r and init_sequence_r arrays, respectively. This makes
> the code a simpler (and even more so when initcall_run_list() is
> later removed) and it reduces the binary size as well. Tested with
> xilinx_zynqmp_kria_defconfig; bloat-o-meter results:
>
> - With LTO
> add/remove: 106/196 grow/shrink: 10/28 up/down: 31548/-33829 (-2281)
> Total: Before=1070471, After=1068190, chg -0.21%
> - Without LTO
> add/remove: 0/54 grow/shrink: 3/0 up/down: 2322/-2832 (-510)
> Total: Before=1121723, After=1121213, chg -0.05%
>
> Execution time does not change in a noticeable way.
>
> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> ---
>  arch/sh/lib/board.c         |   9 +-
>  common/board_f.c            | 223 ++++++++++++++++----------------
>  common/board_r.c            | 247 ++++++++++++++++++------------------
>  include/initcall.h          |  27 ++++
>  test/py/tests/test_trace.py |   8 +-
>  5 files changed, 273 insertions(+), 241 deletions(-)
>
[..]
> diff --git a/common/board_f.c b/common/board_f.c
> index baf98fb8ec8..a1bb8a01be5 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
[..]
> @@ -1049,8 +1056,8 @@ void board_init_f(ulong boot_flags)
>  /*
>   * For now this code is only used on x86.
>   *
> - * init_sequence_f_r is the list of init functions which are run when
> - * U-Boot is executing from Flash with a semi-limited 'C' environment.
> + * Run init functions which are run when U-Boot is executing from Flash with a
> + * semi-limited 'C' environment.
>   * The following limitations must be considered when implementing an
>   * '_f_r' function:
>   *  - 'static' variables are read-only
> @@ -1063,18 +1070,16 @@ void board_init_f(ulong boot_flags)
>   * NOTE: At present only x86 uses this route, but it is intended that
>   * all archs will move to this when generic relocation is implemented.
>   */
> -static const init_fnc_t init_sequence_f_r[] = {
> -#if !CONFIG_IS_ENABLED(X86_64)
> -       init_cache_f_r,
> +static void initcall_run_f_r(void)
> +{
> +#if CONFIG_IS_ENABLED(X86_64)

This is reversing the condition, which breaks link and coral in my lab.

> +       INITCALL(init_cache_f_r);
>  #endif
> -
> -       NULL,
> -};
> +}

Regards,
Simon

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

* Re: [PATCH v6 2/3] common: board: make initcalls static
  2025-06-03 15:22   ` Simon Glass
@ 2025-06-03 16:10     ` Tom Rini
  2025-06-04 13:10       ` Simon Glass
  0 siblings, 1 reply; 25+ messages in thread
From: Tom Rini @ 2025-06-03 16:10 UTC (permalink / raw)
  To: Simon Glass
  Cc: Jerome Forissier, u-boot, Ilias Apalodimas, Marek Vasut,
	Nobuhiro Iwamatsu, Jonas Karlman, Raymond Mao, Evgeny Bachinin,
	Michal Simek, Christian Marangi, Mattijs Korpershoek,
	Caleb Connolly

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

On Tue, Jun 03, 2025 at 09:22:01AM -0600, Simon Glass wrote:
> Hi Jerome,
> 
> On Fri, 4 Apr 2025 at 07:50, Jerome Forissier
> <jerome.forissier@linaro.org> wrote:
> >
> > Change board_init_f(), board_init_f_r() and board_init_r() to make
> > static calls instead of iterating over the init_sequence_f,
> > init_sequence_f_r and init_sequence_r arrays, respectively. This makes
> > the code a simpler (and even more so when initcall_run_list() is
> > later removed) and it reduces the binary size as well. Tested with
> > xilinx_zynqmp_kria_defconfig; bloat-o-meter results:
> >
> > - With LTO
> > add/remove: 106/196 grow/shrink: 10/28 up/down: 31548/-33829 (-2281)
> > Total: Before=1070471, After=1068190, chg -0.21%
> > - Without LTO
> > add/remove: 0/54 grow/shrink: 3/0 up/down: 2322/-2832 (-510)
> > Total: Before=1121723, After=1121213, chg -0.05%
> >
> > Execution time does not change in a noticeable way.
> >
> > Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> > ---
> >  arch/sh/lib/board.c         |   9 +-
> >  common/board_f.c            | 223 ++++++++++++++++----------------
> >  common/board_r.c            | 247 ++++++++++++++++++------------------
> >  include/initcall.h          |  27 ++++
> >  test/py/tests/test_trace.py |   8 +-
> >  5 files changed, 273 insertions(+), 241 deletions(-)
> >
> [..]
> > diff --git a/common/board_f.c b/common/board_f.c
> > index baf98fb8ec8..a1bb8a01be5 100644
> > --- a/common/board_f.c
> > +++ b/common/board_f.c
> [..]
> > @@ -1049,8 +1056,8 @@ void board_init_f(ulong boot_flags)
> >  /*
> >   * For now this code is only used on x86.
> >   *
> > - * init_sequence_f_r is the list of init functions which are run when
> > - * U-Boot is executing from Flash with a semi-limited 'C' environment.
> > + * Run init functions which are run when U-Boot is executing from Flash with a
> > + * semi-limited 'C' environment.
> >   * The following limitations must be considered when implementing an
> >   * '_f_r' function:
> >   *  - 'static' variables are read-only
> > @@ -1063,18 +1070,16 @@ void board_init_f(ulong boot_flags)
> >   * NOTE: At present only x86 uses this route, but it is intended that
> >   * all archs will move to this when generic relocation is implemented.
> >   */
> > -static const init_fnc_t init_sequence_f_r[] = {
> > -#if !CONFIG_IS_ENABLED(X86_64)
> > -       init_cache_f_r,
> > +static void initcall_run_f_r(void)
> > +{
> > +#if CONFIG_IS_ENABLED(X86_64)
> 
> This is reversing the condition, which breaks link and coral in my lab.
> 
> > +       INITCALL(init_cache_f_r);

The most helpful thing to do here would be to post a patch correcting
the logic and providing a Fixes tag, thanks.

-- 
Tom

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

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

* Re: [PATCH v6 2/3] common: board: make initcalls static
  2025-06-03 16:10     ` Tom Rini
@ 2025-06-04 13:10       ` Simon Glass
  0 siblings, 0 replies; 25+ messages in thread
From: Simon Glass @ 2025-06-04 13:10 UTC (permalink / raw)
  To: Tom Rini
  Cc: Jerome Forissier, u-boot, Ilias Apalodimas, Marek Vasut,
	Nobuhiro Iwamatsu, Jonas Karlman, Raymond Mao, Evgeny Bachinin,
	Michal Simek, Christian Marangi, Mattijs Korpershoek,
	Caleb Connolly

Hi Tom,

On Tue, 3 Jun 2025 at 10:10, Tom Rini <trini@konsulko.com> wrote:
>
> On Tue, Jun 03, 2025 at 09:22:01AM -0600, Simon Glass wrote:
> > Hi Jerome,
> >
> > On Fri, 4 Apr 2025 at 07:50, Jerome Forissier
> > <jerome.forissier@linaro.org> wrote:
> > >
> > > Change board_init_f(), board_init_f_r() and board_init_r() to make
> > > static calls instead of iterating over the init_sequence_f,
> > > init_sequence_f_r and init_sequence_r arrays, respectively. This makes
> > > the code a simpler (and even more so when initcall_run_list() is
> > > later removed) and it reduces the binary size as well. Tested with
> > > xilinx_zynqmp_kria_defconfig; bloat-o-meter results:
> > >
> > > - With LTO
> > > add/remove: 106/196 grow/shrink: 10/28 up/down: 31548/-33829 (-2281)
> > > Total: Before=1070471, After=1068190, chg -0.21%
> > > - Without LTO
> > > add/remove: 0/54 grow/shrink: 3/0 up/down: 2322/-2832 (-510)
> > > Total: Before=1121723, After=1121213, chg -0.05%
> > >
> > > Execution time does not change in a noticeable way.
> > >
> > > Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
> > > ---
> > >  arch/sh/lib/board.c         |   9 +-
> > >  common/board_f.c            | 223 ++++++++++++++++----------------
> > >  common/board_r.c            | 247 ++++++++++++++++++------------------
> > >  include/initcall.h          |  27 ++++
> > >  test/py/tests/test_trace.py |   8 +-
> > >  5 files changed, 273 insertions(+), 241 deletions(-)
> > >
> > [..]
> > > diff --git a/common/board_f.c b/common/board_f.c
> > > index baf98fb8ec8..a1bb8a01be5 100644
> > > --- a/common/board_f.c
> > > +++ b/common/board_f.c
> > [..]
> > > @@ -1049,8 +1056,8 @@ void board_init_f(ulong boot_flags)
> > >  /*
> > >   * For now this code is only used on x86.
> > >   *
> > > - * init_sequence_f_r is the list of init functions which are run when
> > > - * U-Boot is executing from Flash with a semi-limited 'C' environment.
> > > + * Run init functions which are run when U-Boot is executing from Flash with a
> > > + * semi-limited 'C' environment.
> > >   * The following limitations must be considered when implementing an
> > >   * '_f_r' function:
> > >   *  - 'static' variables are read-only
> > > @@ -1063,18 +1070,16 @@ void board_init_f(ulong boot_flags)
> > >   * NOTE: At present only x86 uses this route, but it is intended that
> > >   * all archs will move to this when generic relocation is implemented.
> > >   */
> > > -static const init_fnc_t init_sequence_f_r[] = {
> > > -#if !CONFIG_IS_ENABLED(X86_64)
> > > -       init_cache_f_r,
> > > +static void initcall_run_f_r(void)
> > > +{
> > > +#if CONFIG_IS_ENABLED(X86_64)
> >
> > This is reversing the condition, which breaks link and coral in my lab.
> >
> > > +       INITCALL(init_cache_f_r);
>
> The most helpful thing to do here would be to post a patch correcting
> the logic and providing a Fixes tag, thanks.

Sure I can do that. I also seems that quite a few #if macros could
change to if().

Regards,
Simon

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-04-04 13:50 [PATCH v6 0/3] Static initcalls Jerome Forissier
                   ` (4 preceding siblings ...)
  2025-04-29 21:52 ` [REGRESSION] " Marcel Ziswiler
@ 2025-07-04  2:33 ` Fabio Estevam
  2025-07-04  2:34   ` Fabio Estevam
  5 siblings, 1 reply; 25+ messages in thread
From: Fabio Estevam @ 2025-07-04  2:33 UTC (permalink / raw)
  To: Jerome Forissier; +Cc: u-boot, Ilias Apalodimas, Otavio Salvador, dl-uboot-imx

Hi Jerome and Tom,

On Fri, Apr 4, 2025 at 10:51 AM Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> This series replaces the dynamic initcalls (with function pointers) with
> static calls, and gets rid of initcall_run_list(), init_sequence_f,
> init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
>
> Execution time doesn't seem to change noticeably. There is no impact on
> the SPL.
>
> The inline assembly fixes, although they look unrelated, are triggered
> on some platforms with LTO enabled. For example: kirkwood_defconfig.
>
> CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
>
> Changes in v6:
> - Rebase on next branch

This series breaks the boot on an imx6dl sabresd board (mx6sabresd_defconfig):

U-Boot SPL 2025.04-01075-g3c9c3d852e00 (Jul 03 2025 - 23:23:12 -0300)
Trying to boot from MMC1

(Hangs here)

I ran a git bisect from 2025.04 to master, and that was the result:

8c98b57d72d5e5b94ed064fe1041e51216165334 is the first bad commit
commit 8c98b57d72d5e5b94ed064fe1041e51216165334
Merge: 739ad58dbee8 bbee3d41b33f
Author: Tom Rini <trini@konsulko.com>
Date:   Mon Apr 14 08:59:45 2025 -0600

    Merge patch series "Static initcalls"

    Jerome Forissier <jerome.forissier@linaro.org> says:

    This series replaces the dynamic initcalls (with function pointers) with
    static calls, and gets rid of initcall_run_list(), init_sequence_f,
    init_sequence_f_r and init_sequence_r. This makes the code simpler and the
    binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
    bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).

    Execution time doesn't seem to change noticeably. There is no impact on
    the SPL.

    The inline assembly fixes, although they look unrelated, are triggered
    on some platforms with LTO enabled. For example: kirkwood_defconfig.

    CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514

    Link: https://lore.kernel.org/r/20250404135038.2134570-1-jerome.forissier@linaro.org

 arch/arm/include/asm/system.h             |  22 ++-
 arch/arm/lib/cache.c                      |   5 +-
 arch/arm/mach-kirkwood/include/mach/cpu.h |   9 +-
 arch/sh/lib/board.c                       |   9 +-
 common/board_f.c                          | 223 ++++++++++++++-------------
 common/board_r.c                          | 247 +++++++++++++++---------------
 include/initcall.h                        |  49 +++---
 lib/Makefile                              |   1 -
 lib/initcall.c                            | 102 ------------
 test/py/tests/test_trace.py               |   8 +-
 10 files changed, 297 insertions(+), 378 deletions(-)
 delete mode 100644 lib/initcall.c

Any ideas?

Thanks

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-07-04  2:33 ` Fabio Estevam
@ 2025-07-04  2:34   ` Fabio Estevam
  2025-07-04  8:33     ` Jerome Forissier
  0 siblings, 1 reply; 25+ messages in thread
From: Fabio Estevam @ 2025-07-04  2:34 UTC (permalink / raw)
  To: Jerome Forissier, Tom Rini
  Cc: u-boot, Ilias Apalodimas, Otavio Salvador, dl-uboot-imx

Adding Tom.

On Thu, Jul 3, 2025 at 11:33 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> Hi Jerome and Tom,
>
> On Fri, Apr 4, 2025 at 10:51 AM Jerome Forissier
> <jerome.forissier@linaro.org> wrote:
> >
> > This series replaces the dynamic initcalls (with function pointers) with
> > static calls, and gets rid of initcall_run_list(), init_sequence_f,
> > init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> > binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> > bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> >
> > Execution time doesn't seem to change noticeably. There is no impact on
> > the SPL.
> >
> > The inline assembly fixes, although they look unrelated, are triggered
> > on some platforms with LTO enabled. For example: kirkwood_defconfig.
> >
> > CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
> >
> > Changes in v6:
> > - Rebase on next branch
>
> This series breaks the boot on an imx6dl sabresd board (mx6sabresd_defconfig):
>
> U-Boot SPL 2025.04-01075-g3c9c3d852e00 (Jul 03 2025 - 23:23:12 -0300)
> Trying to boot from MMC1
>
> (Hangs here)
>
> I ran a git bisect from 2025.04 to master, and that was the result:
>
> 8c98b57d72d5e5b94ed064fe1041e51216165334 is the first bad commit
> commit 8c98b57d72d5e5b94ed064fe1041e51216165334
> Merge: 739ad58dbee8 bbee3d41b33f
> Author: Tom Rini <trini@konsulko.com>
> Date:   Mon Apr 14 08:59:45 2025 -0600
>
>     Merge patch series "Static initcalls"
>
>     Jerome Forissier <jerome.forissier@linaro.org> says:
>
>     This series replaces the dynamic initcalls (with function pointers) with
>     static calls, and gets rid of initcall_run_list(), init_sequence_f,
>     init_sequence_f_r and init_sequence_r. This makes the code simpler and the
>     binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
>     bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
>
>     Execution time doesn't seem to change noticeably. There is no impact on
>     the SPL.
>
>     The inline assembly fixes, although they look unrelated, are triggered
>     on some platforms with LTO enabled. For example: kirkwood_defconfig.
>
>     CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
>
>     Link: https://lore.kernel.org/r/20250404135038.2134570-1-jerome.forissier@linaro.org
>
>  arch/arm/include/asm/system.h             |  22 ++-
>  arch/arm/lib/cache.c                      |   5 +-
>  arch/arm/mach-kirkwood/include/mach/cpu.h |   9 +-
>  arch/sh/lib/board.c                       |   9 +-
>  common/board_f.c                          | 223 ++++++++++++++-------------
>  common/board_r.c                          | 247 +++++++++++++++---------------
>  include/initcall.h                        |  49 +++---
>  lib/Makefile                              |   1 -
>  lib/initcall.c                            | 102 ------------
>  test/py/tests/test_trace.py               |   8 +-
>  10 files changed, 297 insertions(+), 378 deletions(-)
>  delete mode 100644 lib/initcall.c
>
> Any ideas?
>
> Thanks

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-07-04  2:34   ` Fabio Estevam
@ 2025-07-04  8:33     ` Jerome Forissier
  2025-07-04  8:37       ` Michael Nazzareno Trimarchi
  2025-07-04 11:37       ` Fabio Estevam
  0 siblings, 2 replies; 25+ messages in thread
From: Jerome Forissier @ 2025-07-04  8:33 UTC (permalink / raw)
  To: Fabio Estevam, Tom Rini
  Cc: u-boot, Ilias Apalodimas, Otavio Salvador, dl-uboot-imx

Hi Fabio,

On 7/4/25 04:34, Fabio Estevam wrote:
> Adding Tom.
> 
> On Thu, Jul 3, 2025 at 11:33 PM Fabio Estevam <festevam@gmail.com> wrote:
>>
>> Hi Jerome and Tom,
>>
>> On Fri, Apr 4, 2025 at 10:51 AM Jerome Forissier
>> <jerome.forissier@linaro.org> wrote:
>>>
>>> This series replaces the dynamic initcalls (with function pointers) with
>>> static calls, and gets rid of initcall_run_list(), init_sequence_f,
>>> init_sequence_f_r and init_sequence_r. This makes the code simpler and the
>>> binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
>>> bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
>>>
>>> Execution time doesn't seem to change noticeably. There is no impact on
>>> the SPL.
>>>
>>> The inline assembly fixes, although they look unrelated, are triggered
>>> on some platforms with LTO enabled. For example: kirkwood_defconfig.
>>>
>>> CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
>>>
>>> Changes in v6:
>>> - Rebase on next branch
>>
>> This series breaks the boot on an imx6dl sabresd board (mx6sabresd_defconfig):
>>
>> U-Boot SPL 2025.04-01075-g3c9c3d852e00 (Jul 03 2025 - 23:23:12 -0300)
>> Trying to boot from MMC1
>>
>> (Hangs here)
>>
>> I ran a git bisect from 2025.04 to master, and that was the result:
>>
>> 8c98b57d72d5e5b94ed064fe1041e51216165334 is the first bad commit
>> commit 8c98b57d72d5e5b94ed064fe1041e51216165334
>> Merge: 739ad58dbee8 bbee3d41b33f
>> Author: Tom Rini <trini@konsulko.com>
>> Date:   Mon Apr 14 08:59:45 2025 -0600
>>
>>     Merge patch series "Static initcalls"
>>
>>     Jerome Forissier <jerome.forissier@linaro.org> says:
>>
>>     This series replaces the dynamic initcalls (with function pointers) with
>>     static calls, and gets rid of initcall_run_list(), init_sequence_f,
>>     init_sequence_f_r and init_sequence_r. This makes the code simpler and the
>>     binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
>>     bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
>>
>>     Execution time doesn't seem to change noticeably. There is no impact on
>>     the SPL.
>>
>>     The inline assembly fixes, although they look unrelated, are triggered
>>     on some platforms with LTO enabled. For example: kirkwood_defconfig.
>>
>>     CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
>>
>>     Link: https://lore.kernel.org/r/20250404135038.2134570-1-jerome.forissier@linaro.org
>>
>>  arch/arm/include/asm/system.h             |  22 ++-
>>  arch/arm/lib/cache.c                      |   5 +-
>>  arch/arm/mach-kirkwood/include/mach/cpu.h |   9 +-
>>  arch/sh/lib/board.c                       |   9 +-
>>  common/board_f.c                          | 223 ++++++++++++++-------------
>>  common/board_r.c                          | 247 +++++++++++++++---------------
>>  include/initcall.h                        |  49 +++---
>>  lib/Makefile                              |   1 -
>>  lib/initcall.c                            | 102 ------------
>>  test/py/tests/test_trace.py               |   8 +-
>>  10 files changed, 297 insertions(+), 378 deletions(-)
>>  delete mode 100644 lib/initcall.c
>>
>> Any ideas?

Have you tried the master branch recently? Hopefully commit 410d59095a9f
("arm: kirkwood: fix freeze on boot") should fix the issue.

Thanks,
-- 
Jerome

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-07-04  8:33     ` Jerome Forissier
@ 2025-07-04  8:37       ` Michael Nazzareno Trimarchi
  2025-07-04 13:33         ` Fabio Estevam
  2025-07-04 11:37       ` Fabio Estevam
  1 sibling, 1 reply; 25+ messages in thread
From: Michael Nazzareno Trimarchi @ 2025-07-04  8:37 UTC (permalink / raw)
  To: Jerome Forissier
  Cc: Fabio Estevam, Tom Rini, u-boot, Ilias Apalodimas,
	Otavio Salvador, dl-uboot-imx

Hi all

On Fri, Jul 4, 2025 at 10:33 AM Jerome Forissier
<jerome.forissier@linaro.org> wrote:
>
> Hi Fabio,
>
> On 7/4/25 04:34, Fabio Estevam wrote:
> > Adding Tom.
> >
> > On Thu, Jul 3, 2025 at 11:33 PM Fabio Estevam <festevam@gmail.com> wrote:
> >>
> >> Hi Jerome and Tom,
> >>
> >> On Fri, Apr 4, 2025 at 10:51 AM Jerome Forissier
> >> <jerome.forissier@linaro.org> wrote:
> >>>
> >>> This series replaces the dynamic initcalls (with function pointers) with
> >>> static calls, and gets rid of initcall_run_list(), init_sequence_f,
> >>> init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> >>> binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> >>> bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> >>>
> >>> Execution time doesn't seem to change noticeably. There is no impact on
> >>> the SPL.
> >>>
> >>> The inline assembly fixes, although they look unrelated, are triggered
> >>> on some platforms with LTO enabled. For example: kirkwood_defconfig.
> >>>
> >>> CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
> >>>
> >>> Changes in v6:
> >>> - Rebase on next branch
> >>
> >> This series breaks the boot on an imx6dl sabresd board (mx6sabresd_defconfig):
> >>
> >> U-Boot SPL 2025.04-01075-g3c9c3d852e00 (Jul 03 2025 - 23:23:12 -0300)
> >> Trying to boot from MMC1
> >>
> >> (Hangs here)
> >>
> >> I ran a git bisect from 2025.04 to master, and that was the result:
> >>
> >> 8c98b57d72d5e5b94ed064fe1041e51216165334 is the first bad commit
> >> commit 8c98b57d72d5e5b94ed064fe1041e51216165334
> >> Merge: 739ad58dbee8 bbee3d41b33f
> >> Author: Tom Rini <trini@konsulko.com>
> >> Date:   Mon Apr 14 08:59:45 2025 -0600
> >>
> >>     Merge patch series "Static initcalls"
> >>
> >>     Jerome Forissier <jerome.forissier@linaro.org> says:
> >>
> >>     This series replaces the dynamic initcalls (with function pointers) with
> >>     static calls, and gets rid of initcall_run_list(), init_sequence_f,
> >>     init_sequence_f_r and init_sequence_r. This makes the code simpler and the
> >>     binary slighlty smaller: -2281 bytes/-0.21 % with LTO enabled and -510
> >>     bytes/-0.05 % with LTO disabled (xilinx_zynqmp_kria_defconfig).
> >>
> >>     Execution time doesn't seem to change noticeably. There is no impact on
> >>     the SPL.
> >>
> >>     The inline assembly fixes, although they look unrelated, are triggered
> >>     on some platforms with LTO enabled. For example: kirkwood_defconfig.
> >>
> >>     CI: https://source.denx.de/u-boot/custodians/u-boot-net/-/pipelines/25514
> >>
> >>     Link: https://lore.kernel.org/r/20250404135038.2134570-1-jerome.forissier@linaro.org
> >>
> >>  arch/arm/include/asm/system.h             |  22 ++-
> >>  arch/arm/lib/cache.c                      |   5 +-
> >>  arch/arm/mach-kirkwood/include/mach/cpu.h |   9 +-
> >>  arch/sh/lib/board.c                       |   9 +-
> >>  common/board_f.c                          | 223 ++++++++++++++-------------
> >>  common/board_r.c                          | 247 +++++++++++++++---------------
> >>  include/initcall.h                        |  49 +++---
> >>  lib/Makefile                              |   1 -
> >>  lib/initcall.c                            | 102 ------------
> >>  test/py/tests/test_trace.py               |   8 +-
> >>  10 files changed, 297 insertions(+), 378 deletions(-)
> >>  delete mode 100644 lib/initcall.c
> >>
> >> Any ideas?
>
> Have you tried the master branch recently? Hopefully commit 410d59095a9f
> ("arm: kirkwood: fix freeze on boot") should fix the issue.
>

We have problems that our board crashes with display enabled when this
series is applied but we can boot
if the series is reverted. We are still try to understand what is going on

Michael

> Thanks,
> --
> Jerome



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-07-04  8:33     ` Jerome Forissier
  2025-07-04  8:37       ` Michael Nazzareno Trimarchi
@ 2025-07-04 11:37       ` Fabio Estevam
  2025-07-04 12:02         ` Jerome Forissier
  1 sibling, 1 reply; 25+ messages in thread
From: Fabio Estevam @ 2025-07-04 11:37 UTC (permalink / raw)
  To: Jerome Forissier
  Cc: Tom Rini, u-boot, Ilias Apalodimas, Otavio Salvador, dl-uboot-imx

Hi Jerome,

On Fri, Jul 4, 2025 at 5:33 AM Jerome Forissier
<jerome.forissier@linaro.org> wrote:

> Have you tried the master branch recently? Hopefully commit 410d59095a9f
> ("arm: kirkwood: fix freeze on boot") should fix the issue.

Yes, I'm using top-of-tree U-Boot, and this commit is present.

Unfortunately, it does not help.

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-07-04 11:37       ` Fabio Estevam
@ 2025-07-04 12:02         ` Jerome Forissier
  2025-07-04 12:22           ` Fabio Estevam
  0 siblings, 1 reply; 25+ messages in thread
From: Jerome Forissier @ 2025-07-04 12:02 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Tom Rini, u-boot, Ilias Apalodimas, Otavio Salvador, dl-uboot-imx



On 7/4/25 13:37, Fabio Estevam wrote:
> Hi Jerome,
> 
> On Fri, Jul 4, 2025 at 5:33 AM Jerome Forissier
> <jerome.forissier@linaro.org> wrote:
> 
>> Have you tried the master branch recently? Hopefully commit 410d59095a9f
>> ("arm: kirkwood: fix freeze on boot") should fix the issue.
> 
> Yes, I'm using top-of-tree U-Boot, and this commit is present.
> 
> Unfortunately, it does not help.

OK. Then I suggest adding a debug traces to the INITCALL() macro to see
how far the init goes.

Thanks,
-- 
Jerome

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-07-04 12:02         ` Jerome Forissier
@ 2025-07-04 12:22           ` Fabio Estevam
  0 siblings, 0 replies; 25+ messages in thread
From: Fabio Estevam @ 2025-07-04 12:22 UTC (permalink / raw)
  To: Jerome Forissier
  Cc: Tom Rini, u-boot, Ilias Apalodimas, Otavio Salvador, dl-uboot-imx

On Fri, Jul 4, 2025 at 9:02 AM Jerome Forissier
<jerome.forissier@linaro.org> wrote:

> OK. Then I suggest adding a debug traces to the INITCALL() macro to see
> how far the init goes.

I added some debug traces inside the INITCALL() macro, but when it
hangs in SPL, no output is seen.

There's something very fragile: depending on what is removed from the
defconfig, the board can boot or not.

For example, by removing the following lines, the board boots:

--- a/configs/mx6sabresd_defconfig
+++ b/configs/mx6sabresd_defconfig
@@ -73,11 +73,6 @@ CONFIG_SYS_MMC_ENV_DEV=1
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
 CONFIG_ARP_TIMEOUT=200
 CONFIG_BOUNCE_BUFFER=y
-CONFIG_USB_FUNCTION_FASTBOOT=y
-CONFIG_FASTBOOT_BUF_ADDR=0x12000000
-CONFIG_FASTBOOT_BUF_SIZE=0x10000000
-CONFIG_FASTBOOT_FLASH=y
-CONFIG_FASTBOOT_FLASH_MMC_DEV=2
 CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_MXC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
@@ -111,8 +106,6 @@ CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
 CONFIG_SPL_USB_HOST=y
-CONFIG_USB_HOST_ETHER=y
-CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
 CONFIG_SPL_USB_GADGET=y
 CONFIG_USB_GADGET_MANUFACTURER="FSL"

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-07-04  8:37       ` Michael Nazzareno Trimarchi
@ 2025-07-04 13:33         ` Fabio Estevam
  2025-07-05 10:01           ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 25+ messages in thread
From: Fabio Estevam @ 2025-07-04 13:33 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi
  Cc: Jerome Forissier, Tom Rini, u-boot, Ilias Apalodimas,
	Otavio Salvador, dl-uboot-imx

Hi Michael,

On Fri, Jul 4, 2025 at 5:37 AM Michael Nazzareno Trimarchi
<michael@amarulasolutions.com> wrote:

> We have problems that our board crashes with display enabled when this
> series is applied but we can boot
> if the series is reverted. We are still try to understand what is going on

What is the defconfig you are using?

Does the crash happen in the SPL or U-Boot?

Please share the logs and more details.

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

* Re: [PATCH v6 0/3] Static initcalls
  2025-07-04 13:33         ` Fabio Estevam
@ 2025-07-05 10:01           ` Michael Nazzareno Trimarchi
  0 siblings, 0 replies; 25+ messages in thread
From: Michael Nazzareno Trimarchi @ 2025-07-05 10:01 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Jerome Forissier, Tom Rini, u-boot, Ilias Apalodimas,
	Otavio Salvador, dl-uboot-imx

Hi

On Fri, Jul 4, 2025 at 3:33 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> Hi Michael,
>
> On Fri, Jul 4, 2025 at 5:37 AM Michael Nazzareno Trimarchi
> <michael@amarulasolutions.com> wrote:
>
> > We have problems that our board crashes with display enabled when this
> > series is applied but we can boot
> > if the series is reverted. We are still try to understand what is going on
>
> What is the defconfig you are using?
>

If everything working on your side, I will check the code that is
added to our board.

> Does the crash happen in the SPL or U-Boot?

u-boot clock subsystem consistently. Change a bit the code allow us to
boot (ex add some more printing)

Michael

>
> Please share the logs and more details.



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

end of thread, other threads:[~2025-07-05 10:02 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-04 13:50 [PATCH v6 0/3] Static initcalls Jerome Forissier
2025-04-04 13:50 ` [PATCH v6 1/3] arm: asm/system.h: mrc and mcr need .arm if __thumb2__ is not set Jerome Forissier
2025-04-04 13:50 ` [PATCH v6 2/3] common: board: make initcalls static Jerome Forissier
2025-04-12 20:52   ` Marek Vasut
2025-06-03 15:22   ` Simon Glass
2025-06-03 16:10     ` Tom Rini
2025-06-04 13:10       ` Simon Glass
2025-04-04 13:50 ` [PATCH v6 3/3] initcall: remove initcall_run_list() Jerome Forissier
2025-04-14 20:07 ` [PATCH v6 0/3] Static initcalls Tom Rini
2025-04-29 21:52 ` [REGRESSION] " Marcel Ziswiler
2025-04-30  7:11   ` [SPAM][REGRESSION] " Weijie Gao
2025-04-30  8:33     ` Marcel Ziswiler
2025-04-30 13:54   ` [REGRESSION] " Simon Glass
2025-04-30 14:15     ` Tom Rini
2025-04-30 15:00       ` Simon Glass
2025-04-30 15:29         ` Tom Rini
2025-07-04  2:33 ` Fabio Estevam
2025-07-04  2:34   ` Fabio Estevam
2025-07-04  8:33     ` Jerome Forissier
2025-07-04  8:37       ` Michael Nazzareno Trimarchi
2025-07-04 13:33         ` Fabio Estevam
2025-07-05 10:01           ` Michael Nazzareno Trimarchi
2025-07-04 11:37       ` Fabio Estevam
2025-07-04 12:02         ` Jerome Forissier
2025-07-04 12:22           ` Fabio Estevam

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