* [PATCH v4 1/3] event: Check return value from event_notify_null()
2026-04-02 15:36 [PATCH v4 0/3] fwu: Call EFI stack initialization after preboot Michal Simek
@ 2026-04-02 15:36 ` Michal Simek
2026-04-02 15:36 ` [PATCH v4 2/3] event: Introduce EVT_POST_PREBOOT event Michal Simek
2026-04-02 15:37 ` [PATCH v4 3/3] fwu: Move boottime checks to EVT_POST_PREBOOT Michal Simek
2 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2026-04-02 15:36 UTC (permalink / raw)
To: u-boot, git, xypron.glpk, ilias.apalodimas, sjg
Cc: Jerome Forissier, Leo Yu-Chi Liang, Marek Vasut, Quentin Schulz,
Tom Rini, Yao Zi
event_notify_null() returns int but its return value is not
checked in run_main_loop() and in fwu_mdata tests.
Add proper error checking to all unchecked call sites.
Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
(no changes since v2)
Changes in v2:
- new patch in series
common/board_r.c | 6 +++++-
test/dm/fwu_mdata.c | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/common/board_r.c b/common/board_r.c
index 8cf0e14679c0..5d37345ca09d 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -569,11 +569,15 @@ static int dm_announce(void)
static int run_main_loop(void)
{
+ int ret;
+
#ifdef CONFIG_SANDBOX
sandbox_main_loop_init();
#endif
- event_notify_null(EVT_MAIN_LOOP);
+ ret = event_notify_null(EVT_MAIN_LOOP);
+ if (ret)
+ return ret;
/* main_loop() can return to retry autoboot, if so just run it again */
for (;;)
diff --git a/test/dm/fwu_mdata.c b/test/dm/fwu_mdata.c
index b7680632f95f..643b647af0a9 100644
--- a/test/dm/fwu_mdata.c
+++ b/test/dm/fwu_mdata.c
@@ -100,7 +100,7 @@ static int dm_test_fwu_mdata_read(struct unit_test_state *uts)
* Trigger lib/fwu_updates/fwu.c fwu_boottime_checks()
* to populate g_dev global pointer in that library.
*/
- event_notify_null(EVT_MAIN_LOOP);
+ ut_assertok(event_notify_null(EVT_MAIN_LOOP));
ut_assertok(uclass_first_device_err(UCLASS_FWU_MDATA, &dev));
ut_assertok(fwu_init());
@@ -127,7 +127,7 @@ static int dm_test_fwu_mdata_write(struct unit_test_state *uts)
* Trigger lib/fwu_updates/fwu.c fwu_boottime_checks()
* to populate g_dev global pointer in that library.
*/
- event_notify_null(EVT_MAIN_LOOP);
+ ut_assertok(event_notify_null(EVT_MAIN_LOOP));
ut_assertok(uclass_first_device_err(UCLASS_FWU_MDATA, &dev));
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v4 2/3] event: Introduce EVT_POST_PREBOOT event
2026-04-02 15:36 [PATCH v4 0/3] fwu: Call EFI stack initialization after preboot Michal Simek
2026-04-02 15:36 ` [PATCH v4 1/3] event: Check return value from event_notify_null() Michal Simek
@ 2026-04-02 15:36 ` Michal Simek
2026-04-02 15:37 ` [PATCH v4 3/3] fwu: Move boottime checks to EVT_POST_PREBOOT Michal Simek
2 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2026-04-02 15:36 UTC (permalink / raw)
To: u-boot, git, xypron.glpk, ilias.apalodimas, sjg; +Cc: Casey Connolly, Tom Rini
Add a new EVT_POST_PREBOOT event type which is fired in main_loop()
after the preboot command has been executed.
Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
(no changes since v3)
Changes in v3:
- add missing type_name extension
Changes in v2:
- check return value
common/event.c | 3 +++
common/main.c | 4 ++++
include/event.h | 9 +++++++++
3 files changed, 16 insertions(+)
diff --git a/common/event.c b/common/event.c
index 8d7513eb10b6..398e713d2f82 100644
--- a/common/event.c
+++ b/common/event.c
@@ -49,6 +49,9 @@ const char *const type_name[] = {
/* main loop events */
"main_loop",
+ /* post preboot events */
+ "post_preboot",
+
/* livetree has been built */
"of_live_init",
};
diff --git a/common/main.c b/common/main.c
index b0b6e74f5d3d..4b4504557f6e 100644
--- a/common/main.c
+++ b/common/main.c
@@ -19,6 +19,7 @@
#include <net.h>
#include <version_string.h>
#include <efi_loader.h>
+#include <event.h>
static void run_preboot_environment_command(void)
{
@@ -53,6 +54,9 @@ void main_loop(void)
if (IS_ENABLED(CONFIG_USE_PREBOOT))
run_preboot_environment_command();
+ if (event_notify_null(EVT_POST_PREBOOT))
+ return;
+
if (IS_ENABLED(CONFIG_UPDATE_TFTP))
update_tftp(0UL, NULL, NULL);
diff --git a/include/event.h b/include/event.h
index 1d267f1d1054..3ce5f992b04e 100644
--- a/include/event.h
+++ b/include/event.h
@@ -153,6 +153,15 @@ enum event_t {
*/
EVT_MAIN_LOOP,
+ /**
+ * @EVT_POST_PREBOOT:
+ * This event is triggered in main_loop() after the preboot command
+ * has run, so that devices initialised by preboot (e.g. USB, UFS)
+ * are available to event handlers. Its parameter is NULL.
+ * A non-zero return value causes the boot to fail.
+ */
+ EVT_POST_PREBOOT,
+
/**
* @EVT_OF_LIVE_BUILT:
* This event is triggered immediately after the live device tree has been
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v4 3/3] fwu: Move boottime checks to EVT_POST_PREBOOT
2026-04-02 15:36 [PATCH v4 0/3] fwu: Call EFI stack initialization after preboot Michal Simek
2026-04-02 15:36 ` [PATCH v4 1/3] event: Check return value from event_notify_null() Michal Simek
2026-04-02 15:36 ` [PATCH v4 2/3] event: Introduce EVT_POST_PREBOOT event Michal Simek
@ 2026-04-02 15:37 ` Michal Simek
2026-04-02 16:14 ` [v4,3/3] " Simon Glass
2 siblings, 1 reply; 5+ messages in thread
From: Michal Simek @ 2026-04-02 15:37 UTC (permalink / raw)
To: u-boot, git, xypron.glpk, ilias.apalodimas, sjg
Cc: Kory Maincent, Padmarao Begari, Sughosh Ganu, Tom Rini
Switch fwu_boottime_checks() from EVT_MAIN_LOOP to EVT_POST_PREBOOT
because there is no reason to call FWU so early. FWU triggers EFI
stack initialization before all devices are visible which prevents
the EFI stack from scanning these devices and adding them to EFI
variables.
Signed-off-by: Michal Simek <michal.simek@amd.com>
---
Changes in v4:
- update dm tests
lib/fwu_updates/fwu.c | 2 +-
test/dm/fwu_mdata.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c
index 37c613014d18..e82600a29a40 100644
--- a/lib/fwu_updates/fwu.c
+++ b/lib/fwu_updates/fwu.c
@@ -796,4 +796,4 @@ static int fwu_boottime_checks(void)
return 0;
}
-EVENT_SPY_SIMPLE(EVT_MAIN_LOOP, fwu_boottime_checks);
+EVENT_SPY_SIMPLE(EVT_POST_PREBOOT, fwu_boottime_checks);
diff --git a/test/dm/fwu_mdata.c b/test/dm/fwu_mdata.c
index 643b647af0a9..cfe543d8a236 100644
--- a/test/dm/fwu_mdata.c
+++ b/test/dm/fwu_mdata.c
@@ -100,7 +100,7 @@ static int dm_test_fwu_mdata_read(struct unit_test_state *uts)
* Trigger lib/fwu_updates/fwu.c fwu_boottime_checks()
* to populate g_dev global pointer in that library.
*/
- ut_assertok(event_notify_null(EVT_MAIN_LOOP));
+ ut_assertok(event_notify_null(EVT_POST_PREBOOT));
ut_assertok(uclass_first_device_err(UCLASS_FWU_MDATA, &dev));
ut_assertok(fwu_init());
@@ -127,7 +127,7 @@ static int dm_test_fwu_mdata_write(struct unit_test_state *uts)
* Trigger lib/fwu_updates/fwu.c fwu_boottime_checks()
* to populate g_dev global pointer in that library.
*/
- ut_assertok(event_notify_null(EVT_MAIN_LOOP));
+ ut_assertok(event_notify_null(EVT_POST_PREBOOT));
ut_assertok(uclass_first_device_err(UCLASS_FWU_MDATA, &dev));
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [v4,3/3] fwu: Move boottime checks to EVT_POST_PREBOOT
2026-04-02 15:37 ` [PATCH v4 3/3] fwu: Move boottime checks to EVT_POST_PREBOOT Michal Simek
@ 2026-04-02 16:14 ` Simon Glass
0 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2026-04-02 16:14 UTC (permalink / raw)
To: michal.simek; +Cc: u-boot, git, xypron.glpk, ilias.apalodimas, sjg
On 2026-04-02T15:36:57, Michal Simek <michal.simek@amd.com> wrote:
> fwu: Move boottime checks to EVT_POST_PREBOOT
> fwu: Move boottime checks to EVT_POST_PREBOOT
>
> Switch fwu_boottime_checks() from EVT_MAIN_LOOP to EVT_POST_PREBOOT
> because there is no reason to call FWU so early. FWU triggers EFI
> stack initialization before all devices are visible which prevents
> the EFI stack from scanning these devices and adding them to EFI
> variables.
>
> Signed-off-by: Michal Simek <michal.simek@amd.com>
>
> lib/fwu_updates/fwu.c | 2 +-
> test/dm/fwu_mdata.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 5+ messages in thread