[PATCH v2 08/17] boot: Add a flag for whether there are global bootmeths

Simon Glass sjg at chromium.org
Wed Oct 1 23:26:33 CEST 2025


The current 'doing_global' refers to being in the state of processing
global bootmeths. Since global bootmeths are currently used once at the
start, it becomes false once the last global bootmeth has been used.

In preparation for allowing bootmeths to run at other points in the
bootstd interation, add a new 'have_global' flag which tracks whether
there are any global bootmeths in the method_order[] list. It is set up
when iteration starts. Unlike doing_global which resets back to false
after the global bootmeths have been handled, once have_global is set to
true, it remains true for the entire iteration process. This provides a
quick check as to whether global-bootmeth processing is needed.

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

(no changes since v1)

 boot/bootmeth-uclass.c | 1 +
 include/bootflow.h     | 2 ++
 test/boot/bootflow.c   | 4 ++++
 3 files changed, 7 insertions(+)

diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 918d78ec2c9..e95a8a801c4 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -208,6 +208,7 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global)
 	    iter->first_glob_method != -1 && iter->first_glob_method != count) {
 		iter->cur_method = iter->first_glob_method;
 		iter->doing_global = true;
+		iter->have_global = true;
 	}
 	iter->method_order = order;
 	iter->num_methods = count;
diff --git a/include/bootflow.h b/include/bootflow.h
index b1efeee3259..157a16d44b9 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -255,6 +255,7 @@ enum bootflow_meth_flags_t {
  * @cur_prio: Current priority being scanned
  * @method_order: List of bootmeth devices to use, in order. The normal methods
  *	appear first, then the global ones, if any
+ * @have_global: true if we have global bootmeths in @method_order[]
  * @doing_global: true if we are iterating through the global bootmeths (which
  *	happens before the normal ones)
  * @method_flags: flags controlling which methods should be used for this @dev
@@ -278,6 +279,7 @@ struct bootflow_iter {
 	int first_glob_method;
 	enum bootdev_prio_t cur_prio;
 	struct udevice **method_order;
+	bool have_global;
 	bool doing_global;
 	int method_flags;
 };
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index a65fcd3d4e3..c766bfcf683 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -308,6 +308,7 @@ static int bootflow_iter(struct unit_test_state *uts)
 	ut_asserteq_str("extlinux", iter.method->name);
 	ut_asserteq(0, bflow.err);
 	ut_assert(!iter.doing_global);
+	ut_assert(!iter.have_global);
 	ut_asserteq(-1, iter.first_glob_method);
 
 	/*
@@ -406,6 +407,7 @@ static int bootflow_iter_glob(struct unit_test_state *uts)
 	bootflow_show(0, &bflow, true);
 	ut_asserteq(3, iter.num_methods);
 	ut_assert(iter.doing_global);
+	ut_assert(iter.have_global);
 	ut_asserteq(2, iter.first_glob_method);
 
 	ut_asserteq(2, iter.cur_method);
@@ -422,6 +424,7 @@ static int bootflow_iter_glob(struct unit_test_state *uts)
 	ut_asserteq(2, iter.num_methods);
 	ut_asserteq(2, iter.first_glob_method);
 	ut_assert(!iter.doing_global);
+	ut_assert(iter.have_global);
 
 	ut_asserteq(0, iter.cur_method);
 	ut_asserteq(0, iter.part);
@@ -487,6 +490,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts)
 	/* at this point the global bootmeths are stranded above num_methods */
 	ut_asserteq(3, iter.num_methods);
 	ut_assert(!iter.doing_global);
+	ut_assert(iter.have_global);
 	ut_asserteq(3, iter.first_glob_method);
 	ut_asserteq_str("sandbox", iter.method->name);
 	ut_assertok(inject_response(uts));
-- 
2.43.0



More information about the U-Boot mailing list