Skip to contentSkip to conversation

bootstd: Keep track of use of usb stop

PATCH New Simon Glass 1 participant 2 messages Sep 20, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v6 13/20 bootstd: Keep track of use of usb stop

When 'usb stop' is run, doing 'bootflow scan' does not run the USB hunter again so does not see any devices. Fix this by telling bootstd about the state of USB.

---

Changes in v6:
- Ensure that bootstd functions are not called in SPL

 boot/bootdev-uclass.c         | 27 +++++++++++++++++++++++++++
 drivers/usb/host/usb-uclass.c |  8 ++++++++
 include/bootdev.h             |  9 +++++++++
 3 files changed, 44 insertions(+)
boot/bootdev-uclass.c +27 -0
index 69506e3865fc..974ddee5d2fa 100644
@@ -830,6 +830,33 @@ int bootdev_hunt(const char *spec, bool show)
 	return result;
 }
 
+int bootdev_unhunt(enum uclass_id id)
+{
+	struct bootdev_hunter *start;
+	int n_ent, i;
+
+	start = ll_entry_start(struct bootdev_hunter, bootdev_hunter);
+	n_ent = ll_entry_count(struct bootdev_hunter, bootdev_hunter);
+	for (i = 0; i < n_ent; i++) {
+		struct bootdev_hunter *info = start + i;
+
+		if (info->uclass == id) {
+			struct bootstd_priv *std;
+			int ret;
+
+			ret = bootstd_get_priv(&std);
+			if (ret)
+				return log_msg_ret("std", ret);
+			if (!(std->hunters_used & BIT(i)))
+				return -EALREADY;
+			std->hunters_used &= ~BIT(i);
+			return 0;
+		}
+	}
+
+	return -ENOENT;
+}
+
 int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show)
 {
 	struct bootdev_hunter *start;
drivers/usb/host/usb-uclass.c +8 -0
index e5fe949f254c..a1cd0ad2d669 100644
@@ -9,6 +9,7 @@
 #define LOG_CATEGORY UCLASS_USB
 
 #include <common.h>
+#include <bootdev.h>
 #include <dm.h>
 #include <errno.h>
 #include <log.h>
@@ -208,6 +209,13 @@ int usb_stop(void)
 #ifdef CONFIG_USB_STORAGE
 	usb_stor_reset();
 #endif
+	if (CONFIG_IS_ENABLED(BOOTSTD)) {
+		int ret;
+
+		ret = bootdev_unhunt(UCLASS_USB);
+		if (IS_ENABLED(CONFIG_BOOTSTD_FULL) && ret && ret != -EALREADY)
+			printf("failed to unhunt USB (err=%dE)\n", ret);
+	}
 	uc_priv->companion_device_count = 0;
 	usb_started = 0;
 
include/bootdev.h +9 -0
index 848233187f87..b079a91b5b7f 100644
@@ -320,6 +320,15 @@ int bootdev_hunt(const char *spec, bool show);
  */
 int bootdev_hunt_prio(enum bootdev_prio_t prio, bool show);
 
+/**
+ * bootdev_unhunt() - Mark a device as needing to be hunted again
+ *
+ * @id: uclass ID to update
+ * Return: 0 if done, -EALREADY if already in this state, -ENOENT if no hunter
+ * found for that uclass
+ */
+int bootdev_unhunt(enum uclass_id id);
+
 /**
  * bootdev_hunt_and_find_by_label() - Hunt for bootdevs by label
  *
Signature · 1 line
2.42.0.459.ge4e396fd5e-goog
#1 lore raw

PATCH v6 15/20 efi: Use the installed SMBIOS tables

U-Boot should set up the SMBIOS tables during startup, as it does on x86. Ensure that it does this correctly on non-x86 machines too, by creating an event spy for last-stage init.

Tidy up the installation-condition code while we are here.

---

Changes in v6:
- Add a condition for mvebu_db-88f3720 last-stage init

Changes in v4:
- Rewrite this to use events instead

Changes in v3:
- Use log_debug() to show the message
- Squash in the next patch

Changes in v2:
- Add new patch

 board/Marvell/mvebu_armada-37xx/board.c |  3 +-
 lib/Kconfig                             |  1 +
 lib/efi_loader/Makefile                 |  2 +-
 lib/efi_loader/efi_setup.c              | 10 ++--
 lib/efi_loader/efi_smbios.c             | 72 ++++++++++++++++---------
 test/py/tests/test_event_dump.py        |  1 +
 6 files changed, 56 insertions(+), 33 deletions(-)
board/Marvell/mvebu_armada-37xx/board.c +2 -1
index 3fe5319437ea..04124d8014dd 100644
@@ -307,7 +307,8 @@ static int last_stage_init(void)
 	struct udevice *bus;
 	ofnode node;
 
-	if (!of_machine_is_compatible("globalscale,espressobin"))
+	if (!CONFIG_IS_ENABLED(DM_MDIO) ||
+	    !of_machine_is_compatible("globalscale,espressobin"))
 		return 0;
 
 	node = ofnode_by_compatible(ofnode_null(), "marvell,orion-mdio");
lib/Kconfig +1 -0
index 6b5389f3a87d..79cf9ef0fa31 100644
@@ -1049,6 +1049,7 @@ config SMBIOS
 	bool "SMBIOS support"
 	depends on X86 || EFI_LOADER
 	default y
+	select LAST_STAGE_INIT
 	help
 	  Indicates that this platform can support System Management BIOS
 	  (SMBIOS) tables. These provide various pieces of information about
lib/efi_loader/Makefile +1 -1
index 0eb748ff1a59..8d31fc61c601 100644
@@ -79,7 +79,7 @@ obj-$(CONFIG_VIDEO) += efi_gop.o
 obj-$(CONFIG_BLK) += efi_disk.o
 obj-$(CONFIG_NETDEVICES) += efi_net.o
 obj-$(CONFIG_ACPI) += efi_acpi.o
-obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
+obj-$(CONFIG_SMBIOS) += efi_smbios.o
 obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
 obj-$(CONFIG_EFI_TCG2_PROTOCOL) += efi_tcg2.o
 obj-$(CONFIG_EFI_RISCV_BOOT_PROTOCOL) += efi_riscv.o
lib/efi_loader/efi_setup.c +5 -5
index ad719afd6328..e6de685e8795 100644
@@ -326,11 +326,11 @@ efi_status_t efi_init_obj_list(void)
 		if (ret != EFI_SUCCESS)
 			goto out;
 	}
-#ifdef CONFIG_GENERATE_SMBIOS_TABLE
-	ret = efi_smbios_register();
-	if (ret != EFI_SUCCESS)
-		goto out;
-#endif
+	if (IS_ENABLED(CONFIG_SMBIOS)) {
+		ret = efi_smbios_register();
+		if (ret != EFI_SUCCESS)
+			goto out;
+	}
 	ret = efi_watchdog_register();
 	if (ret != EFI_SUCCESS)
 		goto out;
lib/efi_loader/efi_smbios.c +46 -26

90 lines not on this page · raw message

test/py/tests/test_event_dump.py +1 -0
index a6df9e10e54e..e282c67335cd 100644
@@ -18,6 +18,7 @@ def test_event_dump(u_boot_console):
 --------------------  ------------------------------  ------------------------------
 EVT_FT_FIXUP          bootmeth_vbe_ft_fixup           .*boot/vbe_request.c:.*
 EVT_FT_FIXUP          bootmeth_vbe_simple_ft_fixup    .*boot/vbe_simple_os.c:.*
+EVT_LAST_STAGE_INIT   install_smbios_table            .*lib/efi_loader/efi_smbios.c:.*
 EVT_MISC_INIT_F       sandbox_early_getopt_check      .*arch/sandbox/cpu/start.c:.*
 EVT_TEST              h_adder_simple                  .*test/common/event.c:'''
     assert re.match(expect, out, re.MULTILINE) is not None
Signature · 1 line
2.42.0.459.ge4e396fd5e-goog