[PATCH 2/3] bootstd: usb: Avoid initing USB twice
Simon Glass
sjg at chromium.org
Sat May 6 04:03:04 CEST 2023
This causes crashes on some boards, e.g. rockpro64. In any case, we
should not do it.
Check the usb_started flag to avoid this.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
drivers/usb/host/usb_bootdev.c | 3 +++
test/boot/bootdev.c | 5 +++++
2 files changed, 8 insertions(+)
diff --git a/drivers/usb/host/usb_bootdev.c b/drivers/usb/host/usb_bootdev.c
index 32919f992865..06e8f61aa1c5 100644
--- a/drivers/usb/host/usb_bootdev.c
+++ b/drivers/usb/host/usb_bootdev.c
@@ -22,6 +22,9 @@ static int usb_bootdev_bind(struct udevice *dev)
static int usb_bootdev_hunt(struct bootdev_hunter *info, bool show)
{
+ if (usb_started)
+ return 0;
+
return usb_init();
}
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c
index 606bf4fcc1c1..6b29213416db 100644
--- a/test/boot/bootdev.c
+++ b/test/boot/bootdev.c
@@ -306,6 +306,7 @@ static int bootdev_test_hunter(struct unit_test_state *uts)
{
struct bootstd_priv *std;
+ usb_started = false;
test_set_skip_delays(true);
/* get access to the used hunters */
@@ -346,6 +347,7 @@ static int bootdev_test_cmd_hunt(struct unit_test_state *uts)
struct bootstd_priv *std;
test_set_skip_delays(true);
+ usb_started = false;
/* get access to the used hunters */
ut_assertok(bootstd_get_priv(&std));
@@ -474,6 +476,7 @@ BOOTSTD_TEST(bootdev_test_bootable, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
/* Check hunting for bootdev of a particular priority */
static int bootdev_test_hunt_prio(struct unit_test_state *uts)
{
+ usb_started = false;
test_set_skip_delays(true);
console_record_reset_enable();
@@ -502,6 +505,8 @@ static int bootdev_test_hunt_label(struct unit_test_state *uts)
struct bootstd_priv *std;
int mflags;
+ usb_started = false;
+
/* get access to the used hunters */
ut_assertok(bootstd_get_priv(&std));
--
2.40.1.521.gf1e218fcd8-goog
More information about the U-Boot
mailing list