[PATCH v2 3/3] test: bootdev: scan with a broken high-priority device

Simon Glass sjg at chromium.org
Thu Jun 18 15:24:04 CEST 2026


Hi Denis,

On 2026-06-16T06:36:03, None <dmukhin at ford.com> wrote:
> test: bootdev: scan with a broken high-priority device
>
> Add bootdev_hunt_fallthrough() test to verify that 'bootflow scan -l'
> falls back to a lower-priority bootdev when a higher-priority hunter
> fails.
>
> Introduce a simple 'sandbox-bootdev' device for the test. The new
> bootdev can be configured to produce an error at the hunting stage.
>
> Signed-off-by: Denis Mukhin <dmukhin at ford.com>
>
> drivers/block/Makefile          |  2 +-
>  drivers/block/host-uclass.c     | 18 ++++++++++++
>  drivers/block/sandbox-bootdev.c | 64 +++++++++++++++++++++++++++++++++++++++++
>  include/sandbox_host.h          | 17 +++++++++++
>  test/boot/bootflow.c            | 51 ++++++++++++++++++++++++++++++++
>  5 files changed, 151 insertions(+), 1 deletion(-)

> diff --git a/drivers/block/host-uclass.c b/drivers/block/host-uclass.c
> @@ -27,6 +27,7 @@ DECLARE_GLOBAL_DATA_PTR;
>  struct host_priv {
>       struct udevice *cur_dev;
> +     unsigned int flags;
>  };

This flags field is never read or written - the flags that matter are
in host_sb_plat::flags, where host_set_flags_by_label() writes them
and sandbox_bootdev_hunt() reads them. Please remove it.

> diff --git a/drivers/block/sandbox-bootdev.c b/drivers/block/sandbox-bootdev.c
> @@ -0,0 +1,64 @@
> +#define LOG_CATEGORY UCLASS_HOST
> +
> +#include <bootdev.h>
> +#include <dm.h>
> +#include <log.h>
> +#include <sandbox_host.h>
> +
> +static int sandbox_bootdev_bind(struct udevice *dev)

LOG_CATEGORY is defined but sandbox_bootdev_hunt() uses pr_debug() and
pr_err(). Please use the log_ family throughout so the category is
honoured.

> diff --git a/drivers/block/sandbox-bootdev.c b/drivers/block/sandbox-bootdev.c
> @@ -0,0 +1,64 @@
> +     uclass_id_foreach_dev(UCLASS_HOST, dev, uc) {
> +             struct host_sb_plat *plat = dev_get_plat(dev);
> +
> +             pr_debug("hunting %s\n", plat->label);
> +
> +             if (plat->flags & BLK_HOST_BROKEN) {
> +                     ret = -ETIME;
> +                     pr_err("cannot hunt sandbox device '%s': %d\n",
> +                            plat->label, ret);
> +                     return ret;
> +             }
> +
> +             return 0;
> +     }

The unconditional return 0 exits on the first HOST device found, so
any further devices are silently ignored. It works for the test since
only one device is created, but is misleading. Please use continue
after a non-broken device, or add a comment explaining the early
return.

Regards,
Simon


More information about the U-Boot mailing list