Files
lbmk/config/grub/xhci/patches/0023-xhci-configure-TT-for-non-root-hubs.patch
T
Leah Rowe 81dc1a7f89 GRUB: Bump to rev a68a7dece, 23 June 2025
NOTE: gfxterm_menu module removed, because of this
change by upstream:

commit ca2a91f43bf6e1df23a07c295534f871ddf2d401
Author: Glenn Washburn <development@efficientek.com>
Date:   Mon May 5 16:11:36 2025 -0500

    tests: Disable gfxterm_menu and cmdline_cat tests

This brings in the following changes from upstream:

* a68a7dece loader/i386/pc/linux: Fix resource leak
* de80acf36 loader/efi/linux: Unload previous Linux kernel/initrd before updating kernel size
* 249db11d8 loader/efi/linux: Correctly terminate load_options member
* f3b339af1 loader/efi/linux: Use sizeof() instead of constant
* c2b2e0dcf loader/efi/linux: Use proper type for len variable
* de4e8e2aa loader/efi/linux: Do not pass excessive size for source string
* 8c8f96664 loader/efi/linux: Remove useless assignment
* 8ebf155af include/grub/charset.h: Update documentation
* 2f2ed28d5 Revert "lzma: Make sure we don't dereference past array"
* 2539ede82 tests/util/grub-shell: Correct netboot and file_filter test failure
* 8c2d4e64f normal/charset: Fix underflow and overflow in loop init
* ba8eadde6 dl: Provide a fake grub_dl_set_persistent() and grub_dl_is_persistent() for the emu target
* 409e72ced util/grub-protect: Correct uninit "err" variable
* 5eca564b1 gnulib: Bring back the fix for resolving unused variable issue
* ac1512b87 gnulib: Add patch to allow GRUB w/GCC-15 compile
* db506b3b8 gnulib/regexec: Fix resource leak
* bba7dd736 gnulib/regcomp: Fix resource leak
* 91cb7ff6b tests/tpm2_key_protector_test: Add tests for SHA-384 PCR bank
* 451e227e5 tpm2_key_protector: Dump the PCR bank for key unsealing
* 11caacdb2 util/grub-protect: Fix the hash algorithm of PCR digest
* ce23919ca build: Add new header files to dist to allow building from tar
* e3b15bafd build: Remove extra_deps.lst from EXTRA_DIST
* 40e261b89 lib/LzmaEnc: Validate "len" before subtracting
* 86e8f2c4b osdep/unix/hostdisk: Fix signed integer overflow
* 438f05581 disk/luks2: Add attempting to decrypt message to align with luks and geli modules
* 20e6d0c4a osdep/linux/getroot: Detect DDF container similar to IMSM
* b71bc0f8b fs/fshelp: Avoid possible NULL pointer deference
* 272ff81cb fs/ntfs: Correct possible infinite loops/hangs
* 8c95307a0 fs/ntfs: Correct possible access violations
* 06914b614 fs/ntfs: Correct attribute vs attribute list validation
* 0e1762c8a fs/ntfs: Correct regression with run list calculation
* be303f8c1 lib/envblk: Ignore empty new lines while parsing env files
* 34bd00ee2 fs/zfs: Fix another memory leak in ZFS code
* ca2a91f43 tests: Disable gfxterm_menu and cmdline_cat tests

Signed-off-by: Leah Rowe <leah@libreboot.org>
2025-07-06 16:26:49 +01:00

99 lines
3.4 KiB
Diff

From 0a669ef9815267de4fb14f3c329431ac531755c9 Mon Sep 17 00:00:00 2001
From: Sven Anderson <sven@anderson.de>
Date: Mon, 13 Jan 2025 20:26:32 +0100
Subject: [PATCH 23/26] xhci: configure TT for non-root-hubs
---
grub-core/bus/usb/usbhub.c | 6 +++++
grub-core/bus/usb/xhci.c | 45 +++++++++++++++++++++++++++++++++-----
include/grub/usb.h | 2 ++
3 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
index e96505aa9..629b3ed53 100644
--- a/grub-core/bus/usb/usbhub.c
+++ b/grub-core/bus/usb/usbhub.c
@@ -818,3 +818,9 @@ grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data)
return 0;
}
+
+grub_usb_device_t
+grub_usb_get_dev (int addr)
+{
+ return grub_usb_devs[addr];
+}
diff --git a/grub-core/bus/usb/xhci.c b/grub-core/bus/usb/xhci.c
index dc89b9619..88c9ac57f 100644
--- a/grub-core/bus/usb/xhci.c
+++ b/grub-core/bus/usb/xhci.c
@@ -623,13 +623,46 @@ grub_xhci_alloc_inctx(struct grub_xhci *x, int maxepid,
break;
}
- /* Route is greater zero on devices that are connected to a non root hub */
- if (dev->route)
- {
- /* FIXME: Implement this code for non SuperSpeed hub devices */
+ /* Set routing string */
+ slot->ctx[0] |= dev->route;
+
+ /* Set root hub port number */
+ slot->ctx[1] |= (dev->root_port + 1) << 16;
+
+ if (dev->split_hubaddr && (dev->speed == GRUB_USB_SPEED_LOW ||
+ dev->speed == GRUB_USB_SPEED_FULL)) {
+
+ grub_usb_device_t hubdev = grub_usb_get_dev(dev->split_hubaddr);
+
+ if (!hubdev || hubdev->descdev.class != GRUB_USB_CLASS_HUB) {
+ grub_dprintf("xhci", "Invalid hub device at addr %d!\n", dev->split_hubaddr);
+ return NULL;
+ }
+
+ struct grub_xhci_priv *hub_priv = hubdev->xhci_priv;
+ if (!hub_priv) {
+ grub_dprintf("xhci", "Hub has no xhci_priv!\n");
+ return NULL;
+ }
+
+ if (hubdev->speed == GRUB_USB_SPEED_HIGH) {
+ /* Direct connection to high-speed hub - set up TT */
+ grub_dprintf("xhci", "Direct high-speed hub connection - configuring TT with "
+ "hub slot %d port %d\n", hub_priv->slotid, dev->split_hubport);
+ slot->ctx[2] |= hub_priv->slotid;
+ slot->ctx[2] |= dev->split_hubport << 8;
}
- slot->ctx[0] |= dev->route;
- slot->ctx[1] |= (dev->root_port+1) << 16;
+ else {
+ /* Hub is not high-speed, inherit TT settings from parent */
+ volatile struct grub_xhci_slotctx *hubslot;
+ grub_dprintf("xhci", "Non high-speed hub - inheriting TT settings from parent\n");
+ hubslot = grub_dma_phys2virt(x->devs[hub_priv->slotid].ptr_low, x->devs_dma);
+ slot->ctx[2] = hubslot->ctx[2];
+ }
+ }
+
+ grub_dprintf("xhci", "Slot context: ctx[0]=0x%08x ctx[1]=0x%08x ctx[2]=0x%08x\n",
+ slot->ctx[0], slot->ctx[1], slot->ctx[2]);
grub_arch_sync_dma_caches(in, size);
diff --git a/include/grub/usb.h b/include/grub/usb.h
index eb71fa1c7..df97a60cc 100644
--- a/include/grub/usb.h
+++ b/include/grub/usb.h
@@ -62,6 +62,8 @@ typedef int (*grub_usb_controller_iterate_hook_t) (grub_usb_controller_t dev,
/* Call HOOK with each device, until HOOK returns non-zero. */
int grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data);
+grub_usb_device_t grub_usb_get_dev (int addr);
+
grub_usb_err_t grub_usb_device_initialize (grub_usb_device_t dev);
grub_usb_err_t grub_usb_get_descriptor (grub_usb_device_t dev,
--
2.39.5