usb: host: ohci/ehci: halt the controller before booting an OS
Subsystems (3)
PATCH 1/1 usb: host: ohci/ehci: halt the controller before booting an OS
Currently, OHCI is not stopped before OS starts booting. This means HCCA is still being written into during OS boot. This may cause all sorts of random and hard to catch errors, if same area is being used for some other needs.
Mark OHCI and EHCI drivers with DM_FLAG_OS_PREPARE so remove hook stops both controllers during OS boot.
--- drivers/usb/host/ehci-generic.c | 2 +- drivers/usb/host/ohci-generic.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/host/ehci-generic.c +1 -1
@@ -167,5 +167,5 @@ U_BOOT_DRIVER(ehci_generic) = { .remove = ehci_usb_remove, .ops = &ehci_usb_ops, .priv_auto = sizeof(struct generic_ehci), - .flags = DM_FLAG_ALLOC_PRIV_DMA, + .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_OS_PREPARE, };
drivers/usb/host/ohci-generic.c +1 -1
@@ -110,5 +110,5 @@ U_BOOT_DRIVER(ohci_generic) = { .remove = ohci_usb_remove, .ops = &ohci_usb_ops, .priv_auto = sizeof(struct generic_ohci), - .flags = DM_FLAG_ALLOC_PRIV_DMA, + .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_OS_PREPARE, };
Signature · 1 line
2.56.1
Quoted 5 lines · Jernej Skrabec
Currently, OHCI is not stopped before OS starts booting. This means HCCA is still being written into during OS boot. This may cause all sorts of random and hard to catch errors, if same area is being used for some other needs.
Quoted 7 lines
Mark OHCI and EHCI drivers with
DM_FLAG_OS_PREPAREso remove hook stops both controllers during OS boot.Signed-off-by Jernej Skrabec <[email protected]>--- drivers/usb/host/ehci-generic.c | 2 +- drivers/usb/host/ohci-generic.c | 2 +-
I think per:
commit d610f703f937ebf7681e5cc36905586666e7ceb8
Author: Jacob Procee <[email protected]> Date: Thu Oct 22 18:58:08 2026 +0200
usb: xhci-dwc3: Add DM_FLAG_ACTIVE_DMA flag
xhci-dwc3 is not removed before U-Boot hands over to the OS, so the controller keeps running after ExitBootServices or bootm. If a device was enumerated by "usb start" (for example by the default preboot command for USB keyboards), the controller keeps polling it.
On Apple Silicon machines (tested on a MacBook Pro M1 Pro, J314s), a USB device that is connected while U-Boot runs is then not detected by Linux until it is unplugged and plugged back in. Running "usb stop" before booting avoids this.
Add DM_FLAG_ACTIVE_DMA so the controller is removed, and its DMA stopped, before the handover.
We're preferring to use DM_FLAG_ACTIVE_DMA here instead.
Signature · 1 line
Tom
Dne četrtek, 12. november 2026 ob 19:35:46 Srednjeevropski standardni čas je Tom Rini napisal(a):
Quoted 32 lines · Jernej Skrabec
Quoted 6 lines
Currently, OHCI is not stopped before OS starts booting. This means HCCA is still being written into during OS boot. This may cause all sorts of random and hard to catch errors, if same area is being used for some other needs.
Quoted 7 lines
Mark OHCI and EHCI drivers with
DM_FLAG_OS_PREPAREso remove hook stops both controllers during OS boot.Signed-off-by Jernej Skrabec <[email protected]>--- drivers/usb/host/ehci-generic.c | 2 +- drivers/usb/host/ohci-generic.c | 2 +-I think per:
commitd610f703f937ebf7681e5cc36905586666e7ceb8Author: Jacob Procee <[email protected]> Date: Thu Oct 22 18:58:08 2026 +0200usb: xhci-dwc3: Add
DM_FLAG_ACTIVE_DMAflagxhci-dwc3 is not removed before U-Boot hands over to the OS, so the controller keeps running after ExitBootServices or bootm. If a device was enumerated by "usb start" (for example by the default preboot command for USB keyboards), the controller keeps polling it.
On Apple Silicon machines (tested on a MacBook Pro M1 Pro, J314s), a USB device that is connected while U-Boot runs is then not detected by Linux until it is unplugged and plugged back in. Running "usb stop" before booting avoids this.
Quoted 7 lines
Add
DM_FLAG_ACTIVE_DMAso the controller is removed, and its DMA stopped, before the handover.Signed-off-by Jacob Procee <[email protected]>Reviewed-by Marek Vasut <[email protected]>We're preferring to use
DM_FLAG_ACTIVE_DMAhere instead.
Ok, no problem. Should I respin it now or do you prefer to wait to potential other comments on it?
Best regards,
Jernej
Quoted 36 lines · Jernej Škrabec
Dne četrtek, 12. november 2026 ob 19:35:46 Srednjeevropski standardni čas je Tom Rini napisal(a):
Quoted 35 lines · Jernej Skrabec
Quoted 6 lines
Currently, OHCI is not stopped before OS starts booting. This means HCCA is still being written into during OS boot. This may cause all sorts of random and hard to catch errors, if same area is being used for some other needs.
Quoted 7 lines
Mark OHCI and EHCI drivers with
DM_FLAG_OS_PREPAREso remove hook stops both controllers during OS boot.Signed-off-by Jernej Skrabec <[email protected]>--- drivers/usb/host/ehci-generic.c | 2 +- drivers/usb/host/ohci-generic.c | 2 +-I think per:
commitd610f703f937ebf7681e5cc36905586666e7ceb8Author: Jacob Procee <[email protected]> Date: Thu Oct 22 18:58:08 2026 +0200usb: xhci-dwc3: Add
DM_FLAG_ACTIVE_DMAflagxhci-dwc3 is not removed before U-Boot hands over to the OS, so the controller keeps running after ExitBootServices or bootm. If a device was enumerated by "usb start" (for example by the default preboot command for USB keyboards), the controller keeps polling it.
On Apple Silicon machines (tested on a MacBook Pro M1 Pro, J314s), a USB device that is connected while U-Boot runs is then not detected by Linux until it is unplugged and plugged back in. Running "usb stop" before booting avoids this.
Add
DM_FLAG_ACTIVE_DMAso the controller is removed, and its DMA stopped, before the handover.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Jacob Procee <[email protected]>Reviewed-by Marek Vasut <[email protected]>We're preferring to use
DM_FLAG_ACTIVE_DMAhere instead.Ok, no problem. Should I respin it now or do you prefer to wait to potential other comments on it?
Maybe wait a day to respin? I believe Marek is happy with this as the general solution now but I could be wrong.
Signature · 1 line
Tom