[PATCH] virtio: ignore ENODEV for boot device hunting

Simon Glass sjg at chromium.org
Fri May 1 00:00:06 CEST 2026


Hi Ludwig,

On Thu, 30 Apr 2026 at 03:01, Ludwig Nussel <ludwig.nussel at siemens.com> wrote:
>
> On 4/29/26 16:20, Simon Glass wrote:
> > [...]
> >> diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c
> >> @@ -382,7 +382,7 @@ static int virtio_bootdev_hunt(struct bootdev_hunter *info, bool show)
> >>        ret = uclass_probe_all(UCLASS_VIRTIO);
> >> -     if (ret && ret != -ENOENT)
> >> +     if (ret && ret != -ENOENT && ret != -ENODEV)
> >>                return log_msg_ret('vir', ret);
> >
> > I don't think this is the right layer. uclass_probe_all() walks every
> > device in the uclass and returns whichever error came back last, so a
> > single bogus mmio slot poisons the result for every other working
> > virtio device. -ENXIO is also returned from virtio_mmio_probe() for an
> > unsupported version and would still bail out here, which is
> > inconsistent with what you are trying to achieve.
> >
> > As I understand it, the placeholder/empty mmio slots should not be
> > reaching probe at all, i.e. the bind step should reject them - or
> > virtio_mmio_probe() should keep returning 0 for the 'no device
> > present' case (wrong magic, ID 0) and let DM treat that as nothing to
> > probe. The unsupported-version case is the only real error.
> >
> > Could you take another look at 70101c3217ae and see whether the fix
> > belongs there (or in the bind path) instead?
>
> I don't know the first thing about that :) Naively changing the function
> to be called in bind() instead makes u-boot crash. It would be possible
> to change the return value in the probe function to ENOENT instead.
> The driver claims to be ported from Linux. In Linux the return value in
> question is ENODEV though.

U-Boot is a little different from Linux in that it has a 'bind' stage.
We use -ENODEV in driver model to indicate that there is no device.
Standard boot uses it to indicate there are no more devices (see
BF_NO_MORE_DEVICES).

Checking for -ENODEV in a device doesn't really make any sense since
there is clearly a device (you just called the probe() method!)

I think -ENOENT would work.

>
> Maybe it makes sense to make virtio_bootdev_hunt() ignore all errors
> instead?
>

I'm not sure about that, but I see it as a last resort, since we try
to report errors where possible.

Regards,
Simon


More information about the U-Boot mailing list