Skip to contentSkip to conversation

usb: xhci-dwc3: Add DM_FLAG_OS_PREPARE flag

PATCH Superseded Jacob Procee 2 participants 3 messages Oct 22

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: xhci-dwc3: Add DM_FLAG_OS_PREPARE 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_OS_PREPARE so the controller is removed before the handover, as was done for xhci-pci in commit e3bbc1f74e05 ("usb:
xhci-pci: Add DM_FLAG_OS_PREPARE flag").

---
 drivers/usb/host/xhci-dwc3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-dwc3.c +1 -1
index 3504a7cf4..92b311d42 100644
@@ -256,6 +256,6 @@ U_BOOT_DRIVER(xhci_dwc3) = {
 	.ops = &xhci_usb_ops,
 	.priv_auto	= sizeof(struct xhci_ctrl),
 	.plat_auto	= sizeof(struct xhci_dwc3_plat),
-	.flags = DM_FLAG_ALLOC_PRIV_DMA,
+	.flags = DM_FLAG_OS_PREPARE | DM_FLAG_ALLOC_PRIV_DMA,
 };
 #endif
Signature · 1 line
2.55.0
#1 lore raw
Quoted 24 lines · Jacob Procee

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_OS_PREPARE so the controller is removed before the handover, as was done for xhci-pci in commit e3bbc1f74e05 ("usb:
xhci-pci: Add DM_FLAG_OS_PREPARE flag").

---
  drivers/usb/host/xhci-dwc3.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-dwc3.c +0 -0
index 3504a7cf4..92b311d42 100644

drivers/usb/host/xhci-dwc3.c U_BOOT_DRIVER(xhci_dwc3) = { · line 259

Quoted 5 lines
drivers/usb/host/xhci-dwc3.c +1 -1
@@ -256,6 +256,6 @@ U_BOOT_DRIVER(xhci_dwc3) = {
  	.ops = &xhci_usb_ops,
  	.priv_auto	= sizeof(struct xhci_ctrl),
  	.plat_auto	= sizeof(struct xhci_dwc3_plat),
-	.flags = DM_FLAG_ALLOC_PRIV_DMA,
+	.flags = DM_FLAG_OS_PREPARE | DM_FLAG_ALLOC_PRIV_DMA,

Does DM_FLAG_ACTIVE_DMA also fix the problem for you ?

#2 lore raw
Quoted 1 line · Marek Vasut

Does DM_FLAG_ACTIVE_DMA also fix the problem for you ?

I tested DM_FLAG_ACTIVE_DMA on the MacBook Pro M1 Pro with a cold boot and a USB device plugged in, and it works fine. I've updated the patch to use this flag and will send it as v2.