All of lore.kernel.org
 help / color / mirror / Atom feed
From: khaliforce <kforce@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: Neil Armstrong <neil.armstrong@linaro.org>,
	Marek Vasut <marex@nabladev.com>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v2] usb: stop generic OHCI and EHCI at OS handoff
Date: Wed,  7 Oct 2026 00:58:33 +0900	[thread overview]
Message-ID: <20261006155833.68374-1-kforce@gmail.com> (raw)
In-Reply-To: <3ae0a18e-0fa5-477d-bf5e-89072b9634ba@linaro.org>

The generic OHCI and EHCI drivers provide remove callbacks, but do
not set DM_FLAG_ACTIVE_DMA. 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 U-Boot memory. In particular, OHCI may continue
accessing its HCCA.

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

Signed-off-by: khaliforce <kforce@gmail.com>
---
Changes in v2:
- Use DM_FLAG_ACTIVE_DMA as suggested by Neil Armstrong.

Retested on MangoPi MQ Pro with the downstream D1 port based on
U-Boot v2026.10 and Linux 6.1:
- Read a 64 GB FAT32 USB device in U-Boot.
- Verified a 4096-byte read against Linux using CRC32.
- Booted Linux without running "usb stop".
- Confirmed USB reads, Wi-Fi and SSH after the handoff.
- Observed no panic, Bad page or failed services.

Standalone builds pass for RISC-V64, ARM64 and ARM32 on upstream
main. RISC-V64 QEMU boots. 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..57f1bcbd9c0 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_ACTIVE_DMA,
 };
diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
index cc44226f5e0..7493750f8d1 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_ACTIVE_DMA,
 };

  reply	other threads:[~2026-10-06 16:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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   ` khaliforce [this message]
2026-10-06 16:10     ` [PATCH v2] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261006155833.68374-1-kforce@gmail.com \
    --to=kforce@gmail.com \
    --cc=marex@nabladev.com \
    --cc=neil.armstrong@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.