Repository navigation
thunderbolt: tb: a router that leaves during the CIO wake is an unplug - #3960
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 sleep the router resume marks the routers that did not come back as unplugged, and their tunnels are skipped and retired later. A router that leaves a moment after that, while the tunnels are replayed, fails the replay instead: the wake fails and apple_nhi_cio_resume() panics. When a replay fails while the host router still answers, look for the routers behind it that no longer do, mark them as the router resume would have, and replay what is left. Host steps, a failure with every router answering and the suspend's own unwind fail as before. Found by reading the code. The window is short and was not hit on hardware. The host test covers it. 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 sleep the router resume marks the routers that did not come back as unplugged; their tunnels are skipped and retired later, as after a hot unplug. A router that leaves a moment later, while the tunnels are replayed, fails the replay instead: the wake fails and
apple_nhi_cio_resume()panics ("Apple CIO: resume failed"). Now, when a replay fails and the host router still answers, the routers behind it that no longer answer are marked unplugged as the router resume would have, and the replay starts over with the rest. A failure with every router answering, a host that does not answer, and the suspend's own unwind still fail as before.Tested: Host side at the head, on main 30c1870.
tools/asahi/tb-cio-sleep-tests.py: 48 cases, 33 negative controls pass (main: 42 and 29). The new cases fail against main'stb-cio-sleep.c(the wake fails:!tb_cio_wake(&tb, &pci_lost)).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. checkpatch --strict: clean. No KUnit suite covers these paths (apple-kunit.py planpicks none). Hardware: none. This was found by reading the code; the window was not hit on a Mac. 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, J714s, J716c, and only in an error path that panics today. If it is wrong, a wake that would have panicked carries on with routers marked unplugged.
Other Macs: The code runs only where
apple_nhi_cio_bind()sets up a sleep in place: the J713 (T8132) and the J714s and J716c (T6050). On those it changes only what happens after a tunnel replay fails, which today ends in a panic. Every other Mac, the J715 included, does not run it. It can help all three hosts the same way, if the window is ever hit.Not yet: any hardware evidence. The planned J713 check: a test kernel with a delay before the replay and a dock unplugged in it (expect
lost during the CIO wake, the resume completes, a replug works); 20 pulls aimed at the wake; no regression in 10 docked sleeps.Details
tb_sw_set_unplugged(). The replay starts over only if at least one was newly marked, so it ends: each retry needs one more router gone.tb_sw_set_unplugged()warns once.tb-cio-sleep.c: each applies alone to main, and the two merge without conflict. Same story as thunderbolt: tb: stop waiting for a CIO peer that is gone #3959 and iommu/apple-dart: cio: release the clock protection of every removed port DART #3962; best reviewed after them.Evidence
tb-cio-sleep.cPR.python3 tools/asahi/tb-cio-sleep-tests.py:PASS 48 native tunnel replay cases,PASS 33 negative controls(main: 42 and 29).drivers/thunderbolt/tb-cio-sleep.ctaken from main and only the real variant run: fails,Assertion '!tb_cio_wake(&tb, &pci_lost)' failed.tools/asahi/run-host-tests.py --only cio: 5/5, 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 in 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.