Repository navigation
thunderbolt: apple: release a sleeping XDomain peer at the adapter that holds it - #3211
Conversation
…s it Before a native CIO sleep, tb_cio_release_xdomains() looks a peer up by the downstream route of each lane adapter, because on the J713 the adapter iterated did not hold the peer while the lookup found it. It then cleared only the iterated adapter's pointer. In that case the adapter that does hold the peer keeps its pointer, which holds no reference, after the peer is unregistered outside the lock and freed. The next lookup, rescan or sleep walks through it. Find the adapter that holds the peer the same way the route lookup finds the peer, and release the peer there: clear that adapter's pointer before the reference taken for the release is dropped, and unconfigure that adapter. The host model gains the J713 case, a peer found by the route of an adapter that does not hold it, with two negative controls: clearing or unconfiguring the iterated adapter instead of the holder. Fixes: a05c35c ("thunderbolt: Apple native CIO deep sleep with a host-to-host peer or no PCIe tunnel (M4 MacBook Air) (#2692)") Signed-off-by: Dj <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Verdict at Blockers: none Checked
Evidence
|
|
J773g (M4 Mac mini) at How it was run: two guarded one-shots on the default cmdline, the same day on the same Mac. Both returned to the stock kernel afterwards, and the kits were removed from the Mac.
No USB4/Thunderbolt device is attached to this Mac, so this is a smoke check: no new kernel lines, PCIe and Wi-Fi unaffected, and one s2idle cycle survived. It doesn't exercise a dock.
The only extra err-level kernel lines on the candidate are the scaler module A/B's two job timeouts (#3217). They aren't TB/PCI lines. |
|
J714s (MacBook Pro 14" M5 Pro, T6050) row at
|
There was a problem hiding this comment.
Verdict: MERGE at 15b90391 (once cancelled CI checks are rerun green)
Blockers: none (code, host model tests, and two-generation no-regression rows are ready; rerun the 16 cancelled CI checks before merge).
Checked:
drivers/thunderbolt/tb-cio-sleep.c:13-71: verifiedtb_cio_xdomain_port()recursively locates the actualholderadapter holding the peer matchingroute, takes a reference viatb_xdomain_get(holder->xdomain), removes it, clearsholder->xdomain = NULLbeforetb_xdomain_put(xd), and callstb_port_unconfigure_xdomain(holder)rather than the iterated aliasport.tools/asahi/tb-cio-sleep-tests.{c,py}: verified alias-holder test case and mutations (clear-iterated-port,unconfigure-iterated-port,keep-xdomain-port) cover the exact J713 failure mode (42/42 cases, 29/29 negative controls).- Verified exact-head (
15b903917a94) no-regression rows on J773g (M4 mini, s2idle PASS) and J714s (M5 Pro, deep sleep PASS).
Evidence
- Diff reviewed at
15b90391(all 3 files, 168 lines). - CI at review time: 3 passed, 0 failed, 16 cancelled.
|
Merge-train status at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
What: Before a native CIO deep sleep, a host-to-host (XDomain) peer was found by the route of the lane adapter being walked, but only that adapter's pointer was cleared. When a different adapter held the peer (the J713 case the code describes), that adapter kept a pointer to the peer after it was unregistered and freed. The release now finds the adapter that holds the peer, clears it before the last reference goes, and unconfigures that adapter.
Tested: host model
tools/asahi/tb-cio-sleep-tests.pyat 15b9039: 42 cases pass, all 29 negative controls caught (2 new). Hardware rows still owed (below).Risk: two-way door · Macs that use the native CIO sleep: M4 (T8132: J713, J773g) and M5 Pro (T6050: J714s)
Not yet: hardware rows at this head on J714s (dock attached: attach and detach, displays, dock I/O, one deep sleep) and J773g (the same, plus a deep sleep with a host-to-host peer if one is cabled).
Details
tb_cio_xdomain_port()walks the router tree the same wayswitch_find_xdomain()does for a route lookup, through the adapters'xdomainpointers, and returns the adapter whose peer has the route. So the peers that get released are exactly the ones the old lookup found.tb_xdomain_remove(), clear the holder's pointer, tear down its paths, drop the reference, then unconfigure the holder. It is unregistered outside the lock as before.Evidence
Head
15b903917a94f24177940d37acad8fd03d658a7f, basemain40e5e29cc915.New negative controls:
clear-iterated-port(clear the walked adapter, as before this change) andunconfigure-iterated-port. Both fail the new J713 case, the first because the holder keeps its pointer and the peer is released a second time.KUnit
thunderboltsuite (arm64 QEMU, KASAN) with this branch merged with the other two USB4 branches,W=1: 78/78, no warnings in the changed files.