Repository navigation
thunderbolt: tb: stop waiting for a CIO peer that is gone - #3959
Draft
themartiano wants to merge 1 commit into
Draft
themartiano wants to merge 1 commit into
themartiano wants to merge 1 commit into
Conversation
After a native CIO deep sleep the wake waits up to 30 rounds for each link that had a peer, inside the noirq phase of the system's resume. A peer that was unplugged during the sleep costs all of them: 34 s with a Thunderbolt display pulled from a J713 (measured on an older tree), with every later resume waiting. Only hosts with QUIRK_CIO_WAKE_GIVES_UP wait for two rounds, which outlast a cold start's training. That quirk also bounds the wait for a link that still trains and tolerates a router state that is not taken back, neither of which is wanted here. The lane adapter tells the two cases apart. A peer that is there trains, and keeps its 30 rounds. An adapter that reads unplugged at the end of two rounds in a row has no peer: the port is lost as before, after a little over 2 s. Hosts with the quirk are not affected. Of the others, only the J713 sleeps with a router in place. Signed-off-by: Eduardo <git@martiano.me>
This was referenced Dec 2, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: After a native CIO deep sleep the wake waits up to 30 rounds for each link that had a peer, inside the noirq phase of the system's resume. A peer that was unplugged during the sleep costs all 30: 34 s with a Thunderbolt display pulled from a J713 (older tree). Now the lane adapter decides. An adapter that reads unplugged at the end of two
tb_wait_for_port()rounds in a row has no peer, and the wait for it ends after a little over 2 s. A peer whose link trains keeps its 30 rounds. Hosts withQUIRK_CIO_WAKE_GIVES_UPare unchanged.Tested: Host side at the head, on main 30c1870.
tools/asahi/tb-cio-sleep-tests.py: 47 cases, 32 negative controls pass (main: 42 and 29). The new cases fail against main'stb-cio-sleep.c(link_waits == gone[n].waits).run-host-tests.py --only cio5/5, the same as main. arm64 W=1 LLVM 20 build ofdrivers/thunderbolt/: the same 208 kernel-doc warnings as main, none intb-cio-sleep.c(it is built as part oftb.o). checkpatch --strict: clean. No KUnit suite covers these paths (apple-kunit.py planpicks none). Hardware, measured on an older tree, not at this head: 34 s lost to a display pulled from a J713 during a deep sleep; good docked wakes had the link back within about 0.5 s. This commit is in our7.3.0 next4test kernel (main ba12094 plus this and other open branches; the files it touches are the same on today's main). A row at this head is not yet run.Risk: two-way · J713, the only host on main that sleeps with the router in place without
QUIRK_CIO_WAKE_GIVES_UP. A dock that shows nothing on the lane for 2 s after the wake is now retired as unplugged instead of waited for, and rescanned at complete. Whether its PCIe comes back without a replug in that case is not known.Other Macs:
tb-cio-sleep.cruns only whereapple_nhi_cio_bind()sets up a sleep in place: the J713 (T8132) and the J714s and J716c (T6050). The T6050 hosts setQUIRK_CIO_WAKE_GIVES_UP, so they already wait two rounds at most, and the new early end at two unplugged rounds changes nothing for them. T6020's deep sleep (#3569) powers the port off instead and does not reach this wait. Other Macs and the J715 do not run it. So only the J713 changes, and it only gets shorter in the unplugged case.Not yet: J713 rows at this head: a display pulled during a deep sleep (expect
link after wake: 0after about 2.1 s, and the resume about 30 s shorter); 10 docked sleeps with the link back each time; 5 with a slow self-powered dock, and one with the dock switched off and on during the sleep.Details
QUIRK_CIO_WAKE_GIVES_UPis set by chip, and it also tolerates a router state that is not taken back and cuts a link that still trains. Neither is wanted on the J713.DISABLEDadapter keeps the 30 rounds.tb-cio-sleep.c; each applies alone to main, and the two merge without conflict.Evidence
python3 tools/asahi/tb-cio-sleep-tests.py:PASS 47 native tunnel replay cases,PASS 32 negative controls(main: 42 and 29).drivers/thunderbolt/tb-cio-sleep.ctaken from main and only the real variant run: fails,Assertion 'link_waits == gone[n].waits' failed.tools/asahi/run-host-tests.py --only cio: 5/5 (atc-cio-sleep,cio-native,dart-cio-owner,dart-cio-powerand this one), main 5/5.make O=<dir> LLVM=/usr/lib/llvm20/bin/ ARCH=arm64 olddefconfigfrom our J713 test kernel's config (7.3.0-0.next3), thenW=1 drivers/thunderbolt/(clang 20.1.8). 208 warnings, all kernel-doc inapple.cand other files this does not touch; the list is identical to main's.scripts/checkpatch.pl --strict -g main..HEAD: 0 errors, 0 warnings, 0 checks.scripts/ci/apple-kunit.py plan: no suite for these files.git merge-treewith the othertb-cio-sleep.cbranch (a router that leaves during the wake): no conflict.