From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] boot: do not attempt booting bootsource more than once
Date: Mon, 26 Jan 2026 11:44:56 +0100 [thread overview]
Message-ID: <20260126104457.781763-1-a.fatoum@pengutronix.de> (raw)
storage.builtin and storage.removable do not overlap, but bootsource
can overlap with one of them leading to confusing output, when the
bootsource has nothing bootable as the boot will be attempted twice.
Add a new .nonbootsource specialization and use that in the default.
While at it, also drop the unused bootcdev.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/boot.c | 4 ++--
common/cdev-alias.c | 23 +++++++++++++++--------
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/common/boot.c b/common/boot.c
index 7b2ce4740759..e400a4fcb8b3 100644
--- a/common/boot.c
+++ b/common/boot.c
@@ -138,8 +138,8 @@ static int init_boot(void)
global_boot_default = xstrdup(
IF_ENABLED(CONFIG_EFI_LOADER_BOOTMGR, "efibootmgr ")
IF_ENABLED(CONFIG_BOOT_DEFAULTS, "bootsource ")
- IF_ENABLED(CONFIG_BOOT_DEFAULTS, "storage.builtin ")
- IF_ENABLED(CONFIG_BOOT_DEFAULTS, "storage.removable ")
+ IF_ENABLED(CONFIG_BOOT_DEFAULTS, "storage.builtin.nonbootsource ")
+ IF_ENABLED(CONFIG_BOOT_DEFAULTS, "storage.removable.nonbootsource ")
"net"
);
diff --git a/common/cdev-alias.c b/common/cdev-alias.c
index 82b91108c1fc..ca5048f35a26 100644
--- a/common/cdev-alias.c
+++ b/common/cdev-alias.c
@@ -82,6 +82,8 @@ static int cdev_alias_resolve_diskuuid(struct cdev_alias_res *cdev_alias_res,
#define STORAGE_REMOVABLE BIT(0)
#define STORAGE_BUILTIN BIT(1)
+#define STORAGE_NONBOOTSOURCE BIT(31)
+
/**
* call_for_each_storage() - invoke callback for each storage medium
*
@@ -136,24 +138,29 @@ static int cdev_alias_resolve_storage(struct cdev_alias_res *cdev_alias_res,
cdev_alias_processor_t fn,
void *data)
{
- struct cdev *bootcdev;
unsigned filter = 0;
- int bootsource, nmatches;
+ int bootsource = 0, nmatches;
if (!class)
- filter = ~0;
+ filter = STORAGE_REMOVABLE | STORAGE_BUILTIN;
+ else if (streq_ptr(class, "nonbootsource"))
+ filter = STORAGE_REMOVABLE | STORAGE_BUILTIN | STORAGE_NONBOOTSOURCE;
else if (streq_ptr(class, "removable"))
filter |= STORAGE_REMOVABLE;
else if (streq_ptr(class, "builtin"))
filter |= STORAGE_BUILTIN;
+ else if (streq_ptr(class, "removable.nonbootsource"))
+ filter |= STORAGE_REMOVABLE | STORAGE_NONBOOTSOURCE;
+ else if (streq_ptr(class, "builtin.nonbootsource"))
+ filter |= STORAGE_BUILTIN | STORAGE_NONBOOTSOURCE;
else
return -EINVAL;
- bootcdev = bootsource_of_cdev_find();
-
- bootsource = call_for_each_storage(fn, data, filter, true);
- if (bootsource < 0)
- return bootsource;
+ if (!(filter & STORAGE_NONBOOTSOURCE)) {
+ bootsource = call_for_each_storage(fn, data, filter, true);
+ if (bootsource < 0)
+ return bootsource;
+ }
nmatches = call_for_each_storage(fn, data, filter, false);
if (nmatches < 0)
--
2.47.3
next reply other threads:[~2026-01-26 10:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 10:44 Ahmad Fatoum [this message]
2026-01-27 7:54 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260126104457.781763-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox