event: Replace some more init hooks
Subsystems (9)
cover event: Replace some more init hooks
This series replaces some more of the init hooks in board_f.c and board_r.c with events. Notably it converts last_state_init() over.
It also provides a 'simple' event spy, which takes no arguments. It turns out that this is quite a common case, so it is worth optimising for this, to reduce code size, before events become too commonly used.
Finally, it introduces a way of emitting an event in an initcall, instead of calling a function. This is likely to be used at least as often as the functions, as we convert more of these initcalls.
As part of this, the initcall code is brought back into a C file. Somehow the compiler has changed or something else, so that this does not confer any benefits now.
For boards with EVENT enabled, this unfortunately results in small growth, e.g. for firefly:
aarch64: (for 1/1 boards) all +114.0 data +16.0 rodata +22.0 text +76.0
arm: (for 1/1 boards) all +82.0 rodata +18.0 text +64.0
For boards without EVENT enabled the growth is smaller, e.g. nokia_rx51:
arm: (for 1/1 boards) all +32.0 data +8.0 rodata -8.0 text +32.0
I cannot find a good way to avoid the latter, other than macro magic with an embedded comma (to completely remove an event entry), which seems nasty.
Simon Glass (14):
event: Support a simple spy record
Revert "initcall: Move to inline function"
initcall: Factor out reloc_off calculation
initcall: Adjust the loop logic
initcall: Adjust the failure message and return value
event: Export event_type_name()
initcall: Support emitting events
initcall: Support manual relocation
event: Convert existing spy records to simple
event: Rename EVENT_SPY to EVENT_SPY_FULL
event: Update documentation for simple spy
x86: Convert arch_fsp_init() to use events
freescale: Drop call to init_func_vid() in the init sequence
event: Use an event to replace last_stage_init()
arch/Kconfig | 1 + arch/arm/cpu/armv8/fsl-layerscape/spl.c | 5 + arch/arm/mach-imx/imx8/cpu.c | 4 +- arch/arm/mach-imx/imx8m/soc.c | 4 +- arch/arm/mach-imx/imx8ulp/soc.c | 7 +- arch/arm/mach-imx/imx9/soc.c | 4 +- arch/arm/mach-omap2/am33xx/board.c | 4 +- arch/arm/mach-omap2/hwinit-common.c | 12 +- arch/mips/mach-mtmips/cpu.c | 6 +- arch/mips/mach-pic32/cpu.c | 12 +- arch/nios2/cpu/cpu.c | 4 +- arch/riscv/cpu/cpu.c | 4 +- arch/riscv/include/asm/system.h | 2 +- arch/riscv/lib/spl.c | 2 +- arch/sandbox/cpu/start.c | 7 +- arch/x86/cpu/baytrail/cpu.c | 4 +- arch/x86/cpu/broadwell/cpu.c | 4 +- arch/x86/cpu/coreboot/coreboot.c | 7 +- arch/x86/cpu/cpu.c | 10 +- arch/x86/cpu/efi/payload.c | 4 +- arch/x86/cpu/ivybridge/cpu.c | 4 +- arch/x86/cpu/quark/quark.c | 30 +++-- arch/x86/lib/fsp1/fsp_common.c | 1 + arch/x86/lib/fsp2/fsp_common.c | 5 - arch/x86/lib/fsp2/fsp_init.c | 4 +- board/CZ.NIC/turris_mox/turris_mox.c | 4 +- board/Marvell/mvebu_armada-37xx/board.c | 5 +- board/Marvell/octeon_nic23/board.c | 4 +- board/Marvell/octeontx2/board.c | 4 +- board/cortina/presidio-asic/presidio.c | 4 +- board/emulation/qemu-ppce500/qemu-ppce500.c | 4 +- board/freescale/ls1088a/ls1088a.c | 3 +- board/freescale/lx2160a/lx2160a.c | 2 + board/gdsys/a38x/controlcenterdc.c | 31 +++-- board/gdsys/mpc8308/gazerbeam.c | 4 +- board/ge/bx50v3/bx50v3.c | 4 +- board/google/chromebook_coral/coral.c | 4 +- board/keymile/km83xx/km83xx.c | 4 +- board/keymile/kmcent2/kmcent2.c | 7 +- .../keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c | 10 +- board/phytium/durian/durian.c | 4 +- board/phytium/pomelo/pomelo.c | 4 +- board/starfive/visionfive2/spl.c | 2 +- boot/vbe_request.c | 2 +- boot/vbe_simple_os.c | 2 +- common/Kconfig | 1 + common/board_f.c | 21 +--- common/board_r.c | 20 ++-- common/event.c | 13 ++- configs/bayleybay_defconfig | 1 - configs/cherryhill_defconfig | 1 - configs/chromebook_coral_defconfig | 1 - configs/chromebook_link64_defconfig | 1 - configs/chromebook_link_defconfig | 1 - configs/chromebook_samus_defconfig | 1 - configs/chromebook_samus_tpl_defconfig | 1 - configs/chromebox_panther_defconfig | 1 - ...-qeval20-qa3-e3845-internal-uart_defconfig | 1 - configs/conga-qeval20-qa3-e3845_defconfig | 1 - configs/coreboot64_defconfig | 1 - configs/coreboot_defconfig | 1 - configs/cougarcanyon2_defconfig | 1 - configs/crownbay_defconfig | 1 - configs/dfi-bt700-q7x-151_defconfig | 1 - configs/edison_defconfig | 1 - configs/efi-x86_app32_defconfig | 1 - configs/efi-x86_app64_defconfig | 1 - configs/efi-x86_payload32_defconfig | 1 - configs/efi-x86_payload64_defconfig | 1 - configs/galileo_defconfig | 1 - configs/minnowmax_defconfig | 1 - configs/qemu-x86_64_defconfig | 3 +- configs/qemu-x86_defconfig | 1 - configs/som-db5800-som-6867_defconfig | 1 - ...able-x86-conga-qa3-e3845-pcie-x4_defconfig | 1 - .../theadorable-x86-conga-qa3-e3845_defconfig | 1 - configs/theadorable-x86-dfi-bt700_defconfig | 1 - doc/develop/event.rst | 23 +++- drivers/cpu/microblaze_cpu.c | 4 +- include/event.h | 72 +++++++++++- include/init.h | 15 --- include/initcall.h | 72 +++++------- lib/Makefile | 1 + lib/fwu_updates/fwu.c | 4 +- lib/initcall.c | 109 ++++++++++++++++++ scripts/event_dump.py | 12 +- test/common/event.c | 22 ++++ test/py/tests/test_event_dump.py | 3 +- test/py/tests/test_trace.py | 11 +- 89 files changed, 431 insertions(+), 261 deletions(-) create mode 100644 lib/initcall.c
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 1/14 event: Support a simple spy record
The current event spy is always passed the event context and the event. The context is always NULL for a static spy. The event is not often used.
Introduce a 'simple' spy which takes no arguments. This allows us to drop the adaptation code that many of these spy records use.
Update the event script to find these in the image.
---
common/event.c | 9 ++++++- include/event.h | 41 ++++++++++++++++++++++++++++++-- scripts/event_dump.py | 12 ++++++---- test/common/event.c | 22 +++++++++++++++++ test/py/tests/test_event_dump.py | 3 ++- 5 files changed, 79 insertions(+), 8 deletions(-)
common/event.c +8 -1
@@ -71,7 +71,14 @@ static int notify_static(struct event *ev)log_debug ("Sending event %x/%s to spy '%s'\n" , ev->type,event_type_name (ev->type),event_spy_id (spy)); - ret = spy->func (NULL , ev); +if (spy->flags &EVSPYF_SIMPLE ) { +const struct evspy_info_simple *simple; + + simple = (struct evspy_info_simple *)spy; + ret = simple->func (); + }else { + ret = spy->func (NULL , ev); + }/* * TODO: Handle various return codes to
include/event.h +39 -2
73 lines not on this page · raw message
scripts/event_dump.py +8 -4
@@ -19,8 +19,10 @@ from u_boot_pylib import tools # A typical symbol looks like this: # _u_boot_list_2_evspy_info_2_EVT_MISC_INIT_F_3_sandbox_misc_init_f -PREFIX = '_u_boot_list_2_evspy_info_2_' -RE_EVTYPE = re.compile('%s(.*)_3_.*' % PREFIX) +PREFIX_FULL = '_u_boot_list_2_evspy_info_2_' +PREFIX_SIMPLE = '_u_boot_list_2_evspy_info_simple_2_' +RE_EVTYPE_FULL = re.compile('%s(.*)_3_.*' % PREFIX_FULL) +RE_EVTYPE_SIMPLE = re.compile('%s(.*)_3_.*' % PREFIX_SIMPLE) def show_sym(fname, data, endian, evtype, sym): """Show information about an evspy entry
@@ -88,12 +90,14 @@ def show_event_spy_list(fname, endian): fname (str): Filename of ELF file endian (str): Endianness to use ('little', 'big', 'auto') """ - syms = elf.GetSymbolFileOffset(fname, [PREFIX]) + syms = elf.GetSymbolFileOffset(fname, [PREFIX_FULL, PREFIX_SIMPLE]) data = tools.read_file(fname) print('%-20s %-30s %s' % ('Event type', 'Id', 'Source location')) print('%-20s %-30s %s' % ('-' * 20, '-' * 30, '-' * 30)) for name, sym in syms.items(): - m_evtype = RE_EVTYPE.search(name) + m_evtype = RE_EVTYPE_FULL.search(name) + if not m_evtype: + m_evtype = RE_EVTYPE_SIMPLE.search(name) evtype = m_evtype .group(1) show_sym(fname, data, endian, evtype, sym)
test/common/event.c +22 -0
@@ -18,6 +18,8 @@ struct test_state {int val; }; +static bool called; +static int h_adder (void *ctx,struct event *event) {struct event_data_test *data = &event->data.test;
@@ -28,6 +30,14 @@ static int h_adder(void *ctx, struct event *event)return 0 ; } +static int h_adder_simple (void ) +{ + called = true; + +return 0 ; +} +EVENT_SPY_SIMPLE (EVT_TEST , h_adder_simple); +static int test_event_base (struct unit_test_state *uts) {struct test_state state;
@@ -46,6 +56,18 @@ static int test_event_base(struct unit_test_state *uts) }COMMON_TEST (test_event_base,0 ); +static int test_event_simple (struct unit_test_state *uts) +{ + called = false; + +/* Check that the handler is called */ +ut_assertok (event_notify_null (EVT_TEST )); +ut_assert (called); + +return 0 ; +} +COMMON_TEST (test_event_simple,0 ); +static int h_probe (void *ctx,struct event *event) {struct test_state *test_state = ctx;
test/py/tests/test_event_dump.py +2 -1
@@ -18,5 +18,6 @@ def test_event_dump(u_boot_console): -------------------- ------------------------------ ------------------------------ EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.* EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple_os.c:.* -EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:''' +EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:.* +EVT_TEST h_adder_simple .*test/common/event.c:''' assert re.match(expect, out, re.MULTILINE) is not None
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 2/14 Revert "initcall: Move to inline function"
In reply to Simon GlassSomehow 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.
---
common/board_r.c | 5 ++++- include/initcall.h | 46 +--------------------------------------- lib/Makefile | 1 + lib/initcall.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 46 deletions(-) create mode 100644 lib/initcall.c
common/board_r.c +4 -1
@@ -583,7 +583,10 @@ static int run_main_loop(void) }/* -* We hope to remove most of the driver-related init and do it if/when +* 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. * * TODO: perhaps reset the watchdog in the initcall function after each call?
include/initcall.h +1 -45
51 lines not on this page · raw message
lib/Makefile +1 -0
@@ -44,6 +44,7 @@ obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o 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
lib/initcall.c new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 3/14 initcall: Factor out reloc_off calculation
In reply to Simon GlassMove this into a function and do it once, not each time around the loop.
---
lib/initcall.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
lib/initcall.c +15 -10
@@ -11,6 +11,20 @@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 ; +}/* * To enable debugging. add #define DEBUG at the top of the including file. *
@@ -18,21 +32,12 @@ DECLARE_GLOBAL_DATA_PTR;*/ int initcall_run_list (const init_fnc_t init_sequence[]) { +ulong reloc_ofs =calc_reloc_ofs ();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,
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 4/14 initcall: Adjust the loop logic
In reply to Simon GlassUse a variable to hold the function, so we don't need to repeat the pointer access each time. Rename the init pointer to 'ptr' since we only refer to it in the for() statement now.
---
lib/initcall.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
lib/initcall.c +12 -12
@@ -33,25 +33,25 @@ static ulong calc_reloc_ofs(void)int initcall_run_list (const init_fnc_t init_sequence[]) {ulong reloc_ofs =calc_reloc_ofs (); -const init_fnc_t *init_fnc_ptr; +const init_fnc_t *ptr; +init_fnc_t func; +int ret =0 ; -for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { -int ret; - -if (reloc_ofs) +for (ptr = init_sequence; func = *ptr, !ret && func; ptr++) { +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); + (char *)func - reloc_ofs, func); + }else { +debug ("initcall: %p\n" , (char *)func - reloc_ofs); + } - ret = (*init_fnc_ptr)(); + ret =func ();if (ret) {printf ("initcall sequence %p failed at call %p (err=%d)\n" , - init_sequence, - (char *)*init_fnc_ptr - reloc_ofs, ret); + init_sequence, (char *)func - reloc_ofs, ret);return -1 ; } } +return 0 ; }
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 5/14 initcall: Adjust the failure message and return value
In reply to Simon GlassMove the failure message outside the loop, so it is easier to follow the code. Avoid swallowing the error code - just pass it along.
Drop the initcall-list address from the output. This is confusing since we show two addresses. Really it is only the function address which is useful, since it can be looked up in the map, e.g. with:
grep -A1 -B1 serial_init u-boot.map
---
lib/initcall.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
lib/initcall.c +7 -5
@@ -46,11 +46,13 @@ int initcall_run_list(const init_fnc_t init_sequence[]) } ret =func (); -if (ret) { -printf ("initcall sequence %p failed at call %p (err=%d)\n" , - init_sequence, (char *)func - reloc_ofs, ret); -return -1 ; - } + } + +if (ret) { +printf ("initcall failed at call %p (err=%dE)\n" , + (char *)func - reloc_ofs, ret); + +return ret; }return 0 ;
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Re: [PATCH 05/14] initcall: Adjust the failure message and return value
Hi Simon,
út 22. 8. 2023 v 5:18 odesílatel Simon Glass <[email protected]> napsal:
Quoted 39 lines
Move the failure message outside the loop, so it is easier to follow the code. Avoid swallowing the error code - just pass it along.
Drop the initcall-list address from the output. This is confusing since we show two addresses. Really it is only the function address which is useful, since it can be looked up in the map, e.g. with:
grep -A1 -B1
serial_initu-boot.mapSigned-off-by Simon Glass <[email protected]>---
lib/initcall.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)lib/initcall.c +7
-5@@ -46,11 +46,13 @@ int initcall_run_list(const init_fnc_t init_sequence[]) } ret =func (); -if (ret) { - printf("initcall sequence %p failed at call %p (err=%d)\n", - init_sequence, (char *)func - reloc_ofs, ret); -return -1 ; - } + } + +if (ret) { +printf ("initcall failed at call %p (err=%dE)\n" , + (char *)func - reloc_ofs, ret); + +return ret; }
Quoted 5 lines
return 0;--
2.42.0.rc1.204.g551eb34607-goog
I am debugging one issue and I get output like this. And I dig into it and find out that failures are not reported
on the function which is causing it but on the next one. It is because of pointer is moved to next function;
This is what I see.
initcall: 0000000008072de8, 0
initcall failed at call 000000000802b14c (err=-19)
And this is the problematic part.
for (ptr = init_sequence; func = *ptr, !ret && func; ptr++) {
Fix should be of course to get that if(ret) code back but maybe you want to see different solution.
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
Re: [PATCH 05/14] initcall: Adjust the failure message and return value
Hi Simon,
Quoted 50 lines · Michal Simek
Hi Simon,
út 22. 8. 2023 v 5:18 odesílatel Simon Glass <[email protected] <mailto:[email protected]>> napsal:
Move the failure message outside the loop, so it is easier to follow the code. Avoid swallowing the error code - just pass it along. Drop the initcall-list address from the output. This is confusing since we show two addresses. Really it is only the function address which is useful, since it can be looked up in the map, e.g. with: grep -A1 -B1 serial_init u-boot.map Signed-off-by: Simon Glass <[email protected] <mailto:[email protected]>> --- lib/initcall.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/initcall.c b/lib/initcall.c index 81c5d2450735..0f74cef32f85 100644 --- a/lib/initcall.c +++ b/lib/initcall.c @@ -46,11 +46,13 @@ int initcall_run_list(const init_fnc_t init_sequence[]) } ret = func(); - if (ret) { - printf("initcall sequence %p failed at call %p (err=%d)\n", - init_sequence, (char *)func - reloc_ofs, ret); - return -1; - } + } + + if (ret) { + printf("initcall failed at call %p (err=%dE)\n", + (char *)func - reloc_ofs, ret); + + return ret; } return 0; -- 2.42.0.rc1.204.g551eb34607-googI am debugging one issue and I get output like this. And I dig into it and find out that failures are not reported on the function which is causing it but on the next one. It is because of pointer is moved to next function;
Quoted 8 lines
This is what I see.
initcall:0000000008072de8, 0
initcall failed at call000000000802b14c(err=-19)And this is the problematic part.
for (ptr =init_sequence; func = *ptr, !ret && func; ptr++) {Fix should be of course to get that if(ret) code back but maybe you want to see different solution.
Any comment on this one?
M
Re: [PATCH 05/14] initcall: Adjust the failure message and return value
Hi Michal,
Quoted 61 lines · Michal Simek
Hi Simon,
Quoted 57 lines · Michal Simek
Hi Simon,
út 22. 8. 2023 v 5:18 odesílatel Simon Glass <[email protected] <mailto:[email protected]>> napsal:
Move the failure message outside the loop, so it is easier to follow the code. Avoid swallowing the error code - just pass it along.
Drop the initcall-list address from the output. This is confusing since we show two addresses. Really it is only the function address which is useful, since it can be looked up in the map, e.g. with:
grep -A1 -B1
serial_initu-boot.mapSigned-off-by Simon Glass <[email protected] <mailto:[email protected]>>---
lib/initcall.c| 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)diff --git
a/lib/initcall.cb/lib/initcall.c
index81c5d2450735..0f74cef32f85100644
---a/lib/initcall.c
+++b/lib/initcall.c
@@ -46,11 +46,13 @@ intinitcall_run_list(const init_fnc_t init_sequence[])
}ret =
func();
- if (ret) {
- printf("initcall sequence %p failed at call %p
(err=%d)\n",
-init_sequence, (char *)func -reloc_ofs, ret);
- return -1;
- }
+ }
+
+ if (ret) {
+ printf("initcall failed at call %p (err=%dE)\n",
+ (char *)func -reloc_ofs, ret);
+
+ return ret;
}return 0;
--
2.42.0.rc1.204.g551eb34607-googI am debugging one issue and I get output like this. And I dig into it and find out that failures are not reported
on the function which is causing it but on the next one. It is because of pointer is moved to next function;This is what I see.
initcall:0000000008072de8, 0
initcall failed at call000000000802b14c(err=-19)
Quoted 7 lines
Quoted 5 lines
And this is the problematic part.
for (ptr =init_sequence; func = *ptr, !ret && func; ptr++) {Fix should be of course to get that if(ret) code back but maybe you want to see different solution.
Any comment on this one?
Yes it was fixed by this, I believe, although no Fixes tag unfortunately:7554388c1d1 initcall: break loop immediately on failure
Regards,
Simon
Re: [PATCH 05/14] initcall: Adjust the failure message and return value
Quoted 67 lines · Simon Glass
Hi Michal,
Quoted 64 lines · Michal Simek
Hi Simon,
Quoted 60 lines · Michal Simek
Hi Simon,
út 22. 8. 2023 v 5:18 odesílatel Simon Glass <[email protected] <mailto:[email protected]>> napsal:
Move the failure message outside the loop, so it is easier to follow the code. Avoid swallowing the error code - just pass it along.
Drop the initcall-list address from the output. This is confusing since we show two addresses. Really it is only the function address which is useful, since it can be looked up in the map, e.g. with:
grep -A1 -B1
serial_initu-boot.mapSigned-off-by Simon Glass <[email protected] <mailto:[email protected]>>---
lib/initcall.c| 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)diff --git
a/lib/initcall.cb/lib/initcall.c
index81c5d2450735..0f74cef32f85100644
---a/lib/initcall.c
+++b/lib/initcall.c
@@ -46,11 +46,13 @@ intinitcall_run_list(const init_fnc_t init_sequence[])
}ret =
func();
- if (ret) {
- printf("initcall sequence %p failed at call %p
(err=%d)\n",
-init_sequence, (char *)func -reloc_ofs, ret);
- return -1;
- }
+ }
+
+ if (ret) {
+ printf("initcall failed at call %p (err=%dE)\n",
+ (char *)func -reloc_ofs, ret);
+
+ return ret;
}return 0;
--
2.42.0.rc1.204.g551eb34607-googI am debugging one issue and I get output like this. And I dig into it and find out that failures are not reported
on the function which is causing it but on the next one. It is because of pointer is moved to next function;This is what I see.
initcall:0000000008072de8, 0
initcall failed at call000000000802b14c(err=-19)And this is the problematic part.
for (ptr =init_sequence; func = *ptr, !ret && func; ptr++) {
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fix should be of course to get that if(ret) code back but maybe you want to see different solution.
Any comment on this one?
Yes it was fixed by this, I believe, although no Fixes tag unfortunately:
7554388c1d1initcall: break loop immediately on failure
perfect.
Thanks,
Michal
PATCH 6/14 event: Export event_type_name()
In reply to Simon GlassExport this function so it can be used with initcall debugging.
---
common/event.c | 2 +- include/event.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-)
common/event.c +1 -1
@@ -49,7 +49,7 @@ const char *const type_name[] = {_Static_assert (ARRAY_SIZE (type_name) ==EVT_COUNT ,"event type_name size" );#endif -static const char *event_type_name (enum event_t type) +const char *event_type_name (enum event_t type) {#if CONFIG_IS_ENABLED (EVENT_DEBUG )return type_name[type];
include/event.h +8 -0
@@ -230,6 +230,14 @@ void event_show_spy_list(void);*/ int event_manual_reloc (void ); +/** +* event_type_name() - Get the name of an event type +* +* @type: Type to check +* Return: Name of event, or "(unknown)" if not known +*/ +const char *event_type_name (enum event_t type); +/** * event_notify() - notify spies about an event *
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 7/14 initcall: Support emitting events
In reply to Simon GlassAt 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.
---
common/board_f.c | 7 +----- include/initcall.h | 25 +++++++++++++++++++ lib/initcall.c | 50 +++++++++++++++++++++++++++++++++---- test/py/tests/test_trace.py | 11 ++++---- 4 files changed, 77 insertions(+), 16 deletions(-)
common/board_f.c +1 -6
@@ -836,11 +836,6 @@ __weak int clear_bss(void)return 0 ; } -static int misc_init_f (void ) -{ -return event_notify_null (EVT_MISC_INIT_F ); -} -static const init_fnc_t init_sequence_f[] = { setup_mon_len, #ifdef CONFIG_OF_CONTROL
@@ -899,7 +894,7 @@ static const init_fnc_t init_sequence_f[] = { show_board_info,#endif INIT_FUNC_WATCHDOG_INIT - misc_init_f, + INITCALL_EVENT(EVT_MISC_INIT_F), INIT_FUNC_WATCHDOG_RESET #if CONFIG_IS_ENABLED(SYS_I2C_LEGACY) init_func_i2c,
include/initcall.h +25 -0
@@ -6,8 +6,33 @@#ifndef __INITCALL_H#define __INITCALL_H +#include <asm/types.h> +#include <event.h> + +_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
lib/initcall.c +45 -5
80 lines not on this page · raw message
test/py/tests/test_trace.py +6 -5
@@ -175,7 +175,7 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat): # Then look for this: # u-boot-1 [000] 282.101375: funcgraph_exit: 0.006 us | } # Then check for this: - # u-boot-1 [000] 282.101375: funcgraph_entry: 0.000 us | event_init(); + # u-boot-1 [000] 282.101375: funcgraph_entry: 0.000 us | initcall_is_event(); expected_indent = None found_start = False
@@ -197,8 +197,9 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat): elif found_start and indent == expected_indent and brace == '}': found_end = True - # The next function after initf_bootstage() exits should be event_init() - assert upto == 'event_init()' + # The next function after initf_bootstage() exits should be + # initcall_is_event() + assert upto == 'initcall_is_event()' # Now look for initf_dm() and dm_timer_init() so we can check the bootstage # time
@@ -247,7 +248,7 @@ def check_flamegraph(cons, 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;initr_dm_devices;dm_timer_init 1' + look2 = 'board_init_r;initcall_run_list;initr_dm_devices;dm_timer_init 1' found = 0 with open(trace_fg, 'r') as fd: for line in fd:
@@ -272,7 +273,7 @@ def check_flamegraph(cons, fname, proftool, map_fname, trace_fg): total += count return total - +check_flamegraph @pytest.mark.slow @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('trace')
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 8/14 initcall: Support manual relocation
In reply to Simon GlassMove the manual-relocation code to the initcall file. Make sure to avoid manually relocating event types. Only true function pointers should be relocated.
---
common/board_r.c | 6 ++---- include/initcall.h | 7 +++++++ lib/initcall.c | 10 ++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-)
common/board_r.c +2 -4
@@ -813,10 +813,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)#endif gd->flags &= ~GD_FLG_LOG_READY ; -if (IS_ENABLED (CONFIG_NEEDS_MANUAL_RELOC )) { -for (int i =0 ; i <ARRAY_SIZE (init_sequence_r); i++) -MANUAL_RELOC (init_sequence_r[i]); - } +if (IS_ENABLED (CONFIG_NEEDS_MANUAL_RELOC )) +initcall_manual_reloc (init_sequence_r);if (initcall_run_list (init_sequence_r))hang ();
include/initcall.h +7 -0
@@ -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
lib/initcall.c +10 -0
@@ -97,3 +97,13 @@ int initcall_run_list(const init_fnc_t init_sequence[])return 0 ; } + +void initcall_manual_reloc (init_fnc_t init_sequence[]) +{ +init_fnc_t *ptr; + +for (ptr = init_sequence; *ptr; ptr++) { +if (!initcall_is_event (*ptr)) +MANUAL_RELOC (*ptr); + } +}
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 9/14 event: Convert existing spy records to simple
In reply to Simon GlassVery few of the existing event-spy records use the arguments they are passed. Update them to use a simple spy instead, to simplify the code.
Where an adaptor function is currently used, remove it where possible.
---
arch/arm/mach-imx/imx8/cpu.c | 4 +-- arch/arm/mach-imx/imx8m/soc.c | 4 +-- arch/arm/mach-imx/imx8ulp/soc.c | 7 +---- arch/arm/mach-imx/imx9/soc.c | 4 +-- arch/arm/mach-omap2/am33xx/board.c | 4 +-- arch/arm/mach-omap2/hwinit-common.c | 12 +++------ arch/mips/mach-pic32/cpu.c | 10 ++----- arch/nios2/cpu/cpu.c | 4 +-- arch/riscv/cpu/cpu.c | 4 +-- arch/riscv/include/asm/system.h | 2 +- arch/riscv/lib/spl.c | 2 +- arch/sandbox/cpu/start.c | 7 +---- arch/x86/cpu/baytrail/cpu.c | 4 +-- arch/x86/cpu/broadwell/cpu.c | 4 +-- arch/x86/cpu/ivybridge/cpu.c | 4 +-- arch/x86/cpu/quark/quark.c | 26 +++++++------------ arch/x86/lib/fsp2/fsp_init.c | 4 +-- board/google/chromebook_coral/coral.c | 4 +-- board/keymile/kmcent2/kmcent2.c | 4 +-- .../keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c | 4 +-- board/starfive/visionfive2/spl.c | 2 +- drivers/cpu/microblaze_cpu.c | 4 +-- lib/fwu_updates/fwu.c | 4 +-- test/py/tests/test_event_dump.py | 2 +- 24 files changed, 52 insertions(+), 78 deletions(-)
arch/arm/mach-imx/imx8/cpu.c +2 -2
@@ -69,7 +69,7 @@ int arch_cpu_init(void)return 0 ; } -static int imx8_init_mu (void *ctx,struct event *event) +static int imx8_init_mu (void ) {struct udevice *devp;int node, ret;
@@ -91,7 +91,7 @@ static int imx8_init_mu(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , imx8_init_mu); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , imx8_init_mu);#if defined(CONFIG_ARCH_MISC_INIT )int arch_misc_init (void )
arch/arm/mach-imx/imx8m/soc.c +2 -2
@@ -532,7 +532,7 @@ static void imx_set_wdog_powerdown(bool enable)writew (enable, &wdog3->wmcr); } -static int imx8m_check_clock (void *ctx,struct event *event) +static int imx8m_check_clock (void ) {struct udevice *dev;int ret;
@@ -549,7 +549,7 @@ static int imx8m_check_clock(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , imx8m_check_clock); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , imx8m_check_clock);static void imx8m_setup_snvs (void ) {
arch/arm/mach-imx/imx8ulp/soc.c +1 -6
@@ -803,12 +803,7 @@ int imx8ulp_dm_post_init(void)return 0 ; } - -static int imx8ulp_evt_dm_post_init (void *ctx,struct event *event) -{ -return imx8ulp_dm_post_init (); -} -EVENT_SPY (EVT_DM_POST_INIT_F , imx8ulp_evt_dm_post_init); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , imx8ulp_dm_post_init);#if defined(CONFIG_SPL_BUILD )__weak void __noreturn jump_to_image_no_args (struct spl_image_info *spl_image)
arch/arm/mach-imx/imx9/soc.c +2 -2
@@ -552,7 +552,7 @@ int arch_cpu_init(void)return 0 ; } -int imx9_probe_mu (void *ctx,struct event *event) +int imx9_probe_mu (void ) {struct udevice *devp;int node, ret;
@@ -576,7 +576,7 @@ int imx9_probe_mu(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , imx9_probe_mu); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , imx9_probe_mu);int timer_init (void ) {
arch/arm/mach-omap2/am33xx/board.c +2 -2
@@ -527,7 +527,7 @@ void board_init_f(ulong dummy)#endif -static int am33xx_dm_post_init (void *ctx,struct event *event) +static int am33xx_dm_post_init (void ) {hw_data_init ();#if !CONFIG_IS_ENABLED (SKIP_LOWLEVEL_INIT )
@@ -535,4 +535,4 @@ static int am33xx_dm_post_init(void *ctx, struct event *event)#endif return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , am33xx_dm_post_init); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , am33xx_dm_post_init);
arch/arm/mach-omap2/hwinit-common.c +4 -8
@@ -174,7 +174,7 @@ void __weak init_package_revision(void)* done in each of these cases * This function is called with SRAM stack. */ -void early_system_init (void ) +int early_system_init (void ) {#if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_MULTI_DTB_FIT )int ret;
@@ -225,6 +225,8 @@ void early_system_init(void)debug_uart_init ();#endif prcm_init (); + +return 0 ; }#ifdef CONFIG_SPL_BUILD
@@ -240,13 +242,7 @@ void board_init_f(ulong dummy) }#endif -static int omap2_system_init (void *ctx,struct event *event) -{ -early_system_init (); - -return 0 ; -} -EVENT_SPY (EVT_DM_POST_INIT_F , omap2_system_init); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , early_system_init);/* * Routine: wait_for_command_complete
arch/mips/mach-pic32/cpu.c +2 -8
@@ -95,14 +95,8 @@ static void prefetch_init(void)iounmap (regs); } -/* arch specific CPU init after DM */ -static int pic32_flash_prefetch (void *ctx,struct event *event) -{ -/* flash prefetch */ -prefetch_init (); -return 0 ; -} -EVENT_SPY (EVT_DM_POST_INIT_F , pic32_flash_prefetch); +/* arch-specific CPU init after DM: flash prefetch */ +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , prefetch_init);/* Un-gate DDR2 modules (gated by default) */ static void ddr2_pmd_ungate (void )
arch/nios2/cpu/cpu.c +2 -2
@@ -64,7 +64,7 @@ static void copy_exception_trampoline(void) }#endif -static int nios_cpu_setup (void *ctx,struct event *event) +static int nios_cpu_setup (void ) {struct udevice *dev;int ret;
@@ -80,7 +80,7 @@ static int nios_cpu_setup(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , nios_cpu_setup); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , nios_cpu_setup);static int altera_nios2_get_desc (const struct udevice *dev,char *buf,int size)
arch/riscv/cpu/cpu.c +2 -2
@@ -91,7 +91,7 @@ static void dummy_pending_ipi_clear(ulong hart, ulong arg0, ulong arg1) }#endif -int riscv_cpu_setup (void *ctx,struct event *event) +int riscv_cpu_setup (void ) {int ret;
@@ -145,7 +145,7 @@ int riscv_cpu_setup(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , riscv_cpu_setup); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , riscv_cpu_setup);int arch_early_init_r (void ) {
arch/riscv/include/asm/system.h +1 -1
@@ -26,6 +26,6 @@ struct event; } while (0)/* Hook to set up the CPU (called from SPL too) */ -int riscv_cpu_setup(void *ctx, struct event *event); +int riscv_cpu_setup(void);#endif /* __ASM_RISCV_SYSTEM_H */
arch/riscv/lib/spl.c +1 -1
@@ -28,7 +28,7 @@ __weak void board_init_f(ulong dummy)if (ret)panic ("spl_early_init() failed: %d\n" , ret); -riscv_cpu_setup (NULL ,NULL ); +riscv_cpu_setup ();preloader_console_init ();
arch/sandbox/cpu/start.c +1 -6
@@ -119,12 +119,7 @@ int sandbox_early_getopt_check(void)os_exit (0 ); } - -static int sandbox_misc_init_f (void *ctx,struct event *event) -{ -return sandbox_early_getopt_check (); -} -EVENT_SPY (EVT_MISC_INIT_F , sandbox_misc_init_f); +EVENT_SPY_SIMPLE (EVT_MISC_INIT_F , sandbox_early_getopt_check);static int sandbox_cmdline_cb_help (struct sandbox_state *state,const char *arg) {
arch/x86/cpu/baytrail/cpu.c +2 -2
@@ -45,7 +45,7 @@ static void hsuart_clock_set(void *base)* Configure the internal clock of both SIO HS-UARTs, if they are enabled * via FSP */ -static int baytrail_uart_init (void *ctx,struct event *event) +static int baytrail_uart_init (void ) {struct udevice *dev;void *base;
@@ -64,7 +64,7 @@ static int baytrail_uart_init(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , baytrail_uart_init); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , baytrail_uart_init);static void set_max_freq (void ) {
arch/x86/cpu/broadwell/cpu.c +2 -2
@@ -25,7 +25,7 @@#include <asm/arch/pch.h> #include <asm/arch/rcb.h> -static int broadwell_init_cpu (void *ctx,struct event *event) +static int broadwell_init_cpu (void ) {struct udevice *dev;int ret;
@@ -40,7 +40,7 @@ static int broadwell_init_cpu(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , broadwell_init_cpu); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , broadwell_init_cpu);void set_max_freq (void ) {
arch/x86/cpu/ivybridge/cpu.c +2 -2
@@ -54,7 +54,7 @@ int arch_cpu_init(void)return x86_cpu_init_f (); } -static int ivybridge_cpu_init (void *ctx,struct event *ev) +static int ivybridge_cpu_init (void ) {struct pci_controller *hose;struct udevice *bus, *dev;
@@ -86,7 +86,7 @@ static int ivybridge_cpu_init(void *ctx, struct event *ev)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , ivybridge_cpu_init); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , ivybridge_cpu_init);#define PCH_EHCI0_TEMP_BAR0 0xe8000000#define PCH_EHCI1_TEMP_BAR0 0xe8000400
arch/x86/cpu/quark/quark.c +10 -16
@@ -248,22 +248,16 @@ int arch_cpu_init(void)return 0 ; } -static int quark_init_pcie (void *ctx,struct event *event) -{ -/* -* Initialize PCIe controller -* -* Quark SoC holds the PCIe controller in reset following a power on. -* U-Boot needs to release the PCIe controller from reset. The PCIe -* controller (D23:F0/F1) will not be visible in PCI configuration -* space and any access to its PCI configuration registers will cause -* system hang while it is held in reset. -*/ -quark_pcie_early_init (); - -return 0 ; -} -EVENT_SPY (EVT_DM_POST_INIT_F , quark_init_pcie); +/* +* Initialize PCIe controller +* +* Quark SoC holds the PCIe controller in reset following a power on. +* U-Boot needs to release the PCIe controller from reset. The PCIe +* controller (D23:F0/F1) will not be visible in PCI configuration +* space and any access to its PCI configuration registers will cause +* system hang while it is held in reset. +*/ +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , quark_pcie_early_init);int checkcpu (void ) {
arch/x86/lib/fsp2/fsp_init.c +2 -2
@@ -19,7 +19,7 @@#include <dm/uclass-internal.h> #include <asm/fsp2/fsp_internal.h> -int fsp_setup_pinctrl (void *ctx,struct event *event) +int fsp_setup_pinctrl (void ) {struct udevice *dev;ofnode node;
@@ -42,7 +42,7 @@ int fsp_setup_pinctrl(void *ctx, struct event *event)return ret; } -EVENT_SPY (EVT_DM_POST_INIT_F , fsp_setup_pinctrl); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , fsp_setup_pinctrl);#if !defined(CONFIG_TPL_BUILD )binman_sym_declare (ulong, intel_fsp_m, image_pos);
board/google/chromebook_coral/coral.c +2 -2
@@ -33,7 +33,7 @@ struct cros_gpio_info {int flags; }; -static int coral_check_ll_boot (void *ctx,struct event *event) +static int coral_check_ll_boot (void ) {if (!ll_boot_init ()) {printf ("Running as secondary loader" );
@@ -57,7 +57,7 @@ static int coral_check_ll_boot(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_MISC_INIT_F , coral_check_ll_boot); +EVENT_SPY_SIMPLE (EVT_MISC_INIT_F , coral_check_ll_boot);int arch_misc_init (void ) {
board/keymile/kmcent2/kmcent2.c +2 -2
@@ -182,7 +182,7 @@ unsigned long get_serial_clock(unsigned long dummy)return (gd->bus_clk /2 ); } -static int kmcent2_misc_init_f (void *ctx,struct event *event) +static int kmcent2_misc_init_f (void ) {/* configure QRIO pis for i2c deblocking */ i2c_deblock_gpio_cfg ();
@@ -210,7 +210,7 @@ static int kmcent2_misc_init_f(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_MISC_INIT_F , kmcent2_misc_init_f); +EVENT_SPY_SIMPLE (EVT_MISC_INIT_F , kmcent2_misc_init_f);#define USED_SRDS_BANK 0#define EXPECTED_SRDS_RFCK SRDS_PLLCR0_RFCK_SEL_100
board/keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c +2 -2
@@ -110,14 +110,14 @@ int board_early_init_f(void)return 0 ; } -static int pg_wcom_misc_init_f (void *ctx,struct event *event) +static int pg_wcom_misc_init_f (void ) {if (IS_ENABLED (CONFIG_PG_WCOM_UBOOT_UPDATE_SUPPORTED ))check_for_uboot_update ();return 0 ; } -EVENT_SPY (EVT_MISC_INIT_F , pg_wcom_misc_init_f); +EVENT_SPY_SIMPLE (EVT_MISC_INIT_F , pg_wcom_misc_init_f);int board_init (void ) {
board/starfive/visionfive2/spl.c +1 -1
@@ -218,7 +218,7 @@ void board_init_f(ulong dummy)if (ret)panic ("spl_early_init() failed: %d\n" , ret); -riscv_cpu_setup (NULL ,NULL ); +riscv_cpu_setup ();preloader_console_init ();/* Set the parent clock of cpu_root clock to pll0,
drivers/cpu/microblaze_cpu.c +2 -2
@@ -19,7 +19,7 @@ DECLARE_GLOBAL_DATA_PTR; ci = tmp; \ } -static int microblaze_cpu_probe_all (void *ctx,struct event *event) +static int microblaze_cpu_probe_all (void ) {int ret;
@@ -29,7 +29,7 @@ static int microblaze_cpu_probe_all(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_DM_POST_INIT_F , microblaze_cpu_probe_all); +EVENT_SPY_SIMPLE (EVT_DM_POST_INIT_F , microblaze_cpu_probe_all);static void microblaze_set_cpuinfo_pvr (struct microblaze_cpuinfo *ci) {
lib/fwu_updates/fwu.c +2 -2
@@ -618,7 +618,7 @@ int fwu_trial_state_ctr_start(void)return ret; } -static int fwu_boottime_checks (void *ctx,struct event *event) +static int fwu_boottime_checks (void ) {int ret;u32 boot_idx, active_idx;
@@ -682,4 +682,4 @@ static int fwu_boottime_checks(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_MAIN_LOOP , fwu_boottime_checks); +EVENT_SPY_SIMPLE (EVT_MAIN_LOOP , fwu_boottime_checks);
test/py/tests/test_event_dump.py +1 -1
@@ -18,6 +18,6 @@ def test_event_dump(u_boot_console): -------------------- ------------------------------ ------------------------------ EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.* EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple_os.c:.* -EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:.* +EVT_MISC_INIT_F sandbox_early_getopt_check .*arch/sandbox/cpu/start.c:.* EVT_TEST h_adder_simple .*test/common/event.c:''' assert re.match(expect, out, re.MULTILINE) is not None
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 10/14 event: Rename EVENT_SPY to EVENT_SPY_FULL
In reply to Simon GlassThe new name makes it clearer that this is for a full spy, with access to the context and the event data.
---
boot/vbe_request.c | 2 +- boot/vbe_simple_os.c | 2 +- include/event.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
boot/vbe_request.c +1 -1
@@ -230,4 +230,4 @@ static int bootmeth_vbe_ft_fixup(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_FT_FIXUP , bootmeth_vbe_ft_fixup); +EVENT_SPY_FULL (EVT_FT_FIXUP , bootmeth_vbe_ft_fixup);
boot/vbe_simple_os.c +1 -1
@@ -109,4 +109,4 @@ static int bootmeth_vbe_simple_ft_fixup(void *ctx, struct event *event)return 0 ; } -EVENT_SPY (EVT_FT_FIXUP , bootmeth_vbe_simple_ft_fixup); +EVENT_SPY_FULL (EVT_FT_FIXUP , bootmeth_vbe_simple_ft_fixup);
include/event.h +1 -1
@@ -195,7 +195,7 @@ static inline const char *event_spy_id(struct evspy_info *spy)* away the linker-list entry sometimes, e.g. with the EVT_FT_FIXUP entry in * vbe_simple.c - so for now, make it global. */ -#define EVENT_SPY (_type, _func) \ +#define EVENT_SPY_FULL (_type, _func) \ __used ll_entry_declare(struct evspy_info, _type ## _3_ ## _func, \ evspy_info) = _ESPY_REC(_type, _func)
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 11/14 event: Update documentation for simple spy
In reply to Simon GlassNow that we have two types of spy, mention this in the documentation. Put the simple spy first, since it seems to be the common case.
---
doc/develop/event.rst | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
doc/develop/event.rst +21 -2
@@ -21,16 +21,31 @@ Declaring a spy To declare a spy, use something like this:: - static int snow_setup_cpus(void *ctx, struct event *event) + static int snow_check_temperature(void) { /* do something */ return 0; } - EVENT_SPY(EVT_DM_POST_INIT_F, snow_setup_cpus); + EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, snow_check_temperature); This function is called when EVT_DM_POST_INIT_F is emitted, i.e. after the driver model is initialized (in U-Boot proper before and after relocation). +If you need access to the event data, use `EVENT_SPY_FULL`, like this:: + + static int snow_setup_cpus(void *ctx, struct event *event) + { + /* do something that uses event->data*/ + return 0; + } + EVENT_SPY_FULL(EVT_DM_POST_INIT_F, snow_setup_cpus); + +Note that the context is always NULL for a static spy. See below for information +about how to use a dynamic spy. + +The return value is handled by the event emitter. If non-zero, then the error +is returned to the function which emitted the event, i.e. the one that called +`event_notify()`. Debugging ---------
@@ -80,6 +95,10 @@ to be notified when a particular device is probed or removed. This can be handled by enabling `CONFIG_EVENT_DYNAMIC`. It is then possible to call `event_register()` to register a new handler for a particular event. +If some context is need for the spy, you can pass a pointer to +`event_register()` to provide that. Note that the context is only passed to +a spy registered with `EVENT_SPY_FULL`. + Dynamic event handlers are called after all the static event spy handlers have been processed. Of course, since dynamic event handlers are created at runtime it is not possible to use the `event_dump.py` to see them.
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 12/14 x86: Convert arch_fsp_init() to use events
In reply to Simon GlassConvert this to use events instead of calling a function directly in the init sequence.
Rename it to arch_fsp_init_f() to distinguish it from the one that happens after relocation.
For FSPv2 nothing needs to be done here, so drop the empty function.
---
arch/x86/lib/fsp1/fsp_common.c | 1 + arch/x86/lib/fsp2/fsp_common.c | 5 ----- common/board_f.c | 4 +--- common/event.c | 1 + include/event.h | 9 +++++++++ include/init.h | 11 ----------- 6 files changed, 12 insertions(+), 19 deletions(-)
arch/x86/lib/fsp1/fsp_common.c +1 -0
@@ -101,3 +101,4 @@ int arch_fsp_init(void)return 0 ; } +EVENT_SPY_SIMPLE (EVT_FSP_INIT_F , arch_fsp_init);
arch/x86/lib/fsp2/fsp_common.c +0 -5
@@ -8,11 +8,6 @@#include <init.h> #include <asm/fsp/fsp_support.h> -int arch_fsp_init (void ) -{ -return 0 ; -} -void board_final_cleanup (void ) {u32 status;
common/board_f.c +1 -3
@@ -855,9 +855,7 @@ static const init_fnc_t init_sequence_f[] = {#if defined(CONFIG_CONSOLE_RECORD_INIT_F ) console_record_init, #endif -#if defined(CONFIG_HAVE_FSP ) - arch_fsp_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,
common/event.c +1 -0
@@ -35,6 +35,7 @@ const char *const type_name[] = {/* init hooks */ "misc_init_f" , +"fsp_init_r" ,/* Fpga load hook */ "fpga_load",
include/event.h +9 -0
@@ -32,6 +32,15 @@ enum event_t {/* Init hooks */ EVT_MISC_INIT_F , +/* +* Emitted before relocation to set up Firmware Support Package +* +* Where U-Boot relies on binary blobs to handle part of the system +* init, this event can be used to set up the blobs. This is used on +* some Intel platforms +*/ +EVT_FSP_INIT_F , +/* Fpga load hook */ EVT_FPGA_LOAD,
include/init.h +0 -11
@@ -57,17 +57,6 @@ int arch_cpu_init(void);*/ int mach_cpu_init (void ); -/** -* arch_fsp_init() - perform firmware support package init -* -* Where U-Boot relies on binary blobs to handle part of the system init, this -* function can be used to set up the blobs. This is used on some Intel -* platforms. -* -* Return: 0 -*/ -int arch_fsp_init (void ); -/** * arch_fsp_init() - perform post-relocation firmware support package init *
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 13/14 freescale: Drop call to init_func_vid() in the init sequence
In reply to Simon GlassUse the misc_init_f event instead, which is designed for this purpose.
All boards with CONFIG_VID already enable CONFIG_EVENT.
---
arch/arm/cpu/armv8/fsl-layerscape/spl.c | 5 +++++ board/freescale/ls1088a/ls1088a.c | 3 ++- board/freescale/lx2160a/lx2160a.c | 2 ++ common/board_f.c | 10 ---------- include/init.h | 3 --- 5 files changed, 9 insertions(+), 14 deletions(-)
arch/arm/cpu/armv8/fsl-layerscape/spl.c +5 -0
@@ -78,6 +78,11 @@ void tzpc_init(void)#endif } +__weak int init_func_vid (void ) +{ +return 0 ; +} +void board_init_f (ulong dummy) {int ret;
board/freescale/ls1088a/ls1088a.c +2 -1
@@ -181,13 +181,14 @@ unsigned long long get_qixis_addr(void)#endif #if defined(CONFIG_VID ) -int init_func_vid (void ) +static int setup_core_voltage (void ) {if (adjust_vdd (0 ) <0 )printf ("core voltage not adjusted\n" );return 0 ; } +EVENT_SPY_SIMPLE (EVT_MISC_INIT_F , setup_core_voltage);u16 soc_get_fuse_vid (int vid_index) {
board/freescale/lx2160a/lx2160a.c +2 -0
@@ -13,6 +13,7 @@#include <i2c.h> #include <malloc.h> #include <errno.h> +#include <event.h> #include <netdev.h> #include <fsl_ddr.h> #include <asm/io.h>
@@ -242,6 +243,7 @@ int init_func_vid(void) return 0; }#endif +EVENT_SPY_SIMPLE (EVT_MISC_INIT_F , init_func_vid);int checkboard (void ) {
common/board_f.c +0 -10
@@ -280,13 +280,6 @@ static int init_func_i2c(void) }#endif -#if defined(CONFIG_VID ) -__weak int init_func_vid (void ) -{ -return 0 ; -} -#endif -static int setup_mon_len (void ) {#if defined(__ARM__) || defined(__MICROBLAZE__)
@@ -896,9 +889,6 @@ static const init_fnc_t init_sequence_f[] = { INIT_FUNC_WATCHDOG_RESET#if CONFIG_IS_ENABLED (SYS_I2C_LEGACY ) init_func_i2c, -#endif -#if defined(CONFIG_VID ) && !defined(CONFIG_SPL ) - init_func_vid, #endif announce_dram_init, dram_init, /* configure available RAM banks */
include/init.h +0 -3
@@ -276,9 +276,6 @@ int set_cpu_clk_info(void);int update_flash_size (int flash_size);int arch_early_init_r (void );int misc_init_r (void ); -#if defined(CONFIG_VID ) -int init_func_vid (void ); -#endif /* common/board_info.c */ int checkboard (void );
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
PATCH 14/14 event: Use an event to replace last_stage_init()
In reply to Simon GlassAdd a new event which handles this function. Convert existing use of the function to use the new event instead.
Make sure that EVENT is enabled by affected boards, by selecting it from the LAST_STAGE_INIT option. For x86, enable it by default since all boards need it.
For controlcenterdc, inline the get_tpm() function and make sure the event is not built in SPL.
---
arch/Kconfig | 1 + arch/mips/mach-mtmips/cpu.c | 6 +++- arch/mips/mach-pic32/cpu.c | 4 ++- arch/x86/cpu/coreboot/coreboot.c | 7 ++++- arch/x86/cpu/cpu.c | 10 ++++-- arch/x86/cpu/efi/payload.c | 4 ++- arch/x86/cpu/quark/quark.c | 4 ++- board/CZ.NIC/turris_mox/turris_mox.c | 4 ++- board/Marvell/mvebu_armada-37xx/board.c | 5 ++- board/Marvell/octeon_nic23/board.c | 4 ++- board/Marvell/octeontx2/board.c | 4 ++- board/cortina/presidio-asic/presidio.c | 4 ++- board/emulation/qemu-ppce500/qemu-ppce500.c | 4 ++- board/gdsys/a38x/controlcenterdc.c | 31 +++++++++---------- board/gdsys/mpc8308/gazerbeam.c | 4 ++- board/ge/bx50v3/bx50v3.c | 4 ++- board/keymile/km83xx/km83xx.c | 4 ++- board/keymile/kmcent2/kmcent2.c | 3 +- .../keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c | 6 +--- board/phytium/durian/durian.c | 4 ++- board/phytium/pomelo/pomelo.c | 4 ++- common/Kconfig | 1 + common/board_r.c | 9 +----- common/event.c | 1 + configs/bayleybay_defconfig | 1 - configs/cherryhill_defconfig | 1 - configs/chromebook_coral_defconfig | 1 - configs/chromebook_link64_defconfig | 1 - configs/chromebook_link_defconfig | 1 - configs/chromebook_samus_defconfig | 1 - configs/chromebook_samus_tpl_defconfig | 1 - configs/chromebox_panther_defconfig | 1 - ...-qeval20-qa3-e3845-internal-uart_defconfig | 1 - configs/conga-qeval20-qa3-e3845_defconfig | 1 - configs/coreboot64_defconfig | 1 - configs/coreboot_defconfig | 1 - configs/cougarcanyon2_defconfig | 1 - configs/crownbay_defconfig | 1 - configs/dfi-bt700-q7x-151_defconfig | 1 - configs/edison_defconfig | 1 - configs/efi-x86_app32_defconfig | 1 - configs/efi-x86_app64_defconfig | 1 - configs/efi-x86_payload32_defconfig | 1 - configs/efi-x86_payload64_defconfig | 1 - configs/galileo_defconfig | 1 - configs/minnowmax_defconfig | 1 - configs/qemu-x86_64_defconfig | 3 +- configs/qemu-x86_defconfig | 1 - configs/som-db5800-som-6867_defconfig | 1 - ...able-x86-conga-qa3-e3845-pcie-x4_defconfig | 1 - .../theadorable-x86-conga-qa3-e3845_defconfig | 1 - configs/theadorable-x86-dfi-bt700_defconfig | 1 - include/event.h | 12 +++++++ include/init.h | 1 - 54 files changed, 95 insertions(+), 80 deletions(-)
arch/Kconfig +1 -0
@@ -252,6 +252,7 @@ config X86 imply DM_SPI imply DM_SPI_FLASH imply DM_USB + imply LAST_STAGE_INIT imply VIDEO imply SYSRESET imply SPL_SYSRESET
arch/mips/mach-mtmips/cpu.c +5 -1
@@ -4,6 +4,7 @@*/ #include <common.h> +#include <event.h> #include <init.h> #include <malloc.h> #include <asm/addrspace.h>
@@ -21,7 +22,8 @@ int dram_init(void)return 0 ; } -int last_stage_init (void ) +#ifndef CONFIG_SPL_BUILD +static int last_stage_init (void ) {void *src, *dst;
@@ -46,3 +48,5 @@ int last_stage_init(void) return 0; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init); +#endif
arch/mips/mach-pic32/cpu.c +3 -1
@@ -57,7 +57,7 @@ static ulong clk_get_cpu_rate(void) }/* initialize prefetch module related to cpu_clk */ -static void prefetch_init (void ) +static int prefetch_init (void ) {struct pic32_reg_atomic *regs;const void __iomem *base;
@@ -93,6 +93,8 @@ static void prefetch_init(void)/* Enable prefetch for all */ writel (0x30 , ®s->set);iounmap (regs); + +return 0 ; }/* arch-specific CPU init after DM: flash prefetch */
arch/x86/cpu/coreboot/coreboot.c +6 -1
@@ -7,6 +7,7 @@#include <common.h> #include <cpu_func.h> +#include <event.h> #include <fdtdec.h> #include <init.h> #include <usb.h>
@@ -74,8 +75,11 @@ static void board_final_init(void) } } -int last_stage_init (void ) +static int last_stage_init (void ) { +if (IS_ENABLED (CONFIG_SPL_BUILD )) +return 0 ; +/* start usb so that usb keyboard can be used as input device */ if (IS_ENABLED (CONFIG_USB_KEYBOARD ))usb_init ();
@@ -84,3 +88,4 @@ int last_stage_init(void)return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);
arch/x86/cpu/cpu.c +7 -3
@@ -26,6 +26,7 @@#include <cpu_func.h> #include <dm.h> #include <errno.h> +#include <event.h> #include <init.h> #include <irq.h> #include <log.h>
@@ -185,7 +186,8 @@ void show_boot_progress(int val) }#endif -#if !defined(CONFIG_SYS_COREBOOT ) && !defined(CONFIG_EFI_STUB ) +#if !defined(CONFIG_SYS_COREBOOT ) && !defined(CONFIG_EFI_STUB ) && \ + !defined(CONFIG_SPL_BUILD )/* * Implement a weak default function for boards that need to do some final init * before the system is ready.
@@ -202,7 +204,7 @@ __weak void board_final_cleanup(void) { } -int last_stage_init (void ) +static int last_stage_init (void ) {struct acpi_fadt __maybe_unused *fadt;int ret;
@@ -245,7 +247,9 @@ int last_stage_init(void) return 0; } -#endif +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init); + +#endif /* !SYS_COREBOOT && !EFI_STUB && !SPL_BUILD */ static int x86_init_cpus (void ) {
arch/x86/cpu/efi/payload.c +3 -1
@@ -9,6 +9,7 @@#include <efi.h> #include <efi_api.h> #include <errno.h> +#include <event.h> #include <init.h> #include <log.h> #include <usb.h>
@@ -168,7 +169,7 @@ int reserve_arch(void)return 0 ; } -int last_stage_init (void ) +static int last_stage_init (void ) {/* start usb so that usb keyboard can be used as input device */ if (IS_ENABLED (CONFIG_USB_KEYBOARD ))
@@ -176,6 +177,7 @@ int last_stage_init(void)return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);unsigned int install_e820_map (unsigned int max_entries,struct e820_entry *entries)
arch/x86/cpu/quark/quark.c +3 -1
@@ -107,7 +107,7 @@ static void quark_setup_bars(void) CONFIG_PCIE_ECAM_BASE | MEM_BAR_EN); } -static void quark_pcie_early_init (void ) +static int quark_pcie_early_init (void ) {/* * Step1: Assert PCIe signal PERST#
@@ -146,6 +146,8 @@ static void quark_pcie_early_init(void)/* Mixer Load Lane 1 */ msg_port_io_clrbits (MSG_PORT_PCIE_AFE ,PCIE_RXPICTRL0_L1 , (1 <<6 ) | (1 <<7 )); + +return 0 ; }static void quark_usb_early_init (void )
board/CZ.NIC/turris_mox/turris_mox.c +3 -1
@@ -15,6 +15,7 @@#include <dm.h> #include <dm/of_extra.h> #include <env.h> +#include <event.h> #include <fdt_support.h> #include <init.h> #include <led.h>
@@ -667,7 +668,7 @@ err:return NULL ; } -int last_stage_init (void ) +static int last_stage_init (void ) {struct gpio_desc reset_gpio = {};
@@ -712,6 +713,7 @@ handle_reset_btn:return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);#if defined(CONFIG_OF_BOARD_SETUP )
board/Marvell/mvebu_armada-37xx/board.c +4 -1
@@ -8,6 +8,7 @@#include <dm/device-internal.h> #include <env.h> #include <env_internal.h> +#include <event.h> #include <i2c.h> #include <init.h> #include <mmc.h>
@@ -301,7 +302,7 @@ static int mii_multi_chip_mode_write(struct udevice *bus, int dev_smi_addr, }/* Bring-up board-specific network stuff */ -int last_stage_init (void ) +static int last_stage_init (void ) {struct udevice *bus;ofnode node;
@@ -356,6 +357,8 @@ int last_stage_init(void) return 0; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init); +#endif #ifdef CONFIG_OF_BOARD_SETUP
board/Marvell/octeon_nic23/board.c +3 -1
@@ -5,6 +5,7 @@#include <cyclic.h> #include <dm.h> +#include <event.h> #include <ram.h> #include <time.h> #include <asm/gpio.h>
@@ -364,7 +365,7 @@ int board_late_init(void)return 0 ; } -int last_stage_init (void ) +static int last_stage_init (void ) {struct gpio_desc gpio = {};ofnode node;
@@ -386,3 +387,4 @@ int last_stage_init(void)return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);
board/Marvell/octeontx2/board.c +3 -1
@@ -12,6 +12,7 @@#include <asm/global_data.h> #include <dm/uclass-internal.h> #include <env.h> +#include <event.h> #include <init.h> #include <malloc.h> #include <net.h>
@@ -213,11 +214,12 @@ void board_acquire_flash_arb(bool acquire) } } -int last_stage_init (void ) +static int last_stage_init (void ) { (void )smc_flsf_fw_booted ();return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);static int do_go_uboot (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[])
board/cortina/presidio-asic/presidio.c +3 -1
@@ -4,6 +4,7 @@* */ #include <common.h> +#include <event.h> #include <init.h> #include <malloc.h> #include <errno.h>
@@ -121,7 +122,7 @@ void reset_cpu(void) }#ifdef CONFIG_LAST_STAGE_INIT -int last_stage_init (void ) +static int last_stage_init (void ) {u32 val;
@@ -134,4 +135,5 @@ int last_stage_init(void) return 0; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);#endif
board/emulation/qemu-ppce500/qemu-ppce500.c +3 -1
@@ -9,6 +9,7 @@#include <cpu_func.h> #include <dm.h> #include <env.h> +#include <event.h> #include <init.h> #include <log.h> #include <net.h>
@@ -184,7 +185,7 @@ int misc_init_r(void)return 0 ; } -int last_stage_init (void ) +static int last_stage_init (void ) {void *fdt =get_fdt_virt ();int len =0 ;
@@ -204,6 +205,7 @@ int last_stage_init(void)return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);static uint64_t get_linear_ram_size (void ) {
board/gdsys/a38x/controlcenterdc.c +14 -17
@@ -7,6 +7,7 @@#include <common.h> #include <command.h> #include <dm.h> +#include <event.h> #include <init.h> #include <miiphy.h> #include <net.h>
@@ -35,19 +36,6 @@ DECLARE_GLOBAL_DATA_PTR;#define DB_GP_88F68XX_GPP_POL_LOW 0x0#define DB_GP_88F68XX_GPP_POL_MID 0x0 -static int get_tpm (struct udevice **devp) -{ -int rc; - - rc =uclass_first_device_err (UCLASS_TPM , devp); -if (rc) { -printf ("Could not find TPM (ret=%d)\n" , rc); -return CMD_RET_FAILURE ; - } - -return 0 ; -} -/* * Define the DDR layout / topology here in the board file. This will * be used by the DDR3 init code in the SPL U-Boot version to configure
@@ -284,15 +272,22 @@ int board_fix_fdt(void *rw_fdt_blob)return 0 ; } -int last_stage_init (void ) +#ifndef CONFIG_SPL_BUILD +static int last_stage_init (void ) {struct udevice *tpm;int ret; -#ifndef CONFIG_SPL_BUILD +if (IS_ENABLED (CONFIG_SPL_BUILD )) +return 0 ;ccdc_eth_init (); -#endif - ret =get_tpm (&tpm); + + ret =uclass_first_device_err (UCLASS_TPM , &tpm); +if (ret) { +printf ("Could not find TPM (ret=%d)\n" , ret); +return ret; + } +if (ret ||tpm_init (tpm) ||tpm1_startup (tpm,TPM_ST_CLEAR ) ||tpm1_continue_self_test (tpm)) {return 1 ;
@@ -305,3 +300,5 @@ int last_stage_init(void) return 0; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init); +#endif
board/gdsys/mpc8308/gazerbeam.c +3 -1
@@ -9,6 +9,7 @@#include <command.h> #include <dm.h> #include <env.h> +#include <event.h> #include <fdt_support.h> #include <fsl_esdhc.h> #include <init.h>
@@ -124,7 +125,7 @@ static void display_osd_info(struct udevice *osd, osd_info->width, osd_info->height); } -int last_stage_init (void ) +static int last_stage_init (void ) {int fpga_hw_rev =0 ;int i;
@@ -179,6 +180,7 @@ int last_stage_init(void)return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);#if defined(CONFIG_OF_BOARD_SETUP )int ft_board_setup (void *blob,struct bd_info *bd)
board/ge/bx50v3/bx50v3.c +3 -1
@@ -5,6 +5,7 @@* Copyright 2012 Freescale Semiconductor, Inc. */ +#include <event.h> #include <image.h> #include <init.h> #include <asm/arch/clock.h>
@@ -531,7 +532,7 @@ static void remove_ethaddr_env_var(int index)env_set (env_var_name,NULL ); } -int last_stage_init (void ) +static int last_stage_init (void ) {int i;
@@ -544,6 +545,7 @@ int last_stage_init(void)return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);int checkboard (void ) {
board/keymile/km83xx/km83xx.c +3 -1
@@ -15,6 +15,7 @@#include <common.h> #include <env.h> +#include <event.h> #include <fdt_support.h> #include <init.h> #include <ioports.h>
@@ -184,7 +185,7 @@ int misc_init_r(void)return 0 ; } -int last_stage_init (void ) +static int last_stage_init (void ) {#if defined(CONFIG_TARGET_KMCOGE5NE )/*
@@ -202,6 +203,7 @@ int last_stage_init(void)set_km_env ();return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);static int fixed_sdram (void ) {
board/keymile/kmcent2/kmcent2.c +2 -1
@@ -261,7 +261,7 @@ int hush_init_var(void)return 0 ; } -int last_stage_init (void ) +static int last_stage_init (void ) {const char *kmem;/* DIP switch support on BFTIC */
@@ -287,6 +287,7 @@ int last_stage_init(void)return 0 ; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);void fdt_fixup_fman_mac_addresses (void *blob) {
board/keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c +1 -5
@@ -215,8 +215,4 @@ int hush_init_var(void)return 0 ; } -int last_stage_init (void ) -{ -set_km_env (); -return 0 ; -} +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , set_km_env);
board/phytium/durian/durian.c +3 -1
@@ -8,6 +8,7 @@#include <common.h> #include <command.h> #include <cpu_func.h> +#include <event.h> #include <init.h> #include <log.h> #include <asm/armv8/mmu.h>
@@ -99,7 +100,7 @@ int __asm_flush_l3_dcache(void)return 0 ; } -int last_stage_init (void ) +static int last_stage_init (void ) {int ret;
@@ -113,3 +114,4 @@ int last_stage_init(void) }return ret; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);
board/phytium/pomelo/pomelo.c +3 -1
@@ -7,6 +7,7 @@#include <stdio.h> #include <command.h> +#include <event.h> #include <init.h> #include <asm/armv8/mmu.h> #include <asm/io.h>
@@ -102,7 +103,7 @@ int __asm_flush_l3_dcache(void)return 0 ; } -int last_stage_init (void ) +static int last_stage_init (void ) {int ret;
@@ -116,3 +117,4 @@ int last_stage_init(void) }return ret; } +EVENT_SPY_SIMPLE (EVT_LAST_STAGE_INIT , last_stage_init);
common/Kconfig +1 -0
@@ -720,6 +720,7 @@ config SYS_FSL_CLK config LAST_STAGE_INIT bool "Call board-specific as last setup step" + select EVENT help Some boards need to perform initialisation immediately before control is passed to the command-line interpreter (e.g. for initializations
common/board_r.c +1 -8
@@ -773,15 +773,8 @@ static init_fnc_t init_sequence_r[] = {#ifdef CONFIG_POST initr_post,#endif -#ifdef CONFIG_LAST_STAGE_INIT INIT_FUNC_WATCHDOG_RESET - /* - * Some parts can be only initialized if all others (like - * Interrupts) are up and running (i.e. the PC-style ISA - * keyboard). - */ - last_stage_init, -#endif + INITCALL_EVENT(EVT_LAST_STAGE_INIT),#if defined(CFG_PRAM ) initr_mem,#endif
common/event.c +1 -0
@@ -36,6 +36,7 @@ const char *const type_name[] = {/* init hooks */ "misc_init_f" ,"fsp_init_r" , +"last_stage_init" ,/* Fpga load hook */ "fpga_load",
configs/bayleybay_defconfig +0 -1
@@ -25,7 +25,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/cherryhill_defconfig +0 -1
@@ -18,7 +18,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/chromebook_coral_defconfig +0 -1
@@ -40,7 +40,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_LOG=y CONFIG_LOGF_FUNC=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_BLOBLIST=y # CONFIG_TPL_BLOBLIST is not set CONFIG_BLOBLIST_ADDR=0x100000
configs/chromebook_link64_defconfig +0 -1
@@ -29,7 +29,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_MISC_INIT_R=y CONFIG_SPL_NO_BSS_LIMIT=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y
configs/chromebook_link_defconfig +0 -1
@@ -25,7 +25,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_MISC_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532
configs/chromebook_samus_defconfig +0 -1
@@ -25,7 +25,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_MISC_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532
configs/chromebook_samus_tpl_defconfig +0 -1
@@ -30,7 +30,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_MISC_INIT_R=y CONFIG_BLOBLIST=y CONFIG_BLOBLIST_ADDR=0xff7c0000
configs/chromebox_panther_defconfig +0 -1
@@ -21,7 +21,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_MISC_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532
configs/conga-qeval20-qa3-e3845-internal-uart_defconfig +0 -1
@@ -31,7 +31,6 @@ CONFIG_BOOTCOMMAND="load scsi 0:2 03000000 /boot/vmlinuz-${kernel-ver}-generic;l CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/conga-qeval20-qa3-e3845_defconfig +0 -1
@@ -27,7 +27,6 @@ CONFIG_BOOTCOMMAND="load scsi 0:2 03000000 /boot/vmlinuz-${kernel-ver}-generic;l CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/coreboot64_defconfig +0 -1
@@ -19,7 +19,6 @@ CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_SPL_NO_BSS_LIMIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532
configs/coreboot_defconfig +0 -1
@@ -20,7 +20,6 @@ CONFIG_LOG=y CONFIG_LOGF_LINE=y CONFIG_LOGF_FUNC=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_PCI_INIT_R=y CONFIG_CMD_MMC=y CONFIG_CMD_PART=y
configs/cougarcanyon2_defconfig +0 -1
@@ -20,7 +20,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/crownbay_defconfig +0 -1
@@ -21,7 +21,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/dfi-bt700-q7x-151_defconfig +0 -1
@@ -26,7 +26,6 @@ CONFIG_BOOTCOMMAND="load scsi 0:1 03000000 /boot/vmlinuz-${kernel-ver}-generic;l CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/edison_defconfig +0 -1
@@ -13,7 +13,6 @@ CONFIG_TARGET_EDISON=y CONFIG_SMP=y CONFIG_SYS_MONITOR_BASE=0x01101000 CONFIG_BOARD_EARLY_INIT_R=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_MAXARGS=128 CONFIG_SYS_CBSIZE=2048
configs/efi-x86_app32_defconfig +0 -1
@@ -16,7 +16,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_BOOTZ=y
configs/efi-x86_app64_defconfig +0 -1
@@ -17,7 +17,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_BOOTZ=y
configs/efi-x86_payload32_defconfig +0 -1
@@ -15,7 +15,6 @@ CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_IDE=y
configs/efi-x86_payload64_defconfig +0 -1
@@ -15,7 +15,6 @@ CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_IDE=y
configs/galileo_defconfig +0 -1
@@ -17,7 +17,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/minnowmax_defconfig +0 -1
@@ -30,7 +30,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_MISC_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532
configs/qemu-x86_64_defconfig +1 -2
@@ -33,7 +33,6 @@ CONFIG_LOG=y CONFIG_LOGF_FUNC=y CONFIG_SPL_LOG=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_PCI_INIT_R=y CONFIG_BLOBLIST=y CONFIG_BLOBLIST_ADDR=0x10000
@@ -84,11 +83,11 @@ CONFIG_SPL_DM_RTC=y CONFIG_SYS_NS16550_PORT_MAPPED=y CONFIG_SPI=y CONFIG_USB_KEYBOARD=y -CONFIG_SPL_VIDEO=y CONFIG_FRAMEBUFFER_SET_VESA_MODE=y CONFIG_FRAMEBUFFER_VESA_MODE_USER=y CONFIG_FRAMEBUFFER_VESA_MODE=0x144 CONFIG_CONSOLE_SCROLL_LINES=5 +CONFIG_SPL_VIDEO=y # CONFIG_SPL_USE_TINY_PRINTF is not set CONFIG_GENERATE_ACPI_TABLE=y # CONFIG_GZIP is not set
configs/qemu-x86_defconfig +0 -1
@@ -23,7 +23,6 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_LOG=y CONFIG_LOGF_FUNC=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_PCI_INIT_R=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/som-db5800-som-6867_defconfig +0 -1
@@ -27,7 +27,6 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/theadorable-x86-conga-qa3-e3845-pcie-x4_defconfig +0 -1
@@ -26,7 +26,6 @@ CONFIG_SHOW_BOOT_PROGRESS=y CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/theadorable-x86-conga-qa3-e3845_defconfig +0 -1
@@ -25,7 +25,6 @@ CONFIG_SHOW_BOOT_PROGRESS=y CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
configs/theadorable-x86-dfi-bt700_defconfig +0 -1
@@ -24,7 +24,6 @@ CONFIG_SHOW_BOOT_PROGRESS=y CONFIG_USE_PREBOOT=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y -CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PBSIZE=532 CONFIG_CMD_CPU=y
include/event.h +12 -0
@@ -41,6 +41,18 @@ enum event_t {*/ EVT_FSP_INIT_F , +/* +* Emitted just before jumping to the main loop +* +* Some boards need to perform initialisation immediately before control +* is passed to the command-line interpreter (e.g. for init that depend +* on later phases in the init sequence). +* +* Some parts can be only initialized if all others (like Interrupts) +* are up and running (e.g. the PC-style ISA keyboard). +*/ +EVT_LAST_STAGE_INIT , +/* Fpga load hook */ EVT_FPGA_LOAD,
include/init.h +0 -1
@@ -270,7 +270,6 @@ void board_init_r(struct global_data *id, ulong dest_addr) __attribute__ ((noreturn));int cpu_init_r (void ); -int last_stage_init (void );int mac_read_from_eeprom (void );int set_cpu_clk_info (void );int update_flash_size (int flash_size);
Signature · 1 line
2.42.0.rc1.204.g551eb34607-goog
Quoted 8 lines · Simon Glass
This series replaces some more of the init hooks in
board_f.candboard_r.cwith events. Notably it convertslast_state_init()over.It also provides a 'simple' event spy, which takes no arguments. It turns out that this is quite a common case, so it is worth optimising for this, to reduce code size, before events become too commonly used.
[...]
Applied to u-boot/next, thanks!
Signature · 1 line
Tom