From e7f59dea880ea25078273473c575794dac08dca2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Aug 2023 21:16:49 -0600 Subject: Revert "initcall: Move to inline function" Somehow I do not see any inlining with initcalls now. I was sure I saw it when this commit went in, but now it seems to make things worse. This reverts commit 47870afab92fca6e672c03d0dea802a55e200675. Signed-off-by: Simon Glass --- include/initcall.h | 46 +--------------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) (limited to 'include/initcall.h') diff --git a/include/initcall.h b/include/initcall.h index 69ce2680705..01f3f2833f1 100644 --- a/include/initcall.h +++ b/include/initcall.h @@ -8,50 +8,6 @@ typedef int (*init_fnc_t)(void); -#include -#ifdef CONFIG_EFI_APP -#include -#endif -#include - -/* - * To enable debugging. add #define DEBUG at the top of the including file. - * - * To find a symbol, use grep on u-boot.map - */ -static inline int initcall_run_list(const init_fnc_t init_sequence[]) -{ - const init_fnc_t *init_fnc_ptr; - - for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { - unsigned long reloc_ofs = 0; - int ret; - - /* - * Sandbox is relocated by the OS, so symbols always appear at - * the relocated address. - */ - if (IS_ENABLED(CONFIG_SANDBOX) || (gd->flags & GD_FLG_RELOC)) - reloc_ofs = gd->reloc_off; -#ifdef CONFIG_EFI_APP - reloc_ofs = (unsigned long)image_base; -#endif - if (reloc_ofs) - debug("initcall: %p (relocated to %p)\n", - (char *)*init_fnc_ptr - reloc_ofs, - (char *)*init_fnc_ptr); - else - debug("initcall: %p\n", (char *)*init_fnc_ptr - reloc_ofs); - - ret = (*init_fnc_ptr)(); - if (ret) { - printf("initcall sequence %p failed at call %p (err=%d)\n", - init_sequence, - (char *)*init_fnc_ptr - reloc_ofs, ret); - return -1; - } - } - return 0; -} +int initcall_run_list(const init_fnc_t init_sequence[]); #endif -- cgit v1.2.3 From c9eff0a6b6ea2bcd54d30f8a02281681f3730223 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Aug 2023 21:16:54 -0600 Subject: initcall: Support emitting events At present the initcall list consists of a list of function pointers. Over time the initcall lists will likely change to mostly emitting events, since most of the calls are board- or arch-specific. As a first step, allow an initcall to be an event type instead of a function pointer. Add the required macro and update initcall_run_list() to emit an event in that case, or ignore it if events are not enabled. The bottom 8 bits of the function pointer are used to hold the event type, with the rest being all ones. This should avoid any collision, since initcalls should not be above 0xffffff00 in memory. Convert misc_init_f over to use this mechanism. Add comments to the initcall header file while we are here. Also fix up the trace test to handle the change. Signed-off-by: Simon Glass --- include/initcall.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include/initcall.h') diff --git a/include/initcall.h b/include/initcall.h index 01f3f2833f1..62d3bb67f08 100644 --- a/include/initcall.h +++ b/include/initcall.h @@ -6,8 +6,33 @@ #ifndef __INITCALL_H #define __INITCALL_H +#include +#include + +_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[]); #endif -- cgit v1.2.3 From dd802467f44b68d6ed9315ffe3002b17dc43b622 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 21 Aug 2023 21:16:55 -0600 Subject: initcall: Support manual relocation Move the manual-relocation code to the initcall file. Make sure to avoid manually relocating event types. Only true function pointers should be relocated. Signed-off-by: Simon Glass --- include/initcall.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/initcall.h') diff --git a/include/initcall.h b/include/initcall.h index 62d3bb67f08..208effd8d13 100644 --- a/include/initcall.h +++ b/include/initcall.h @@ -35,4 +35,11 @@ typedef int (*init_fnc_t)(void); */ int initcall_run_list(const init_fnc_t init_sequence[]); +/** + * initcall_manual_reloc() - Do manual relocation on an initcall sequence + * + * @init_sequence: NULL-terminated init sequence to relocate + */ +void initcall_manual_reloc(init_fnc_t init_sequence[]); + #endif -- cgit v1.2.3 From 92b1f7abb6653c8daa7f359addb0945fa0790c5d Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 6 Sep 2023 23:29:58 +0200 Subject: initcall: Remove unused NEEDS_MANUAL_RELOC code bits The last user of the NEEDS_MANUAL_RELOC has been removed in commit 26af162ac8f8 ("arch: m68k: Implement relocation") Remove now unused NEEDS_MANUAL_RELOC code. Signed-off-by: Marek Vasut --- include/initcall.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include/initcall.h') diff --git a/include/initcall.h b/include/initcall.h index 208effd8d13..62d3bb67f08 100644 --- a/include/initcall.h +++ b/include/initcall.h @@ -35,11 +35,4 @@ typedef int (*init_fnc_t)(void); */ int initcall_run_list(const init_fnc_t init_sequence[]); -/** - * initcall_manual_reloc() - Do manual relocation on an initcall sequence - * - * @init_sequence: NULL-terminated init sequence to relocate - */ -void initcall_manual_reloc(init_fnc_t init_sequence[]); - #endif -- cgit v1.2.3