Skip to contentSkip to conversation

usb: host: ohci/ehci: halt the controller before booting an OS

PATCH Superseded Jernej Skrabec 2 participants 4 messages Nov 12

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 1ae3619ce25d..8075fb069f15 100644
@@ -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
index cc44226f5e0b..66f1fd6fd668 100644
@@ -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
Reviewed-by Marek Vasut on v1 1/1
#1 lore raw
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_PREPARE so remove hook stops both controllers during OS boot.

---
 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
#2 lore raw

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_PREPARE so remove hook stops both controllers during OS boot.

---
 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.

Quoted 7 lines

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.

Ok, no problem. Should I respin it now or do you prefer to wait to potential other comments on it?

Best regards,
Jernej

#3 lore raw
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_PREPARE so remove hook stops both controllers during OS boot.

---
 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.

Quoted 7 lines
Quoted 4 lines

We're preferring to use DM_FLAG_ACTIVE_DMA here 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