[Concept,14/15] boot: Run the EFI bootmgr just before network devices

Message ID 20250930005137.3650600-15-sjg@u-boot.org
State New
Headers
Series boot: Support priority for global bootmeths |

Commit Message

Simon Glass Sept. 30, 2025, 12:51 a.m. UTC
  From: Simon Glass <sjg@chromium.org>

At present the EFI bootmgr scans all devices in the system before
deciding which one to boot. Ideally it would use the bootstd iterator
for this, but in the meantime, give it a lower priority, so it runs
just before the network devices.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 boot/bootmeth_efi_mgr.c | 1 +
 test/boot/bootflow.c    | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
  

Comments

Heinrich Schuchardt Sept. 30, 2025, 1:58 a.m. UTC | #1
Am 30. September 2025 02:51:30 MESZ schrieb Simon Glass <sjg@u-boot.org>:
>From: Simon Glass <sjg@chromium.org>
>
>At present the EFI bootmgr scans all devices in the system before
>deciding which one to boot. Ideally it would use the bootstd iterator
>for this, but in the meantime, give it a lower priority, so it runs
>just before the network devices.
>
>Signed-off-by: Simon Glass <sjg@chromium.org>
>---
>
> boot/bootmeth_efi_mgr.c | 1 +
> test/boot/bootflow.c    | 4 ++--
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
>diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
>index 5e83d1da103..917cec2fe64 100644
>--- a/boot/bootmeth_efi_mgr.c
>+++ b/boot/bootmeth_efi_mgr.c
>@@ -98,6 +98,7 @@ static int bootmeth_efi_mgr_bind(struct udevice *dev)
> 
> 	plat->desc = "EFI bootmgr flow";
> 	plat->flags = BOOTMETHF_GLOBAL;
>+	plat->glob_prio = BOOTDEVP_6_NET_BASE;

Is this meant to work because at each priority level, global methods will be treated first? Maybe mention this in the commit message.

Adding a code comment here why this priority was chosen would be helpful.

> 
> 	return 0;
> }
>diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
>index ceab3c453c4..65e2b5b5c9d 100644
>--- a/test/boot/bootflow.c
>+++ b/test/boot/bootflow.c
>@@ -495,11 +495,11 @@ static int bootflow_system(struct unit_test_state *uts)
> 	ut_assertok(device_probe(dev));
> 	sandbox_set_fake_efi_mgr_dev(dev, true);
> 
>-	/* We should get a single 'bootmgr' method at the start */
>+	/* We should get a single 'bootmgr' method at the end */
> 	bootstd_clear_glob();
> 	ut_assertok(run_command("bootflow scan -lH", 0));
> 	ut_assert_skip_to_line(
>-		"  0  efi_mgr      ready   (none)       0  <NULL>                    ");
>+		"  1  efi_mgr      ready   (none)       0  <NULL>                    ");
> 	ut_assert_skip_to_line("No more bootdevs");
> 	ut_assert_skip_to_line("(2 bootflows, 2 valid)");
> 	ut_assert_console_end();
  

Patch

diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c
index 5e83d1da103..917cec2fe64 100644
--- a/boot/bootmeth_efi_mgr.c
+++ b/boot/bootmeth_efi_mgr.c
@@ -98,6 +98,7 @@  static int bootmeth_efi_mgr_bind(struct udevice *dev)
 
 	plat->desc = "EFI bootmgr flow";
 	plat->flags = BOOTMETHF_GLOBAL;
+	plat->glob_prio = BOOTDEVP_6_NET_BASE;
 
 	return 0;
 }
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index ceab3c453c4..65e2b5b5c9d 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -495,11 +495,11 @@  static int bootflow_system(struct unit_test_state *uts)
 	ut_assertok(device_probe(dev));
 	sandbox_set_fake_efi_mgr_dev(dev, true);
 
-	/* We should get a single 'bootmgr' method at the start */
+	/* We should get a single 'bootmgr' method at the end */
 	bootstd_clear_glob();
 	ut_assertok(run_command("bootflow scan -lH", 0));
 	ut_assert_skip_to_line(
-		"  0  efi_mgr      ready   (none)       0  <NULL>                    ");
+		"  1  efi_mgr      ready   (none)       0  <NULL>                    ");
 	ut_assert_skip_to_line("No more bootdevs");
 	ut_assert_skip_to_line("(2 bootflows, 2 valid)");
 	ut_assert_console_end();