summaryrefslogtreecommitdiff
path: root/config/grub/xhci/patches/0005-xhci/0007-grub-core-bus-usb-usbhub-Add-xHCI-non-root-hub-suppo.patch
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-06-01 23:01:30 +0100
committerLeah Rowe <leah@libreboot.org>2024-06-02 19:58:50 +0100
commit429e91f90894d30bc2c6e165d6f2a743c61b76f3 (patch)
tree67b347fab1b896ab95c38303b5e124eab16ece62 /config/grub/xhci/patches/0005-xhci/0007-grub-core-bus-usb-usbhub-Add-xHCI-non-root-hub-suppo.patch
parent9daf7f05f14c74189daa820eae0127641c4d11d4 (diff)
make GRUB multi-tree and re-add xhci patches
Re-add xHCI only on haswell and broadwell machines, where they are needed. Otherwise, keep the same GRUB code. The xHCI patches were removed because they caused issues on Sandybridge-based Dell Latitude laptops. See: https://codeberg.org/libreboot/lbmk/issues/216 The issue was not reported elsewhere, including on the Haswell/Broadwell hardware where they are needed, but the build system could only build one version of GRUB. The older machines do not need xHCI patches, because they either do not have xHCI patches, or work (in GRUB) because they're in EHCI mode when running the payload. So, the problem is that we need the xHCI patches for GRUB on Haswell/Broadwell hardware, but the patches break Sandybridge hardware, and we only had the one build of GRUB. To mitigate this problem, the build system now supports building multiple revisions of GRUB, with different patches, and each given coreboot target can say which GRUB tree to use by setting this in target.cfg: grubtree="xhci" In the above example, the "xhci" tree would be used. Some generic GRUB config has been moved to config/data/grub/ and config/grub/ now looks like config/coreboot/ - also, the grub.cfg file (named "payload" in each tree) is copied to the GRUB source tree as ".config", then added to GRUB's memdisk in the same way, as grub.cfg. Several other design changes had to be made because of this: * grub.cfg in memdisk no longer automatically jumps to one in CBFS, but now shows a menuentry for it if available * Certain commands in script/trees are disabled for GRUB, such as *config make commands. * gnulib is now defined in config/submodule/grub/, instead of config/git/grub - and this mitigates an existing bug where downloading gnulib first would make grub no longer possible to download in lbmk. The coreboot option CONFIG_FINALIZE_USB_ROUTE_XHCI has been re-enabled on: Dell OptiPlex 9020 MT, Dell OptiPlex 9020 SFF, Lenovo ThinkPad T440p and Lenovo ThinkPad W541 - now USB should work again in GRUB. The GRUB payload has been re-enabled on HP EliteBook 820 G2. This change will enable per-board GRUB optimisation in the future. For example, we hardcode what partitions and LVMs GRUB scans because * is slow on ICH7-based machines, due to GRUB's design. On other machines, * is reasonably fast, for automatically enumerating the list of devices for boot. Use of * (and other wildcards) could enable our GRUB payload to automatically boot more distros, with minimal fuss. This can be done at a later date, in subsequent revisions. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'config/grub/xhci/patches/0005-xhci/0007-grub-core-bus-usb-usbhub-Add-xHCI-non-root-hub-suppo.patch')
-rw-r--r--config/grub/xhci/patches/0005-xhci/0007-grub-core-bus-usb-usbhub-Add-xHCI-non-root-hub-suppo.patch127
1 files changed, 127 insertions, 0 deletions
diff --git a/config/grub/xhci/patches/0005-xhci/0007-grub-core-bus-usb-usbhub-Add-xHCI-non-root-hub-suppo.patch b/config/grub/xhci/patches/0005-xhci/0007-grub-core-bus-usb-usbhub-Add-xHCI-non-root-hub-suppo.patch
new file mode 100644
index 00000000..a37bbd6b
--- /dev/null
+++ b/config/grub/xhci/patches/0005-xhci/0007-grub-core-bus-usb-usbhub-Add-xHCI-non-root-hub-suppo.patch
@@ -0,0 +1,127 @@
+From 2a2c64f6ea62337c1263a70f6ca9a9bade66b78b Mon Sep 17 00:00:00 2001
+From: Patrick Rudolph <patrick.rudolph@9elements.com>
+Date: Thu, 3 Dec 2020 13:44:55 +0100
+Subject: [PATCH 7/8] grub-core/bus/usb/usbhub: Add xHCI non root hub support
+
+Tested on Intel PCH C246, the USB3 hub can be configured by grub.
+
+Issues:
+* USB3 devices connected behind that hub are sometimes not detected.
+
+Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
+---
+ grub-core/bus/usb/usbhub.c | 38 +++++++++++++++++++++++++++++++++-----
+ include/grub/usbdesc.h | 1 +
+ include/grub/usbtrans.h | 4 ++++
+ 3 files changed, 38 insertions(+), 5 deletions(-)
+
+diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
+index b4b3a1a61..e96505aa9 100644
+--- a/grub-core/bus/usb/usbhub.c
++++ b/grub-core/bus/usb/usbhub.c
+@@ -148,19 +148,32 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
+ return dev;
+ }
+
+-
++static grub_usb_err_t
++grub_usb_set_hub_depth(grub_usb_device_t dev, grub_uint8_t depth)
++{
++ return grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_OUT
++ | GRUB_USB_REQTYPE_CLASS
++ | GRUB_USB_REQTYPE_TARGET_DEV),
++ GRUB_USB_HUB_REQ_SET_HUB_DEPTH, depth,
++ 0, 0, NULL);
++}
++
+ static grub_usb_err_t
+ grub_usb_add_hub (grub_usb_device_t dev)
+ {
+ struct grub_usb_usb_hubdesc hubdesc;
+ grub_usb_err_t err;
++ grub_uint16_t req;
+ int i;
+
++ req = (dev->speed == GRUB_USB_SPEED_SUPER) ? GRUB_USB_DESCRIPTOR_SS_HUB :
++ GRUB_USB_DESCRIPTOR_HUB;
++
+ err = grub_usb_control_msg (dev, (GRUB_USB_REQTYPE_IN
+ | GRUB_USB_REQTYPE_CLASS
+ | GRUB_USB_REQTYPE_TARGET_DEV),
+- GRUB_USB_REQ_GET_DESCRIPTOR,
+- (GRUB_USB_DESCRIPTOR_HUB << 8) | 0,
++ GRUB_USB_REQ_GET_DESCRIPTOR,
++ (req << 8) | 0,
+ 0, sizeof (hubdesc), (char *) &hubdesc);
+ if (err)
+ return err;
+@@ -183,6 +196,19 @@ grub_usb_add_hub (grub_usb_device_t dev)
+ return GRUB_USB_ERR_INTERNAL;
+ }
+
++ if (dev->speed == GRUB_USB_SPEED_SUPER)
++ {
++ grub_uint8_t depth;
++ grub_uint32_t route;
++ /* Depth maximum value is 5, but root hubs doesn't count */
++ for (depth = 0, route = dev->route; (route & 0xf) > 0; route >>= 4)
++ depth++;
++
++ err = grub_usb_set_hub_depth(dev, depth);
++ if (err)
++ return err;
++ }
++
+ /* Power on all Hub ports. */
+ for (i = 1; i <= hubdesc.portcnt; i++)
+ {
+@@ -637,7 +663,9 @@ poll_nonroot_hub (grub_usb_device_t dev)
+ int split_hubaddr = 0;
+
+ /* Determine the device speed. */
+- if (status & GRUB_USB_HUB_STATUS_PORT_LOWSPEED)
++ if (dev->speed == GRUB_USB_SPEED_SUPER)
++ speed = GRUB_USB_SPEED_SUPER;
++ else if (status & GRUB_USB_HUB_STATUS_PORT_LOWSPEED)
+ speed = GRUB_USB_SPEED_LOW;
+ else
+ {
+@@ -651,7 +679,7 @@ poll_nonroot_hub (grub_usb_device_t dev)
+ grub_millisleep (10);
+
+ /* Find correct values for SPLIT hubport and hubaddr */
+- if (speed == GRUB_USB_SPEED_HIGH)
++ if (speed == GRUB_USB_SPEED_HIGH || speed == GRUB_USB_SPEED_SUPER)
+ {
+ /* HIGH speed device needs not transaction translation */
+ split_hubport = 0;
+diff --git a/include/grub/usbdesc.h b/include/grub/usbdesc.h
+index bb2ab2e27..1697aa465 100644
+--- a/include/grub/usbdesc.h
++++ b/include/grub/usbdesc.h
+@@ -30,6 +30,7 @@ typedef enum {
+ GRUB_USB_DESCRIPTOR_ENDPOINT,
+ GRUB_USB_DESCRIPTOR_DEBUG = 10,
+ GRUB_USB_DESCRIPTOR_HUB = 0x29,
++ GRUB_USB_DESCRIPTOR_SS_HUB = 0x2a,
+ GRUB_USB_DESCRIPTOR_SS_ENDPOINT_COMPANION = 0x30
+ } grub_usb_descriptor_t;
+
+diff --git a/include/grub/usbtrans.h b/include/grub/usbtrans.h
+index 039ebed65..d6c3f71dc 100644
+--- a/include/grub/usbtrans.h
++++ b/include/grub/usbtrans.h
+@@ -110,6 +110,10 @@ enum
+ GRUB_USB_REQ_SET_INTERFACE = 0x0B,
+ GRUB_USB_REQ_SYNC_FRAME = 0x0C
+ };
++enum
++ {
++ GRUB_USB_HUB_REQ_SET_HUB_DEPTH = 0x0C,
++ };
+
+ #define GRUB_USB_FEATURE_ENDP_HALT 0x00
+ #define GRUB_USB_FEATURE_DEV_REMOTE_WU 0x01
+--
+2.39.2
+