[PATCH v2 13/17] boot: Implement a priority for global bootmeths
Simon Glass
sjg at chromium.org
Wed Oct 1 23:26:38 CEST 2025
Allow bootmeths to select when they want to run, using the bootdev
priority. Provide a new bootmeth_glob_allowed() function which checks if
a bootmeth is ready to use.
Fix a comment in bootflow_system() which is a test for global bootmeths.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
boot/bootflow.c | 15 +++++++++++----
include/bootflow.h | 2 +-
include/bootmeth.h | 4 ++++
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/boot/bootflow.c b/boot/bootflow.c
index 5080096cd11..d4c842c00fd 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -249,17 +249,24 @@ static void scan_next_in_uclass(struct udevice **devp)
* bootmeth_glob_allowed() - Check if a global bootmeth is usable at this point
*
* @iter: Bootflow iterator being used
- * Return: true if the global bootmeth has not already been used
+ * Return: true if the global bootmeth has a suitable priority and has not
+ * already been used
*/
static bool bootmeth_glob_allowed(struct bootflow_iter *iter, int meth_seq)
{
struct udevice *meth = iter->method_order[meth_seq];
bool done = iter->methods_done & BIT(meth_seq);
+ struct bootmeth_uc_plat *ucp;
- log_debug("considering glob '%s': done %d\n", meth->name, done);
+ ucp = dev_get_uclass_plat(meth);
+ log_debug("considering glob '%s': done %d glob_prio %d\n", meth->name,
+ done, ucp->glob_prio);
- /* if this one has already been used, try the next */
- if (done)
+ /*
+ * if this one has already been used, or its priority is too low, try
+ * the next
+ */
+ if (done || ucp->glob_prio > iter->cur_prio)
return false;
return true;
diff --git a/include/bootflow.h b/include/bootflow.h
index ec19f8dc436..10c22d15d52 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -262,7 +262,7 @@ enum {
* 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)
+ * generally happens before the normal ones)
* @method_flags: flags controlling which methods should be used for this @dev
* (enum bootflow_meth_flags_t)
* @methods_done: indicates which methods have been processed, one bit for
diff --git a/include/bootmeth.h b/include/bootmeth.h
index 26de593a9a4..2a492dfd73a 100644
--- a/include/bootmeth.h
+++ b/include/bootmeth.h
@@ -30,10 +30,14 @@ enum bootmeth_flags {
*
* @desc: A long description of the bootmeth
* @flags: Flags for this bootmeth (enum bootmeth_flags)
+ * @glob_prio: Priority for this bootmeth. If unset (0) the bootmeth is started
+ * before all other bootmeths. Otherwise it is started before the iteration
+ * reaches the given priority.
*/
struct bootmeth_uc_plat {
const char *desc;
int flags;
+ enum bootdev_prio_t glob_prio;
};
/** struct bootmeth_ops - Operations for boot methods */
--
2.43.0
More information about the U-Boot
mailing list