Skip to content

t8140: rearm the debug link reliably after a sleep - #1285

Closed
DjDeveloperr wants to merge 8 commits into
fix/t8140-ni1-pcie-slpddrfrom
fix/t8140-debug-link-rearm
Closed

DjDeveloperr wants to merge 8 commits into
fix/t8140-ni1-pcie-slpddrfrom
fix/t8140-debug-link-rearm

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

After a Linux sleep, the host's debug-USB reboot VDM sometimes got no answer from the MacBook Neo (J700), and the host's PD controller stayed busy on it until the cable was replugged.

Cause. Before each sleep, t8140-sleep cuts the debug link with a cold reset of the debug port's controller (sn201202x 1-0c). tipd then rearms it on resume. Two things went wrong:

  • The controller sometimes refused a rearm command (-EPERM). The sequence stopped right there, leaving the controller in its "DBMa" debug mode, unlocked (its mode register read DBMa instead of APP ). The Debug USB stayed down, and the reboot VDM went unanswered for the rest of the boot.
  • In about 1 in 25 cuts, the partner never got a power contract back after the reset. It stayed attached with no PD, while the controller saw nothing attached. No rearm or VDM could get through until something made the port attach again.

Fix.

  • tipd: after entering debug mode, wait for the mode register before enabling the debug VDM, as the boot loader does. Leave debug mode and lock again after a failed step too. Repeat a failed rearm every 250 ms for up to 10 s from a delayed work, and keep it pending across a sleep that comes first.
  • t8140-sleep: after the cut's reset, poll the controller's power status for a PD contract (up to 5 s) and log how long it took. If no contract comes, reset again, up to 3 times.

Hardware (J700). Stock DTB, production command line, SEP active. Each sleep was RTC-woken; the first of a boot is deep, the rest keep DRAM.

  • The final kit with Deep sleep (suspend-to-RAM) for the MacBook Neo (T8140) at EL2 #1208's head e544085 merged locally: 17 sleeps, all returned. NVMe, USB hub and keyboard, Wi-Fi, display and mics were OK after every wake.
  • 8 VDM reboots, each sent after deep and/or DRAM-kept sleeps on these kits: every one reached the loader, Debug USB enumerated, and the next kit booted. 2 more worked after a host-side recovery (below).
  • On the PR head's tree: 23 sleeps, and every cut's partner had its contract back at the first poll (1000 ms).
  • With injected rearm failures (1, 3 and 8 tries; TEST kits only): each failed try left the controller in APP mode, and a later try rearmed the link.
  • Before the fix, a no-contract cut wedged the host's controller. Its simulated unplug brought PD back, and the reboot VDM then worked from the APP -mode controller.

Not yet shown on hardware. The second reset in t8140-sleep hasn't met a real no-contract cut yet (none occurred in 35 cuts with it), so whether it brings the partner back is still open. The sn201202x rejects DISC (-EINVAL), so a simulated unplug from the Neo's side isn't an option. Separately, on the merged test kit only, from its 13th sleep on the cut's first SPMI commands timed out (the stop failed: -110). The link then stayed up through those sleeps, and they still returned. This wasn't seen in 20 sleeps on the PR's tree alone.

🤖 Generated with Claude Code

The sleep controller ends the debug port's link with a cold reset of its
port controller, and tipd rearms it in .complete with the boot loader's
sequence. On the J700 a rearm can be refused: the controller rejects one
of the commands. The sequence then stopped, so the controller stayed in
its "DBMa" debug mode, unlocked, and the Debug USB didn't come back for
the rest of the boot.

Wait for the mode register after entering debug mode, as the boot loader
does, before enabling the debug VDM. Leave debug mode and lock again
after a failed step too. Repeat a failed rearm every 250 ms for up to
10 s from a delayed work, and keep it pending across a sleep that comes
first, since a link that is down isn't cut again.

Signed-off-by: Diljit Singh <hey@djdev.me>
The debug link is cut before a sleep with a cold reset of its port
controller. The partner takes that as an unplug, attaches again and
renegotiates its power contract. On the J700 that failed in about one
sleep in 25: the controller saw nothing attached while the partner kept
no contract, tipd's rearm was refused, and no VDM from the partner got
through until the cable was replugged.

After the reset, poll the controller's power status for a PD contract,
for up to 5 s, and log how long it took. If none comes, reset it again,
up to three times, then go on as before.

Signed-off-by: Diljit Singh <hey@djdev.me>
Keep the tipd rearm and the partner wait after the cut; take the stack
below, with #1304 and its EDAC merge, as is.
cd321x_init_work() now also sets up rearm_work, so the probe fixtures'
cd321x needs the member, as it has update_work and resume_work. Without
it typec-probe and probe-mux-pm-dispatch no longer compile.

Signed-off-by: Diljit Singh <hey@djdev.me>
Brings in integration/aurora 15f88e1 through #1208. No conflicts.

Signed-off-by: Diljit Singh <hey@djdev.me>
Brings in #1208's aop-bootargs host test fix. No conflicts.

Signed-off-by: Diljit Singh <hey@djdev.me>
Signed-off-by: Diljit Singh <hey@djdev.me>
Brings in integration/aurora ac11649 (#1311, PCIe multi power domain
support) through #1208. No conflicts.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Superseded by #1445 (merged as 2b05915); its changes are in integration/aurora. The debug-link rearm is sleep_hpm_wait_contract() in drivers/soc/apple/sleep.c; the tipd side is in drivers/usb/typec/tipd/.

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.

1 participant