Repository navigation
usb: typec: tipd: replug a CD321x port that kept an attach across a reboot - #3587
Conversation
…eboot On a J414c (M2 Max) with a Thunderbolt dock, every reboot after the dock was plugged in while Linux ran leaves the dock dead: no USB4 link, no displays, no USB and no charging, until the cable is pulled and plugged back. The port's CD321x reports no plug after the warm reset although the dock is still attached. Bits 2 and 3 of byte 7 of register 0x7e stay set (0x3d on the dock's port; empty ports read 0x08). A dock attached at boot survives the same reboot, and so does a dock replugged with "DISC". Skipping the USB4 session close before the reboot (b3d63e0) does not change the outcome. At the probe, replug a CD321x port that reports no plug with both bits set, as pulling the cable does: unlocked, "DISC" for 5 s, locked again, through the existing replug work. The key is the board number reversed, as the J716c's is, taken from the machine's compatible. Other users of the replug (debugfs, dwc3-apple after a sleep) still need a key from the DT. Signed-off-by: Muness Castle <[email protected]>
There was a problem hiding this comment.
Verdict: MERGE at dde9bcb2 once the fork PR's CI workflows are approved and pass.
Blockers: none in code (await fork CI workflow approval and green checks).
Checked: Full 2-file diff (drivers/usb/typec/tipd/core.c, drivers/usb/typec/tipd/tps6598x.h), cd321x_board_key() bounds and NUL safety, cd321x_replug_kept_attach() condition/locking/lifecycle ordering in tipd_init(), tipd_replug_work() unlock/DISC/relock error handling, commit Signed-off-by, and exact-head J414c (T6021 M2 Max) reboot recovery proof.
Evidence
- Condition and scope (
drivers/usb/typec/tipd/core.c:79-108):- Strictly scoped to
apple,cd321xports that are ontipd_ports(skipping non-role-switch/MagSafe ports), report no plug (!(status & TPS_STATUS_PLUG_PRESENT)), and have bothCD321X_ATTACH_STATE_KEPT(bit 2) andCD321X_ATTACH_STATE_DONE(bit 3) set in register0x7ebyte 7 (leaving empty ports at0x08/0x04and attached ports untouched). cd321x_board_key()checks!strncmp(s, "apple,j", 7)followed by short-circuitedisdigit(s[7..9])(no out-of-bounds read on short compatibles) and leavestipd_replug_key()/tipd_replug_supported()unchanged for debugfs anddwc3-apple.- Runs at probe right after
tipd_port_list_add()(beforetipd_debugfs_register()andtps->data->ready()), guarded bytipd_ports_lock, sotipd_port_list_del()cancelsreplug_workcleanly on teardown. IfLOCKfails on any controller whose key differs,tipd_replug_work()skipsDISC, relocks, and logs a warning without crashing.
- Strictly scoped to
- Verification at
dde9bcb2(J414c M2 Max /T6021, Surface TB4 dock + 2 displays): After physical replug + menu reboot, stuck port (status 0x10000000, attach state0x3d) replugged at 2.4 s and recovered the dock at 12.3 s (both displays, 26 USB devices, charging); 2 further replug-and-reboot cycles with the dock present did not spuriously replug;0failed units, Touch ID restored. Commit carries valid humanSigned-off-by. - Non-blocking nit: Clearing
tps->kept_attach_replug = false;inside the initialmutex_lock(&tps->lock)section immediately after copyingkept_attach_key(instead of after themsleep+ relock loop atcore.c:3811) would keep all accesses tokept_attach_repluglocked undertps->lockduring the work execution.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
dde9bcb J316s (M1 Pro, T6000) PASS: combined guarded one-shot |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
|
Merged, thank you @muness. Your J414c (M2 Max) replug run and our J316s (M1 Pro) row at |
…it() harness aurora-silicon#3587 made tipd_init() call cd321x_replug_kept_attach(). The probe-transaction-rollback case extracts tipd_init() from tipd/core.c but has no stub for the new call, so it fails to build and the apple-dcp host test is red on main since 94104a6. Stub it like the neighbouring tipd_port_list_add(). Signed-off-by: Ryan Murray <[email protected]>
What: On a J414c (M2 Max) with a Thunderbolt dock, a reboot after the dock was plugged in while Linux ran usually leaves the dock dead: no USB4 link, no displays, no USB, no charging, until the cable is pulled and plugged back. The port's CD321x reports no plug although the dock is still attached, and keeps bits 2 and 3 of its attach state (register
0x7e, byte 7). At the probe, replug such a port through the existing replug work, as pulling the cable does.Tested: J414c M2 Max (T6021) at dde9bcb (
main1bd9c26 + this commit), -46 userspace, stock Aura b17, Surface TB4 dock with two displays. After a physical replug and a menu reboot the dock's port came up with no plug and attach state0x3d; the probe replugged it, and the dock was back 12 s into the boot with both displays, 26 USB devices and charging. Two more replug-and-reboot cycles came up with the dock present, and the replug did not run. 0 failed units, Touch ID restored.Risk: two-way door · Macs with CD321x port controllers (M1 and M2 families). It acts only on a port that reports no plug with both attach-state bits set. Only the J414c is tested.
Not yet: other CD321x Macs.
Details
DISC. A dock plugged in while Linux runs usually doesn't. Skipping the USB4 session close before the reboot (b3d63e0) does not change that, so it is not the cause.0x08. With bit 2 alone, a test build also replugged an empty port reading0x04; requiring both bits leaves it alone.DISCfor 5 s, locked again, throughtipd_replug_work. The probe queues it undertipd_ports_lockwith the checktipd_replug_request()uses, so it cannot race the port's removal.cd321x_inherited_boards), taken from the machine's compatible:apple,j414cgives "414J". The key travels with the queued replug only.tipd_replug_key()andtipd_replug_supported()are unchanged, so the other users of the replug (debugfs,dwc3-appleafter a sleep) still need a key from the DT.Evidence
Reboots on the J414c with the dock left attached (first-seen time of
thunderbolt 0-1in the next boot):--force, emergency restart0x3d, replugged at 2.4 s, dock at 12.3 sController state read in a stuck boot: dock port
status 0x10000000(no plug), attach state0x3d; empty ports0x08. ADISCreplug from the running system brought the dock back with nothing touched (attach state0x39after).The same code on the J414c sleep stack: one more recovery (
0x3d, dock at 12.4 s).The boots of this kernel log an SIO crash when DisplayPort audio starts, as
mainwithout this change does on Aura b17 (see #3569).