All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: stop generic OHCI and EHCI at OS handoff
@ 2026-10-06 11:13 khaliforce
  2026-10-06 13:22 ` Neil Armstrong
  0 siblings, 1 reply; 9+ messages in thread
From: khaliforce @ 2026-10-06 11:13 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Tom Rini

The generic OHCI and EHCI drivers provide remove callbacks, but do
not set DM_FLAG_OS_PREPARE. Consequently, their controllers can
remain active when U-Boot hands control to the operating system.

An active controller may continue DMA after the operating system
starts reusing memory previously occupied by U-Boot. In particular,
OHCI may continue accessing its HCCA.

Set DM_FLAG_OS_PREPARE on both drivers so that their existing remove
callbacks stop the controllers during OS preparation.

Signed-off-by: khaliforce <kforce@gmail.com>
---
Tested on a MangoPi MQ Pro with U-Boot v2026.10 and Linux 6.1:

- Started USB and accessed a 64 GB FAT32 USB storage device.
- Read 4096 bytes in U-Boot and verified that their CRC32 matched
  the same data read under Linux.
- Booted Linux without manually running "usb stop".
- Confirmed USB storage access and Wi-Fi/SSH after the handoff.
- Observed no panic or Bad page errors in the kernel log.

The hardware test used the downstream D1/MangoPi port.

The standalone patch also builds on current upstream main for
RISC-V64, ARM64 and ARM32. Checkpatch reports no errors or warnings.

 drivers/usb/host/ehci-generic.c | 2 +-
 drivers/usb/host/ohci-generic.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 1ae3619ce25..8075fb069f1 100644
--- a/drivers/usb/host/ehci-generic.c
+++ b/drivers/usb/host/ehci-generic.c
@@ -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,
 };
diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index cc44226f5e0..6cc26e2d3c0 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -110,5 +110,6 @@ 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,
+	/* Stop HCCA DMA before Linux reuses the controller memory. */
+	.flags	= DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_OS_PREPARE,
 };

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-10-12  2:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-06 11:13 [PATCH] usb: stop generic OHCI and EHCI at OS handoff khaliforce
2026-10-06 13:22 ` Neil Armstrong
2026-10-06 15:58   ` [PATCH v2] " khaliforce
2026-10-06 16:10     ` Tom Rini
2026-10-11 15:16       ` Marek Vasut
2026-10-11 22:03         ` Tom Rini
2026-10-11 22:24           ` Marek Vasut
2026-10-11 22:31             ` Tom Rini
2026-10-12  2:32         ` khaliforce

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.