summaryrefslogtreecommitdiff
path: root/config/grub/xhci/patches/0005-xhci/0004-grub-core-bus-usb-Add-function-pointer-for-attach-de.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/0004-grub-core-bus-usb-Add-function-pointer-for-attach-de.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/0004-grub-core-bus-usb-Add-function-pointer-for-attach-de.patch')
-rw-r--r--config/grub/xhci/patches/0005-xhci/0004-grub-core-bus-usb-Add-function-pointer-for-attach-de.patch121
1 files changed, 121 insertions, 0 deletions
diff --git a/config/grub/xhci/patches/0005-xhci/0004-grub-core-bus-usb-Add-function-pointer-for-attach-de.patch b/config/grub/xhci/patches/0005-xhci/0004-grub-core-bus-usb-Add-function-pointer-for-attach-de.patch
new file mode 100644
index 00000000..a090e0ea
--- /dev/null
+++ b/config/grub/xhci/patches/0005-xhci/0004-grub-core-bus-usb-Add-function-pointer-for-attach-de.patch
@@ -0,0 +1,121 @@
+From 89701aba00caa81bb566ab10da0c89264393be30 Mon Sep 17 00:00:00 2001
+From: Patrick Rudolph <patrick.rudolph@9elements.com>
+Date: Sun, 15 Nov 2020 19:51:42 +0100
+Subject: [PATCH 4/8] grub-core/bus/usb: Add function pointer for attach/detach
+ events
+
+The xHCI code needs to be called for attaching or detaching a device.
+Introduce two functions pointers and call it from the USB hub code.
+
+Will be used in future commits, currently this doesn't change any functionality.
+
+Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
+---
+ grub-core/bus/usb/ehci.c | 2 ++
+ grub-core/bus/usb/ohci.c | 2 ++
+ grub-core/bus/usb/uhci.c | 2 ++
+ grub-core/bus/usb/usbhub.c | 19 +++++++++++++++++++
+ include/grub/usb.h | 4 ++++
+ 5 files changed, 29 insertions(+)
+
+diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c
+index 9abebc6bd..953b851c0 100644
+--- a/grub-core/bus/usb/ehci.c
++++ b/grub-core/bus/usb/ehci.c
+@@ -1812,6 +1812,8 @@ static struct grub_usb_controller_dev usb_controller = {
+ .hubports = grub_ehci_hubports,
+ .portstatus = grub_ehci_portstatus,
+ .detect_dev = grub_ehci_detect_dev,
++ .attach_dev = NULL,
++ .detach_dev = NULL,
+ /* estimated max. count of TDs for one bulk transfer */
+ .max_bulk_tds = GRUB_EHCI_N_TD * 3 / 4
+ };
+diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c
+index 5363a61f6..7a3f3e154 100644
+--- a/grub-core/bus/usb/ohci.c
++++ b/grub-core/bus/usb/ohci.c
+@@ -1440,6 +1440,8 @@ static struct grub_usb_controller_dev usb_controller =
+ .hubports = grub_ohci_hubports,
+ .portstatus = grub_ohci_portstatus,
+ .detect_dev = grub_ohci_detect_dev,
++ .attach_dev = NULL,
++ .detach_dev = NULL,
+ /* estimated max. count of TDs for one bulk transfer */
+ .max_bulk_tds = GRUB_OHCI_TDS * 3 / 4
+ };
+diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c
+index 0fdea4c1e..03c4605b2 100644
+--- a/grub-core/bus/usb/uhci.c
++++ b/grub-core/bus/usb/uhci.c
+@@ -845,6 +845,8 @@ static struct grub_usb_controller_dev usb_controller =
+ .hubports = grub_uhci_hubports,
+ .portstatus = grub_uhci_portstatus,
+ .detect_dev = grub_uhci_detect_dev,
++ .attach_dev = NULL,
++ .detach_dev = NULL,
+ /* estimated max. count of TDs for one bulk transfer */
+ .max_bulk_tds = N_TD * 3 / 4
+ };
+diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
+index 2ae29cba1..8e963e84b 100644
+--- a/grub-core/bus/usb/usbhub.c
++++ b/grub-core/bus/usb/usbhub.c
+@@ -66,6 +66,15 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
+ dev->split_hubport = split_hubport;
+ dev->split_hubaddr = split_hubaddr;
+
++ if (controller->dev->attach_dev) {
++ err = controller->dev->attach_dev (controller, dev);
++ if (err)
++ {
++ grub_free (dev);
++ return NULL;
++ }
++ }
++
+ err = grub_usb_device_initialize (dev);
+ if (err)
+ {
+@@ -405,6 +414,8 @@ static void
+ detach_device (grub_usb_device_t dev)
+ {
+ unsigned i;
++ grub_usb_err_t err;
++
+ int k;
+ if (!dev)
+ return;
+@@ -425,6 +436,14 @@ detach_device (grub_usb_device_t dev)
+ if (inter && inter->detach_hook)
+ inter->detach_hook (dev, i, k);
+ }
++ if (dev->controller.dev->detach_dev) {
++ err = dev->controller.dev->detach_dev (&dev->controller, dev);
++ if (err)
++ {
++ // XXX
++ }
++ }
++
+ grub_usb_devs[dev->addr] = 0;
+ }
+
+diff --git a/include/grub/usb.h b/include/grub/usb.h
+index ea6ee8c2c..4dd179db2 100644
+--- a/include/grub/usb.h
++++ b/include/grub/usb.h
+@@ -126,6 +126,10 @@ struct grub_usb_controller_dev
+
+ grub_usb_speed_t (*detect_dev) (grub_usb_controller_t dev, int port, int *changed);
+
++ grub_usb_err_t (*attach_dev) (grub_usb_controller_t ctrl, grub_usb_device_t dev);
++
++ grub_usb_err_t (*detach_dev) (grub_usb_controller_t ctrl, grub_usb_device_t dev);
++
+ /* Per controller flag - port reset pending, don't do another reset */
+ grub_uint64_t pending_reset;
+
+--
+2.39.2
+