mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] boot: do not attempt booting bootsource more than once
@ 2026-01-26 10:44 Ahmad Fatoum
  2026-01-27  7:54 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2026-01-26 10:44 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH master] boot: do not attempt booting bootsource more than once
  2026-01-26 10:44 [PATCH master] boot: do not attempt booting bootsource more than once Ahmad Fatoum
@ 2026-01-27  7:54 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2026-01-27  7:54 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Mon, 26 Jan 2026 11:44:56 +0100, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] boot: do not attempt booting bootsource more than once
      https://git.pengutronix.de/cgit/barebox/commit/?id=6cb2c1fbee99 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-27  7:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-26 10:44 [PATCH master] boot: do not attempt booting bootsource more than once Ahmad Fatoum
2026-01-27  7:54 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox