mbox series

[v4,0/2] Static initcalls

Message ID cover.1736174204.git.jerome.forissier@linaro.org
Headers show
Series Static initcalls | expand

Message

Jerome Forissier Jan. 6, 2025, 2:40 p.m. UTC
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.

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/


*** BLURB HERE ***

Jerome Forissier (2):
  common: board: make static calls
  initcall: remove initcall_run_list()

 common/board_f.c   | 218 ++++++++++++++++++++-------------------
 common/board_r.c   | 251 +++++++++++++++++++++++----------------------
 include/initcall.h |  45 ++++----
 lib/Makefile       |   1 -
 lib/initcall.c     | 102 ------------------
 5 files changed, 263 insertions(+), 354 deletions(-)
 delete mode 100644 lib/initcall.c

Comments

Tom Rini Jan. 17, 2025, 9:46 p.m. UTC | #1
On Mon, Jan 06, 2025 at 03:40:12PM +0100, 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.

This fails in CI unfortunately:
https://source.denx.de/u-boot/u-boot/-/pipelines/24241
Jerome Forissier Jan. 21, 2025, 4:05 p.m. UTC | #2
On 1/17/25 22:46, Tom Rini wrote:
> On Mon, Jan 06, 2025 at 03:40:12PM +0100, 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.
> 
> This fails in CI unfortunately:
> https://source.denx.de/u-boot/u-boot/-/pipelines/24241

I found the problem. It was a silly mistake :-/

diff --git a/common/board_r.c b/common/board_r.c
index 74ebbdc7de9..21a8b97d1bc 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -717,7 +717,7 @@ static void initcall_run_r(void)
 #endif
	INITCALL_EVT(EVT_SETTINGS_R);
	WATCHDOG_RESET();
-#if CONFIG_IS_ENABLED(PCI_INIT_R) && CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
+#if CONFIG_IS_ENABLED(PCI_INIT_R) && !CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
	/*
	 * Do pci configuration
	 */

Shall I sent a v5?

Thanks,
Tom Rini Jan. 21, 2025, 4:11 p.m. UTC | #3
On Tue, Jan 21, 2025 at 05:05:58PM +0100, Jerome Forissier wrote:
> 
> 
> On 1/17/25 22:46, Tom Rini wrote:
> > On Mon, Jan 06, 2025 at 03:40:12PM +0100, 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.
> > 
> > This fails in CI unfortunately:
> > https://source.denx.de/u-boot/u-boot/-/pipelines/24241
> 
> I found the problem. It was a silly mistake :-/
> 
> diff --git a/common/board_r.c b/common/board_r.c
> index 74ebbdc7de9..21a8b97d1bc 100644
> --- a/common/board_r.c
> +++ b/common/board_r.c
> @@ -717,7 +717,7 @@ static void initcall_run_r(void)
>  #endif
> 	INITCALL_EVT(EVT_SETTINGS_R);
> 	WATCHDOG_RESET();
> -#if CONFIG_IS_ENABLED(PCI_INIT_R) && CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
> +#if CONFIG_IS_ENABLED(PCI_INIT_R) && !CONFIG_IS_ENABLED(SYS_EARLY_PCI_INIT)
> 	/*
> 	 * Do pci configuration
> 	 */
> 
> Shall I sent a v5?

Yes please, and push it through CI first ;)