Skip to content

drm/apple, usb: Type-C route and USB4 link-recovery follow-ups (#3040, #3109 reviews) - #3540

Merged
DjDeveloperr merged 3 commits into
mainfrom
fix/typec-route-link-followups-20261129
Dec 4, 2026
Merged

DjDeveloperr merged 3 commits into
mainfrom
fix/typec-route-link-followups-20261129

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

What: Follow-ups from the reviews of #3040 and #3109. Routes with disabled suppliers stay refused. The OF changeset bookkeeping is released after permanent route disables, and repeated disables are skipped before allocation. The active USB4 PIPE backend is modelled before host shutdown, and the Type-C shutdown comment is corrected. Automatic USB4 link-lost recovery gets a per-port rate limit of three port cycles per minute, which domain rebuilds and briefly seen peers do not refill. The consecutive budget still refills on discovery.

Tested: Build and host tests only, no Mac row yet. Rebased onto main 8973cea, keeping main's revert-before-destroy ordering in the route-supplier test. The three touched arm64 objects build. Topology KUnit passes 8/8. ATCPHY host checks pass 39 and reject 66/66 mutations, including main's newer control. The link-lost checks pass and both negative controls are rejected. Strict checkpatch is clean on both commits.

Risk: two-way · USB-C/USB4 display routes and link recovery on every Mac with ATC ports.

Not yet: a row at head on one USB4 Mac (J616s or J713): DP-alt plug/unplug plus a flapping-peer recovery check. A regression Mac is also owed. It merges cleanly with #3530, which touches the same test file.

Evidence

Source item: M2MINI-USBC-FULL.md:178 (#3040 review nits of 11-24 17:17, #3109 review nit 2).

Release the OF changeset bookkeeping after permanent route disables and
skip repeated disables before allocation. Cover both node reference
balance and repeated refusal in the topology KUnit suite. The installed
properties remain owned by OF.

Model the active USB4 PIPE backend before host shutdown and exercise mux
disconnect on each supported PHY sequence. Correct the Type-C shutdown
comment to describe PIPE parking and mux ownership.

Keep discovery-based refill of the consecutive link-lost budget, but bound
automatic recovery with a separate per-port rate limiter: three cycles per
one-minute window. Domain reconstruction and a briefly discovered peer
must not refill that limit.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
An idempotent disable can return NULL when another refusal already
disabled the route. Keep that distinct from an available supplier: the
route must still be skipped. Cover a repeated supplier refusal in KUnit.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners November 28, 2026 13:39

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: FINISH, then merge at 3130666e

Blockers:

  1. Hosted CI at 3130666e (21 jobs: kunit, apple-build, host-tests, pr-text, readiness, KUnit suites) is currently QUEUED; wait for green CI.
  2. Missing exact-head hardware rows (J616s or J713 USB4 DP-alt plug/unplug + flapping-peer recovery check plus one regression Mac; noted as queued in Not yet:).

Checked: no Apple material, no AI attribution, human DCO Signed-off-by on both commits, no chip/board/firmware gates, no new parameters, full diff (+104/-15 across dcp-fabric.c, dcp-fabric-topology-test.c, drivers/thunderbolt/apple.c, drivers/usb/typec/tipd/core.c, tools/asahi/atc-usb3-tests.py) verified, dcp_typec_routes_disable_nodes() skips allocation when already disabled and dcp_typec_routes_disable_free() releases changeset bookkeeping without leaking device_node krefs (proved by topology_route_disable_cleanup_test), dcp_typec_route_skip() returns cs ?: ERR_PTR(-ENODEV) so concurrent disables still skip the route, apple_cio.link_lost_limit (3 cycles per 60 * HZ) survives domain rebuilds and brief peer discoveries, atc-usb3-tests.py covers T8103/T8122/T8132 PIPE parking and mux disconnect with 2 new mutations (39 checks + 66/66 mutations killed), 8/8 topology KUnit + arm64 object builds + checkpatch --strict clean, PR body has Tested: and Risk: two-way, branch is MERGEABLE against main.

Evidence
  • drivers/gpu/drm/apple/dcp-fabric.c & dcp-fabric-topology-test.c (3130666ed1):
    • dcp_typec_routes_disable_nodes() checks route ? !of_device_is_available(route) : !dcp_typec_routes_available(routes) before kzalloc_obj(*cs).
    • dcp_typec_routes_disable_free() calls of_changeset_destroy(cs); kfree(cs); on non-ERR/non-NULL changesets; topology_route_disable_cleanup_test() checks kref_read(&route_np->kobj.kref) stays unchanged and repeated disables keep the exact status property pointer.
  • drivers/thunderbolt/apple.c (b08e1731ec): initializes acio->link_lost_limit in apple_cio_probe() with APPLE_CIO_LINK_LOST_INTERVAL (60 * HZ) / APPLE_CIO_LINK_LOST_CYCLES (3) and gates automatic link-lost restarts with __ratelimit(&acio->link_lost_limit) before incrementing link_lost_cycles or setting link_lost_restart.
  • drivers/usb/typec/tipd/core.c & tools/asahi/atc-usb3-tests.py: updates shutdown ordering comment and extends host tests to T8122 + usb4-stop-skips-pipe-park / cio-mux-disconnect-keeps-lanes mutations.
  • Code is clean; ready to approve and merge once CI is green and the queued hardware rows pass at 3130666e.

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 77ed8556: ready to merge

Check Detail
CI at head ok 9 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 77ed8556
Conflicts ok none
PR text ok Risk: two-way · USB-C/USB4 display routes and link recovery on every Mac with ATC ports.

Areas: area:display, area:gpu, area:usb
Merge: gh pr merge 3540 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@aurora-silicon-review aurora-silicon-review Bot 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.

Verdict: MERGE at 3130666ed186

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: no Apple material, no AI attribution, human DCO Signed-off-by on both commits, no chip/board/firmware gates, no new parameters, full diff (+104/-15 across dcp-fabric.c, dcp-fabric-topology-test.c, drivers/thunderbolt/apple.c, drivers/usb/typec/tipd/core.c, tools/asahi/atc-usb3-tests.py) verified, dcp_typec_routes_disable_nodes() skips allocation when already disabled and dcp_typec_routes_disable_free() releases changeset bookkeeping without leaking device_node krefs (proved by topology_route_disable_cleanup_test), dcp_typec_route_skip() returns cs ?: ERR_PTR(-ENODEV) so concurrent disables still skip the route, apple_cio.link_lost_limit (3 cycles per 60 * HZ) survives domain rebuilds and brief peer discoveries, atc-usb3-tests.py covers T8103/T8122/T8132 PIPE parking and mux disconnect with 2 new mutations (39 checks + 66/66 mutations killed), 8/8 topology KUnit + arm64 object builds + checkpatch --strict clean, PR body has Tested: and Risk: two-way, branch is MERGEABLE against main.

Follow-ups (not blocking): queued CI; J616s/J713 USB4 DP-alt + flapping-peer row

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 1, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Dec 2, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Correct. The changeset is now freed in every caller. Destroying an applied changeset leaves its properties in the live tree, and the new KUnit case checks that, with refs unchanged. A repeated refusal returns before allocating. The link-lost rate limit can't be refilled by discovery.

Small optional nit: __ratelimit() prints "callbacks suppressed" when the window ends. ratelimit_set_flags(&acio->link_lost_limit, RATELIMIT_MSG_ON_RELEASE) after init keeps that quiet next to your own warning.

Left before merge: the cancelled KUnit jobs (I re-ran them), and the rows. This touches shared Type-C/USB4 code, so it needs two generations: DP-alt plug/unplug plus a flapping-peer check. I've queued J773g and J714s.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 2, 2026
@DjDeveloperr

DjDeveloperr commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

J773g (M4 mini, T8132, 27.2) 3130666ed186 PASS — regression row only (7.3.0-j773g-comp5 on main b47fc630, boot_id=3a101384-2cfc-4aa6-835b-6d4f9a3692b5): DP-3 (3840x2160) DP-alt active at boot on USB-C Back Right (0x0f010100/0x546005e3), 5/5 software DRM off->detect cycles (not physical Type-C unplug) restored connected/enabled/On 3840x2160 (max 6 ms), USB 3-1 (05e3:0f01) 3/3 deauth/auth OK; initial s2idle pass was 0/3 (/dev/rtc0 lacks wakeup) and /dev/rtc1 rerun completed 3/3 s2idle cycles with 05e3:0f01 re-enumerated 3-1 -> 2-1 (POST_SLEEP_USB_MATCH=0, xHCI usb2/usb3 root-hub bus renumbering on resume); flapping-peer USB4 link-lost check did not run; 0 route-supplier/USB4/tipd/PIPE/link-recovery errors, 0 WARN/Oops/DART faults, 0 failed units.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) ready-to-merge Meets the merge policy: merge it (bot) labels Dec 2, 2026
…ndow

The per-port limit of three automatic restarts a minute returned for good
on the fourth lost link. A flapping peer that then settled never got its
link back: on a J616s with a host-to-host USB4 peer, the peer's controller
came back each time, but the J616s port stayed without a link until a
replug, because only a restart from this side brings it up again.

Re-arm the link-lost check for the end of the window when the limit
refuses a restart. A peer that is present by then is left alone; one that
is still missing gets a normal restart, inside a fresh window. Also keep
the ratelimit's "callbacks suppressed" report quiet next to our own
warning.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ready-to-merge Meets the merge policy: merge it (bot) labels Dec 3, 2026
@github-actions github-actions Bot added the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

J616s (M4 Pro) USB4 flapping-peer row, plus one fix pushed on top: 77ed8556.

Problem found at 3130666e: once the limit refused a restart (the 4th link loss inside a minute), nothing checked the port again. The peer (a J473 host-to-host over USB4) came back every time, but the J616s link stayed down until an ACIO rebind (2.5 min, 3 more flaps, no recovery).

Fix (77ed8556, +13/-2, drivers/thunderbolt/apple.c): when the limit refuses, the link-lost check is re-armed for the end of the window. If the peer is back by then it's left alone; if it's still missing, the port gets a normal restart. This also takes Dj's nit (RATELIMIT_MSG_ON_RELEASE). checkpatch --strict clean.

Tested on one-shot kernels on the J616s (main 2533c76f + this PR + linux#3530; flaps driven from the J473 by unbinding/binding its ACIO, no reboot of the J473):

  • 3130666e: 3 restarts, then "rate limit reached", then never checked again.
  • 77ed8556: 3 restarts, then "next port restart check in 60 s". The check fired 61.3 s later and restarted the port (1/3).
  • 1x rtc1 s2idle with the peer on each build: PASS, peer back, ping 3/3, no oops.

The restart from the deferred check didn't bring the link up. That's pre-existing: on saved fleet94 (no PR), a J616s link-lost restart while the J473 port is already back never relinks (0/5), even though an ACIO rebind does. I'll file it as a separate issue.

Still to run: the DP-alt display plug/unplug part. No monitor is attached to the J616s tonight; it's queued as a morning hands item.

Logs

Lab evidence: traces/usb/20261203-j616s-pr3540-flap (flap.sh, dmesg for each arm, fleet94 controls with 5 s and 1 s down times).

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 3, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed 77ed8556a2cf with #3530. Both shared-file patches apply together. The OF changeset cleanup drops bookkeeping while preserving the live disabled property. The USB4 rate limit survives a rediscovery, and the deferred check still verifies the cable, generation and peer before restarting. The exact-head ATCPHY fixture passed all 39 cases and caught all 66 mutations.

The J616s result exercises the deferred check. The subsequent relink failure also reproduces on fleet94. The remaining display check is a physical DP-alt unplug/replug on the combined build, with s2idle reconnect. The J773g software DRM toggles cover regression behavior.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026
@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed ready-to-merge Meets the merge policy: merge it (bot) labels Dec 3, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Not rowable in our lab today without hands. Exercising the Type-C reconnect path needs a USB-C DP-alt monitor that is really unplugged and replugged, and we have none free right now. I tried a software unplug instead: the tipd debugfs DISC (simulated disconnect) is accepted by the driver's command filter, but the J616s's SN201202x port controller rejects it (EINVAL) unless the controller is put into its debug mode first, and I did not do that. The M2 Air (CD321x) now has no DP monitor attached. So this needs a hand replug of a plain USB-C→DP monitor; we will pick it up if one becomes free.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J773g (Mac mini M4, T8132, OS fw 27.2) real Type-C replug + DRM + s2idle hardware verification for linux#3530 (2b2b96b8db968821267c81d5ef1c595a47ba1016) + linux#3540 (77ed8556a2cf33457abc5ae51db40046468c61cb) on main a0e5cf151159: VERDICT PASS.

  • Kernel & kit: 7.3.0-j773g-tcr1 Arm B (Stage 2 1.0.0b18-g0745e344, boot 29880ad6-4d13-4642-9899-ced685c103d8), work/kit-j773g-3530-3540-20261203 (SHA256SUMS 5cc822ba135f75bf4f0812efe2880c67677838aa1ad6cfd4b473d2076b05fc9b, --check 9/9, live 7/7)
  • Loaded Arm B modules (verified by build ID): appledrm (f6372e739106252917e44e439041eb217b490d42), tps6598x_core (7f58498bb1d97b317275255fd4e10182ac654648); thunderbolt_apple not loaded on J773g (no USB4 peer on Back Right; USB4 flapping-peer path covered by J516s/J616s rows)
  • Target port & display: USB-C Back Right (hpm 1-08, partner 0x0f010100/0x546005e3, card1-DP-3 connected/enabled/On/3840x2160)
  • Results (ARM b CLEAN, 16/16 checks PASS):
    • Boot: 0 WARN/BUG/Oops, display up connected/enabled/On/3840x2160, watchdog 60 s + 25 min dead-man armed
    • Software DRM off -> detect: 5/5 passed
    • Real Type-C replugs (tipd debugfs replug = 3 s on USB-C Back Right only): 5/5 took DP alt mode down and reconnected cleanly (replugs that took DP alt mode down: 5, real replugs all reconnected: 5/5, 0 WARN/BUG/Oops, 0 Type-C DPTX reconnect failed)
    • s2idle (rtcwake -m freeze -s 20, 21 s): rc=0, display & partner back (ok 5ms connected/enabled/On/3840x2160, 0x0f010100/0x546005e3)
    • End state: 0 WARN/BUG/Oops, taint unchanged (4 -> 4), 0 new failed units, dead-man disarmed, phase=done

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J516s (MacBook Pro 14" M3 Pro, apple,j516s, T6030, OS fw 27.2) second-generation real Type-C / USB4 replug + s2idle row for linux#3530 (2b2b96b8db96) + linux#3540 (77ed8556a2cf) on main a0e5cf151159: VERDICT PASS.

  • Kernel & kit: 7.3.0-j516s-tcr1 Arm B (one-shot GRUB on stock Stage 2 1.0.0b17-g683a128b and stock DT, boot_id=fce1e68d-e0d0-46e8-95f6-b668ef62a9ab), work/kit-j516s-3530-3540-20261203 (SHA256SUMS 58bfd135…, --check 9/9, live 9/9).
  • Loaded Arm B modules (verified by build ID):
    • appledrm: adb48ed277b15a7c1187203a4813f8b4ddfd045d
    • thunderbolt_apple: f27b175478aff9e4cbf020ec887aa50f46e2968a
    • tps6598x_core: 583fb2e978f1af06372bfc9781b6a88e61755eb7
  • Real Type-C replugs (5/5 PASS): USB-C Left Front (1-0a) holding Thunderbolt 5 dock WL-UTD59 (0x0d590052/0x4c402629, USB4 router 0-1, gen4 20.0 Gb/s x2, auth=1):
    • Replug 1: gone=635ms usb4_gone=116ms partner_back=4344ms usb4_up=5714ms, auth1, 0 WARN/BUG/Oops
    • Replug 2: gone=1257ms usb4_gone=120ms partner_back=4351ms usb4_up=5756ms, auth1, 0 WARN/BUG/Oops
    • Replug 3: gone=644ms usb4_gone=116ms partner_back=4290ms usb4_up=5796ms, auth1, 0 WARN/BUG/Oops
    • Replug 4: gone=1179ms usb4_gone=119ms partner_back=4337ms usb4_up=5735ms, auth1, 0 WARN/BUG/Oops
    • Replug 5: gone=1154ms usb4_gone=119ms partner_back=4350ms usb4_up=5806ms, auth1, 0 WARN/BUG/Oops
  • s2idle (rtcwake -m freeze -s 20): rc=0, suspend_ok 0 -> 1, dock & USB4 router back in 7 ms (0-1 WL-UTD59 gen4 20.0 Gb/s x2 auth1).
  • Health: 0 WARN/BUG/Oops across boot, all 5 replugs, and end; taint unchanged (4 -> 4), 0 new failed units, route_skipped=0, link_lost=0.
  • Scope note: eDP-only on this laptop (no external display attached), so this second-generation row exercises shared Type-C / CIO / thunderbolt_apple / tps6598x_core replug and s2idle paths; external DP alt-mode reconnect is covered by the J773g row.
  • Evidence: work/kit-j516s-3530-3540-20261203/results/verdict.txt.

@DjDeveloperr
DjDeveloperr merged commit 59c5567 into main Dec 4, 2026
12 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/typec-route-link-followups-20261129 branch December 4, 2026 00:24
DjDeveloperr added a commit that referenced this pull request Dec 4, 2026
Brings the branch up to main after #3786 (s2idle fallback when deep
sleep is refused for retained PCIe-C, J413 fw27 deep by default) and
#3540 (thunderbolt: apple: lost-link recheck).

Conflicts:
- drivers/pci/controller/pcie-apple.c: both sides split the checks out of
  apple_pcie_tunnel_remove_orderly(). Main's helper,
  apple_pcie_tunnel_can_remove_orderly() and remove_orderly() are taken
  as they are. This branch's apple_pcie_tunnel_kept() and
  apple_pcie_tunnel_removable() stay for now; the next commit drops them.
- tools/asahi/run-host-tests.py: both test entries kept.

kernel/power/suspend.c merged without a conflict: the platform veto in
pm_suspend() runs before enter_state(), and main's fallback in
enter_state() still covers a deep sleep refused at PM_SUSPEND_PREPARE.

Signed-off-by: DjDeveloperr <hey@djdev.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants