Skip to content

usb: dwc3: apple: do not enable USB2 hardware LPM - #442

Open
riopierrefrancois wants to merge 1 commit into
omacom:integration/aurorafrom
riopierrefrancois:dwc3-apple-no-usb2-lpm
Open

riopierrefrancois wants to merge 1 commit into
omacom:integration/aurorafrom
riopierrefrancois:dwc3-apple-no-usb2-lpm

Conversation

@riopierrefrancois

Copy link
Copy Markdown

On the Type-C controllers driven by dwc3-apple, the USB2 port does not come back from L1. A BESL-capable high-speed device plugged straight into a root port enumerates, the bus idles for 20 to 35 ms, and the next transfer raises a port PEC event and completes with USB Transaction Error. Every later transfer fails the same way and a port reset does not recover the device.

Seen with a Logitech Brio 500 (046d:0943) on every rear port of a Mac Studio M1 Max (apple,j375c, t6001):

uvcvideo 4-1:1.0: Failed to query (GET_INFO) UVC control 2 on unit 3: -71 (exp. 1).
uvcvideo 4-1:1.1: Failed to initialize the device (-71).
usb 4-1: 3:4: usb_set_interface failed (-71)

Full-speed devices and anything behind a hub are unaffected, because xHCI only enables USB2 hardware LPM for non-hub devices on a root port.

This sets usb2_lpm_disable on the dwc3 core, which becomes XHCI_HW_LPM_DISABLE.

Tested: j375c (t6001), a local build of 7.2.11 (4fdd0fc) with this change and the packaged config, m1n1 with omacom/m1n1#46. With the patch and no usbcore quirk, the camera's video, audio and HID interfaces bind, with no -71 in three boots. Without the patch, usbcore.quirks=046d:0943:k (USB_QUIRK_NO_LPM) set before plugging in gives the same result, which is what points at LPM. power/usb2_hardware_lpm still reads enabled afterwards; it reports what is allowed, not what xHCI did.

Not tested: any other SoC, other high-speed devices, suspend. The change applies to every dwc3-apple controller. If some SoCs are known to resume from L1 correctly, I can narrow it.

Refs #380. Maintainers are welcome to push to this branch or take the change over.

🤖 Generated with Claude Code

On the Type-C controllers driven by dwc3-apple the USB2 port does not
come back from L1. A BESL-capable high-speed device on a root port
enumerates, the bus idles for 20 to 35 ms, and the next transfer raises
a port error (PEC) and completes with a transaction error. Every later
transfer fails the same way and a port reset does not recover the
device:

  uvcvideo 4-1:1.0: Failed to query (GET_INFO) UVC control 2 on unit 3: -71 (exp. 1).
  uvcvideo 4-1:1.1: Failed to initialize the device (-71).

Devices behind a hub are unaffected, because xHCI only enables USB2
hardware LPM for non-hub devices on a root port.

Set usb2_lpm_disable on the dwc3 core so xHCI gets
XHCI_HW_LPM_DISABLE.

Tested on a Mac Studio M1 Max (j375c, t6001) with a Logitech Brio 500
(046d:0943) on the rear ports. Other SoCs are not tested.

Link: omacom#380
Generated-by: LLM
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: riopierrefrancois <rio.pierrefrancois@gmail.com>

@joshuaswarren joshuaswarren left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on 16-inch M1 Max MacBook Pro (T6001), Omarchy, Studio Display over Thunderbolt.

The Studio Display camera (USB device 3-1.4, high-speed) does not expose USB2 LPM controls in sysfs. No devices on this system have power/usb2_hardware_lpm or power/usb2_lpm_besl files. Only USB3 LPM controls exist (usb3_hardware_lpm_u1/u2 on the USB4 controller).

Streamed the camera for 2+ minutes with the port idle between streams. No PEC or transaction errors in dmesg.

Without sysfs controls for USB2 LPM, I cannot verify whether the dwc3-apple usb2_lpm_disable = true flag changes behavior. The bug cannot be reproduced on this hardware.

The fix is correct in principle (disabling USB2 hardware LPM to prevent port errors), but I cannot confirm it resolves a real issue here.

@joshuaswarren

Copy link
Copy Markdown

[Joshua's agent] Boot test of 68bb2ca on a 16-inch M1 Max MacBook Pro (T6001), kernel 7.3.0-2 (integration/aurora plus the lab config), one change versus the same kernel without it: dwc3-apple.ko with this patch.

What I can confirm:

  • The patched kernel boots, both dwc3 hosts come up in host mode, and dmesg shows no dwc3 or xhci error or warning since boot.
  • The patch applies with a little fuzz (offset of 184 lines) to our tree, and the flag is set at the same point in dwc3_apple_core_probe(), after dwc3_core_probe().
  • GUSB2PHYCFG(0) reads 0x00102540 on both dwc3 hosts, the same before and after the patch. That is expected: usb2_lpm_disable turns off hardware LPM in xHCI, and it does not clear the dwc3 register bit.

What I could not test: the failing case. On this machine a Studio Display is attached through a PCIe xHCI behind the Thunderbolt tunnel, not behind dwc3, and the only device on the dwc3 hosts is a 10G Ethernet adapter on the USB3 side. There is no high-speed device on a dwc3 root port, so a camera stream followed by idle cannot reproduce the PEC error or show the fix. The test needs a BESL-capable USB2 camera plugged straight into a Type-C port. I have none attached right now.

So this is a boot check of the patch, not a reproduction of the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants