Skip to contentSkip to conversation

bootdev: few fixes for automatic boot

PATCH Superseded [email protected] 3 participants 7 messages Jun 11 – Jun 14

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover bootdev: few fixes for automatic boot

This mini-series addresses few findings in bootdev code.

Patch 1 some typo fixes in bootdev header.

Patch 2 fix for automatic boots in case of high-priority bootdev
cannot be hunted.

Denis Mukhin (2):
bootdev: fix typos
bootdev: scan boot devices at each priority level

 boot/bootdev-uclass.c | 2 --
 include/bootdev.h     | 8 ++++----
 2 files changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.54.0
#1 lore raw

PATCH 1/2 bootdev: fix typos

From: Denis Mukhin <[email protected]>

---
 include/bootdev.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/bootdev.h +4 -4
index 12c90c4ec1ba..14f8a98633b3 100644
@@ -30,10 +30,10 @@ struct udevice;
  * generally very quick to access, e.g. less than 100ms
  * @BOOTDEVP_3_INTERNAL_SLOW: Internal devices which don't need scanning but
  * take a significant fraction of a second to access
- * @BOOTDEVP_4_SCAN_FAST: Extenal devices which need scanning or bus
+ * @BOOTDEVP_4_SCAN_FAST: External devices which need scanning or bus
  * enumeration to find, but this enumeration happens quickly, typically under
  * 100ms
- * @BOOTDEVP_5_SCAN_SLOW: Extenal devices which need scanning or bus
+ * @BOOTDEVP_5_SCAN_SLOW: External devices which need scanning or bus
  * enumeration to find. The enumeration takes significant fraction of a second
  * to complete
  * @BOOTDEVP_6_NET_BASE: Basic network devices which are quickly and easily
@@ -327,7 +327,7 @@ int bootdev_hunt_and_find_by_label(const char *label, struct udevice **devp,
  * Bootdev scanners are used as needed. For example a label "mmc1" results in
  * running the "mmc" bootdrv.
  *
- * @iter: Interation info, containing iter->cur_label
+ * @iter: Iteration info, containing iter->cur_label
  * @devp: New bootdev found, if any was found
  * @method_flagsp: If non-NULL, returns any flags implied by the label
  * (enum bootflow_meth_flags_t), 0 if none
@@ -342,7 +342,7 @@ int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp,
  * This moves @devp to the next bootdev with the current priority. If there is
  * none, then it moves to the next priority and scans for new bootdevs there.
  *
- * @iter: Interation info, containing iter->cur_prio
+ * @iter: Iteration info, containing iter->cur_prio
  * @devp: On entry this is the previous bootdev that was considered. On exit
  *	this is the new bootdev, if any was found
  * Returns 0 on success (*devp is updated), -ENODEV if there are no more
Signature · 1 line
2.54.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] bootdev: fix typos

Quoted 3 lines · On 6/11/26 03:48, [email protected] wrote:

From: Denis Mukhin <[email protected]>

Thanks for fixing the typos.

Quoted 39 lines
---
  include/bootdev.h | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
include/bootdev.h +4 -4
index 12c90c4ec1ba..14f8a98633b3 100644
@@ -30,10 +30,10 @@ struct udevice;
   * generally very quick to access, e.g. less than 100ms
   * @BOOTDEVP_3_INTERNAL_SLOW: Internal devices which don't need scanning but
   * take a significant fraction of a second to access
- * @BOOTDEVP_4_SCAN_FAST: Extenal devices which need scanning or bus
+ * @BOOTDEVP_4_SCAN_FAST: External devices which need scanning or bus
   * enumeration to find, but this enumeration happens quickly, typically under
   * 100ms
- * @BOOTDEVP_5_SCAN_SLOW: Extenal devices which need scanning or bus
+ * @BOOTDEVP_5_SCAN_SLOW: External devices which need scanning or bus
   * enumeration to find. The enumeration takes significant fraction of a second
   * to complete
   * @BOOTDEVP_6_NET_BASE: Basic network devices which are quickly and easily
@@ -327,7 +327,7 @@ int bootdev_hunt_and_find_by_label(const char *label, struct udevice **devp,
   * Bootdev scanners are used as needed. For example a label "mmc1" results in
   * running the "mmc" bootdrv.
   *
- * @iter: Interation info, containing iter->cur_label
+ * @iter: Iteration info, containing iter->cur_label
   * @devp: New bootdev found, if any was found
   * @method_flagsp: If non-NULL, returns any flags implied by the label
   * (enum bootflow_meth_flags_t), 0 if none
@@ -342,7 +342,7 @@ int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp,
   * This moves @devp to the next bootdev with the current priority. If there is
   * none, then it moves to the next priority and scans for new bootdevs there.
   *
- * @iter: Interation info, containing iter->cur_prio
+ * @iter: Iteration info, containing iter->cur_prio
   * @devp: On entry this is the previous bootdev that was considered. On exit
   *	this is the new bootdev, if any was found
   * Returns 0 on success (*devp is updated), -ENODEV if there are no more
#4 lore raw

PATCH 2/2 bootdev: scan boot devices at each priority level

In reply to [email protected]

From: Denis Mukhin <[email protected]>

Currently, default 'bootflow scan -lb' will stop booting the board if any of high-level priority bootdevs cannot be hunted even if there are bootdevs of lower priority.

For example, if board has both NVMe (priority 4) and USB MSD devices (priority 5), and if NVMe bootdev hunt fails (in an event of bad NVMe firmware update), USB (may be recovery bootdev) is never hunted automatically, leaving the board in U-Boot prompt (user intervention is needed, e.g. something like 'bootflow scan usb' to hunt USB).

Fix bootdev_next_prio() to scan bootdevs at the lower priority level by not exiting the scan loop early.

---
The following patch can be used for manual testing:
https://github.com/dmkhn/u-boot/commit/486bf2eba295126c98fd88bce6889a59a9c9f507

---
 boot/bootdev-uclass.c | 2 --
 1 file changed, 2 deletions(-)
boot/bootdev-uclass.c +0 -2
index 3f8dc2c3c4e6..73c3f050c225 100644
@@ -664,8 +664,6 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp)
 							BOOTFLOWIF_SHOW);
 				log_debug("- bootdev_hunt_prio() ret %d\n",
 					  ret);
-				if (ret)
-					return log_msg_ret("hun", ret);
 			}
 		} else {
 			ret = device_probe(dev);
Signature · 1 line
2.54.0
#5 lore raw

Re: [PATCH v1 2/2] bootdev: scan boot devices at each priority level

Hi Denis,

Quoted 4 lines · None

bootdev: scan boot devices at each priority level

Currently, default 'bootflow scan -lb' will stop booting the board if any of high-level priority bootdevs cannot be hunted even if there

I think you mean 'higher-priority bootdevs fail to be hunted'.

Quoted 18 lines

are bootdevs of lower priority.

For example, if board has both NVMe (priority 4) and USB MSD devices (priority 5), and if NVMe bootdev hunt fails (in an event of bad NVMe firmware update), USB (may be recovery bootdev) is never hunted automatically, leaving the board in U-Boot prompt (user intervention is needed, e.g. something like 'bootflow scan usb' to hunt USB).

Fix bootdev_next_prio() to scan bootdevs at the lower priority level by not exiting the scan loop early.

boot/bootdev-uclass.c | 2 --

 1 file changed, 2 deletions(-)

boot/bootdev-uclass.c int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp) · line 674

Quoted 8 lines
boot/bootdev-uclass.c +0 -2
@@ -669,8 +669,6 @@ int bootdev_next_prio(struct bootflow_iter *iter, struct udevice **devp)
                                                      BOOTFLOWIF_SHOW);
                              log_debug("- bootdev_hunt_prio() ret %d\n",
                                        ret);
-                             if (ret)
-                                     return log_msg_ret('hun', ret);
                      }
              } else {
                      ret = device_probe(dev);

The fix looks right - we can probably rely on the failing subsystem to print a suitable message.

Regards,
Simon

#6 lore raw
In reply to [email protected]

Hi Denis,

Quoted 1 line · None

This mini-series addresses few findings in bootdev code.

Thanks for looking at this.

Patch 2 changes the bootdev hunting behaviour, which is covered by the sandbox tests in test/boot/bootflow.c (bootflow_scan_drvs() and friends). Please can you add a test for the new fall-through: a high-priority bootdev whose hunter fails, followed by a lower-priority bootdev that still gets scanned? Without that we have no regression coverage.

Regards,
Simon