Skip to contentSkip to conversation

fwu: Call EFI stack initialization after preboot

PATCH Superseded Michal Simek 2 participants 5 messages Mar 10 – Mar 17

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover fwu: Call EFI stack initialization after preboot

Hi,

the whole series is trying to address issues we have on platforms where usb and ufs init are not done before efi initialization. This is happenin on platforms where A/B update is enabled. FWU code is called early and do EFI initialization before usb and ufs started that's why they are not visible.

We are workarounding it by starting usb/ufs from board file but this should be more generic approach.

Thanks,
Michal

Michal Simek (2):
event: Introduce EVT_POST_PREBOOT event
fwu: Move boottime checks to EVT_POST_PREBOOT

 common/main.c         | 3 +++
 include/event.h       | 9 +++++++++
 lib/fwu_updates/fwu.c | 2 +-
 3 files changed, 13 insertions(+), 1 deletion(-)
Signature · 4 lines
2.43.0

base-commit: e5387628c1d64caf7bcabb5d99d2987bd5bff617
branch: debian-sent3
#1 lore raw

PATCH 1/2 event: Introduce EVT_POST_PREBOOT event

Add a new EVT_POST_PREBOOT event type which is fired in main_loop() after the preboot command has been executed.

---

 common/main.c   | 3 +++
 include/event.h | 9 +++++++++
 2 files changed, 12 insertions(+)
common/main.c +3 -0
index b0b6e74f5d3d..e8b23f3ff293 100644
@@ -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,8 @@ void main_loop(void)
 	if (IS_ENABLED(CONFIG_USE_PREBOOT))
 		run_preboot_environment_command();
 
+	event_notify_null(EVT_POST_PREBOOT);
+
 	if (IS_ENABLED(CONFIG_UPDATE_TFTP))
 		update_tftp(0UL, NULL, NULL);
 
include/event.h +9 -0
index 1d267f1d1054..3ce5f992b04e 100644
@@ -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
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/2] event: Introduce EVT_POST_PREBOOT event

Hi Michal,

Quoted 24 lines · Michal Simek

Add a new EVT_POST_PREBOOT event type which is fired in main_loop() after the preboot command has been executed.

---

 common/main.c   | 3 +++
 include/event.h | 9 +++++++++
 2 files changed, 12 insertions(+)
common/main.c +1 -0
index b0b6e74f5d3d..e8b23f3ff293 100644
@@ -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)
 {

common/main.c void main_loop(void) · line 57

Quoted 4 lines
common/main.c +1 -0
@@ -53,6 +54,8 @@ void main_loop(void)
        if (IS_ENABLED(CONFIG_USE_PREBOOT))
                run_preboot_environment_command();
 
+       event_notify_null(EVT_POST_PREBOOT);

This needs error checking if you wish to honour your comment below (which I agree with).

Quoted 25 lines
common/main.c +1 -0
+
        if (IS_ENABLED(CONFIG_UPDATE_TFTP))
                update_tftp(0UL, NULL, NULL);
 
include/event.h +9 -1
index 1d267f1d1054..3ce5f992b04e 100644
@@ -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
--
Quoted 2 lines

2.43.0

Regards,
SImon

#3 lore raw

Re: [PATCH 1/2] event: Introduce EVT_POST_PREBOOT event

Quoted 30 lines · Simon Glass

Hi Michal,

Quoted 27 lines · Michal Simek

Add a new EVT_POST_PREBOOT event type which is fired in main_loop() after the preboot command has been executed.

---

  common/main.c   | 3 +++
  include/event.h | 9 +++++++++
  2 files changed, 12 insertions(+)
common/main.c +1 -0
index b0b6e74f5d3d..e8b23f3ff293 100644
@@ -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,8 @@ void main_loop(void)
         if (IS_ENABLED(CONFIG_USE_PREBOOT))
                 run_preboot_environment_command();
 
Quoted 4 lines

common/main.c void main_loop(void) · line 57

Quoted 1 line
common/main.c +1 -0
+       event_notify_null(EVT_POST_PREBOOT);

This needs error checking if you wish to honour your comment below (which I agree with).

ok. I will also fix this one which should check it too.

event_notify_null(EVT_MAIN_LOOP);

M

#4 lore raw

PATCH 2/2 fwu: Move boottime checks to EVT_POST_PREBOOT

In reply to Michal Simek

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.

---

 lib/fwu_updates/fwu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/fwu_updates/fwu.c +1 -1
index 37c613014d18..e82600a29a40 100644
@@ -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);
Signature · 1 line
2.43.0