* [PATCH] usb: host: ohci/ehci: halt the controller before booting an OS
@ 2026-11-12 18:28 Jernej Skrabec
2026-11-12 18:35 ` Tom Rini
0 siblings, 1 reply; 4+ messages in thread
From: Jernej Skrabec @ 2026-11-12 18:28 UTC (permalink / raw)
To: marek.vasut+usb; +Cc: trini, u-boot, 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.
Mark OHCI and EHCI drivers with DM_FLAG_OS_PREPARE so remove hook stops
both controllers during OS boot.
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
---
drivers/usb/host/ehci-generic.c | 2 +-
drivers/usb/host/ohci-generic.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c
index 1ae3619ce25d..8075fb069f15 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 cc44226f5e0b..66f1fd6fd668 100644
--- a/drivers/usb/host/ohci-generic.c
+++ b/drivers/usb/host/ohci-generic.c
@@ -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,
};
--
2.56.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] usb: host: ohci/ehci: halt the controller before booting an OS
2026-11-12 18:28 [PATCH] usb: host: ohci/ehci: halt the controller before booting an OS Jernej Skrabec
@ 2026-11-12 18:35 ` Tom Rini
2026-11-12 18:39 ` Jernej Škrabec
0 siblings, 1 reply; 4+ messages in thread
From: Tom Rini @ 2026-11-12 18:35 UTC (permalink / raw)
To: Jernej Skrabec; +Cc: marek.vasut+usb, u-boot
[-- Attachment #1: Type: text/plain, Size: 1633 bytes --]
On Thu, Nov 12, 2026 at 07:28:38PM +0100, Jernej Skrabec wrote:
> 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.
>
> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
> ---
> drivers/usb/host/ehci-generic.c | 2 +-
> drivers/usb/host/ohci-generic.c | 2 +-
I think per:
commit d610f703f937ebf7681e5cc36905586666e7ceb8
Author: Jacob Procee <sn125164@gmail.com>
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.
Signed-off-by: Jacob Procee <sn125164@gmail.com>
Reviewed-by: Marek Vasut <marek.vasut+usb@mailbox.org>
We're preferring to use DM_FLAG_ACTIVE_DMA here instead.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] usb: host: ohci/ehci: halt the controller before booting an OS
2026-11-12 18:35 ` Tom Rini
@ 2026-11-12 18:39 ` Jernej Škrabec
2026-11-12 18:41 ` Tom Rini
0 siblings, 1 reply; 4+ messages in thread
From: Jernej Škrabec @ 2026-11-12 18:39 UTC (permalink / raw)
To: Tom Rini; +Cc: marek.vasut+usb, u-boot
Dne četrtek, 12. november 2026 ob 19:35:46 Srednjeevropski standardni čas je Tom Rini napisal(a):
> On Thu, Nov 12, 2026 at 07:28:38PM +0100, Jernej Skrabec wrote:
>
> > 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.
> >
> > Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
> > ---
> > drivers/usb/host/ehci-generic.c | 2 +-
> > drivers/usb/host/ohci-generic.c | 2 +-
>
> I think per:
> commit d610f703f937ebf7681e5cc36905586666e7ceb8
> Author: Jacob Procee <sn125164@gmail.com>
> 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.
>
> Signed-off-by: Jacob Procee <sn125164@gmail.com>
> Reviewed-by: Marek Vasut <marek.vasut+usb@mailbox.org>
>
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] usb: host: ohci/ehci: halt the controller before booting an OS
2026-11-12 18:39 ` Jernej Škrabec
@ 2026-11-12 18:41 ` Tom Rini
0 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2026-11-12 18:41 UTC (permalink / raw)
To: Jernej Škrabec; +Cc: marek.vasut+usb, u-boot
[-- Attachment #1: Type: text/plain, Size: 2184 bytes --]
On Thu, Nov 12, 2026 at 07:39:35PM +0100, Jernej Škrabec wrote:
> Dne četrtek, 12. november 2026 ob 19:35:46 Srednjeevropski standardni čas je Tom Rini napisal(a):
> > On Thu, Nov 12, 2026 at 07:28:38PM +0100, Jernej Skrabec wrote:
> >
> > > 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.
> > >
> > > Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
> > > ---
> > > drivers/usb/host/ehci-generic.c | 2 +-
> > > drivers/usb/host/ohci-generic.c | 2 +-
> >
> > I think per:
> > commit d610f703f937ebf7681e5cc36905586666e7ceb8
> > Author: Jacob Procee <sn125164@gmail.com>
> > 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.
> >
> > Signed-off-by: Jacob Procee <sn125164@gmail.com>
> > Reviewed-by: Marek Vasut <marek.vasut+usb@mailbox.org>
> >
> > 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.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-12 18:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 18:28 [PATCH] usb: host: ohci/ehci: halt the controller before booting an OS Jernej Skrabec
2026-11-12 18:35 ` Tom Rini
2026-11-12 18:39 ` Jernej Škrabec
2026-11-12 18:41 ` Tom Rini
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.