[PATCH 04/13] bootstd: Probe the block device before use

Simon Glass sjg at chromium.org
Sat Jan 28 23:00:19 CET 2023


In some cases the block device is obtained but is not probed, since it
is a sibling of the bootdev. Make sure it is probed, so it can be used
without any trouble.

This fixes a bug with virtio, where the device is accessed before it has
been set up by the virtio uclass.

Signed-off-by: Simon Glass <sjg at chromium.org>
Fixes: 201417d700a ("bootstd: Add the bootdev uclass")
Reported-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
---

 boot/bootdev-uclass.c | 3 +++
 boot/bootflow.c       | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 99ee08e3353..8103a11d1bb 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -309,6 +309,9 @@ int bootdev_get_sibling_blk(struct udevice *dev, struct udevice **blkp)
 		if (ret)
 			return log_msg_ret("find", ret);
 	}
+	ret = device_probe(blk);
+	if (ret)
+		return log_msg_ret("act", ret);
 	*blkp = blk;
 
 	return 0;
diff --git a/boot/bootflow.c b/boot/bootflow.c
index dc3f1f0c731..b8fa37ee2a0 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -270,6 +270,10 @@ static int iter_incr(struct bootflow_iter *iter)
 		if (ret) {
 			bootflow_iter_set_dev(iter, NULL, 0);
 		} else {
+			/*
+			 * Probe the bootdev. This does not probe any attached
+			 * block device, since they are siblings
+			 */
 			ret = device_probe(dev);
 			log_debug("probe %s %d\n", dev->name, ret);
 			if (!log_msg_ret("probe", ret))
-- 
2.39.1.456.gfc5497dd1b-goog



More information about the U-Boot mailing list