usb: xhci-dwc3: Add DM_FLAG_OS_PREPARE flag
Subsystems (2)
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
@@ -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
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_PREPAREso the controller is removed before the handover, as was done for xhci-pci in commite3bbc1f74e05("usb:
xhci-pci: AddDM_FLAG_OS_PREPAREflag").Signed-off-by Jacob Procee <[email protected]>--- drivers/usb/host/xhci-dwc3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/host/xhci-dwc3.c +0
-0
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 ?
Quoted 1 line · Marek Vasut
Does
DM_FLAG_ACTIVE_DMAalso 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.