Repository navigation
usb: typec: tipd: put an empty CD321x port to sleep, as macOS - #425
nekolyanich wants to merge 1 commit into
Conversation
On an M2 Pro (j416s), replugs of a USB-C to HDMI adapter in DP alt mode often never reach the display: 10 of 24 on integration/aurora under the m1n1 hypervisor, 26 of 56 natively. After the unplug of a session with DP, the controller keeps the cable power path "in" and the session's data status; the next plug gets no VBUS and never reaches PD (2 of 2 in a trace). Unplugging that plug clears the state, so plugs alternate. macOS, traced on the same port, puts the port into system power state 2 on every disconnect: 0x2000 to the undocumented register 0x50, SSPS 2, 0x2000 and 0 to 0x50 (8 of 8). It sends SSPS 0 as soon as STATUS shows the next plug, and puts the empty MagSafe controller to sleep at boot. Do the same from the cable work, on the CD321x only (port_sleep): when it finds no plug on a port not known to be asleep, the sequence above, after reading STATUS again (a plug skips it); when it sees a plug on a port not known to be awake, SSPS 0 before anything else. Removing the driver also restores S0. A failure only warns and leaves the state unknown, as do resume and the controller setup recovery, so the next pass tries again. Testing: MacBook Pro 16" M2 Pro (j416s), DCP firmware 13.5, a TV on the adapter and a Dell over Thunderbolt, under the m1n1 hypervisor. On integration/aurora, 8 of 8 TV replugs reached the display; an I2C trace showed the sleep (state 2 read back) at each unplug and SSPS 0 (state 0) at each plug. Unbinding on the empty port restored S0, rebinding slept it, a plug and a replug about 1.4 s after an unplug came back. No failed sleep or wake, no kernel warning. Earlier: 0 of 24 lost against 4 of 16 on aurora-wip, and 16 of 16 natively on a downstream tree. Assisted-by: Claude:claude-opus-5-5 checkpatch Signed-off-by: nekolyanich <me@nekolyanich.com>
|
The current repair is review/pr425-fixtures-t3094-v3, head afe724c, with original authorship/sign-off followed by fixture-only commits. The original code reproduces 41/63 on this base; all 22 failures are fixture compile errors and the relevant production blob IDs are identical after repair. The repaired suite passes 66/66, keeping all 63 old groups and adding three actual power/ordering groups. The fixtures retain distinct controller/fabric/external/mode/tunnel locks and unknown-key rejection. Three positive controls and six broken variants pass their expected outcomes; every mutant compiles and fails at runtime. This covers sleep with a plug, forgotten wake failure, cable wake/sleep and removal wake under a real mutex. On integration/aurora at 421e314 with shared #438 and #456, DCP is PASS (66/66). KUnit has 905 passes and 1 policy skips. Universal WERROR is PASS; Fedora-base WERROR is PASS. Software gates pass; hardware and shared #438/#456 review pending. The operator reports #456 passed all 63 host groups with stock make 3.81 and GNU Make; this worker did not rerun native macOS on the assembled base. Hardware still needed: J416s empty port/replug/resume/cold boot, MagSafe, USB-only and sleeping controller; M1 Pro/Neo regression. |
|
Tested on J416s (M2 Pro),
Runs and this summary were prepared with Claude (Opus 5.5); counts checked against the logs. |
Replaces #296, which was opened on aurora-wip (since retired). Same change on integration/aurora, with the wake moved earlier, S0 restored when the driver is removed, and aurora's controller setup recovery taken into account.
On an M2 Pro (j416s), replugs of a USB-C to HDMI adapter in DP alt mode often never reach the display. On integration/aurora under the m1n1 hypervisor, 10 of 24 guided replugs were lost (6, 4 and 4 of 8 reached the display in three sessions), every other plug from some cycle on. Natively on our tree before this change, 26 of 56. A lost plug gets the Type-C partner, but nothing enumerates behind the adapter, the port gets no DP route and DCP no HPD.
Cause. After the unplug of a session with DP, the CD321x stays half-connected: a trace of its status showed the cable power path still "in" and the session's data status kept, and the next plug got no VBUS and never reached PD (2 of 2). Unplugging that plug clears the state, hence the alternation. macOS, traced on the same port with the same TV and adapter, puts the port into system power state 2 on every disconnect (
0x2000to the undocumented register 0x50,SSPS 2,0x2000and0to 0x50; 8 of 8) and sendsSSPS 0as soon as STATUS shows the next plug. At boot it also puts the empty MagSafe controller to sleep.The change (CD321x only,
port_sleepintipd_cd321x_data; the driver tracks the port as unknown, awake or asleep):SSPS 0, before any teardown or partner registration;SSPS 0;Testing: MacBook Pro 16" M2 Pro (j416s), DCP firmware 13.5, a TV on the adapter, a Dell over Thunderbolt on another port, under the m1n1 hypervisor (with a bench-only DT change):
SSPS 0(state read back 0) at each of the 8 plugs;SSPS 0, binding it again puts the port to sleep at probe, then a plug and a replug about 1.4 s after an unplug both bring the TV back;Not tested: