Repository navigation
thunderbolt: apple: opt-in port power-off for s2idle with CD321x restore - #92
Merged
4 commits merged intoOct 15, 2026
Merged
4 commits merged into
4 commits merged into
Conversation
Observe successful stock XDomain UUID/property exchanges and remote- router reads instead of issuing a second, sequence-sensitive UUID probe. Snapshot activity before resume and watch only cables with a pre-suspend peer. Fresh activity cancels the watchdog even while downstream enumeration continues. Keep resume_recovery disabled by default. Allow 90 seconds for peer resume, then confirm the absence of fresh discovery three times five seconds apart. Missing discovery suggests a stall but cannot prove a cached UP lane dead; qualification is required before enabling automatic recovery. Share a single cable-revalidation budget across all ACIO instances for the driver lifetime. Suspend and cable changes never refill it. A manual module reload starts a new lifetime and must not be used to refill the lab budget. Do not issue verification probes or a second revalidation after recovery. Try a recovery start only once. On failure, unwind children and power- domain links, clear the RTKit handle, latch the port down and return ESHUTDOWN. Stop CD321x's automatic retry cascade for a terminal provider shutdown. Make OFF idempotent when ACIO never started, so later teardown cannot dereference the absent RTKit instance. Put the PHY in safe mode and release the USB role on a terminal provider failure. Ordinary start retries are unchanged. Signed-off-by: Marcelo Alcantara <[email protected]>
…tion The j314s lab observed firmware lane-initialization timeouts with router sleep enabled, including the first system suspend after boot. The root lane registers remained UP, so the previous recovery detector missed the failure. Observation of stock rediscovery and forced recovery still need hardware qualification before changing the default on any SoC. Leave router_sleep disabled by default, including t6000 and t6001, while retaining explicit Y/N and runtime parameter writes for qualification. Replace the inaccurate claim that ACIO links remain trained across sleep. An explicit Y clears QUIRK_KEEP_TUNNELS along with QUIRK_NO_SYSTEM_SLEEP. tb_resume_noirq() then rediscovers, deactivates and reactivates tunnels instead of taking the retained-tunnel path. Dock and PCIe-storage suspend behaviour is unqualified; automatic router sleep remains deferred. Signed-off-by: Marcelo Alcantara <[email protected]>
A Thunderbolt provider that powers itself down for system sleep needs the current cable state reapplied afterwards. CD321x only rereads the cable when its own resume runs, on a link fault, or on a completed deferred activation. Link faults draw on a small per-connection budget, so a provider cannot rely on them for routine restores: once a session has used its budget, the request is refused and the port stays down. Add TYPEC_THUNDERBOLT_SWITCH_RESTORE and typec_thunderbolt_switch_notify_restore(). CD321x answers it with one bounded fresh read that is not charged to the fault budget, and drops its cached state so the provider's switch is called again even when the mode is unchanged. A port that is still prepared for sleep ignores the request, because its own resume revalidates it. Signed-off-by: Marcelo Alcantara <[email protected]>
…leep A connected ACIO port keeps its USB4 link trained through s2idle. On a t6000 MacBook Pro with a Thunderbolt peer attached this costs about 1.3 W of the 4.0 W sleep draw; with the port powered off for the sleep, sleep power drops to 2.7 W. Add an opt-in s2idle_teardown parameter. When set, each connected port without a PCIe tunnel is stopped from the PM_SUSPEND_PREPARE notifier, before tasks freeze, so the NHI and its children are removed while their workers can still run. Ports carrying PCIe tunnels are left alone: an endpoint driver may unregister a PM notifier on removal, which would deadlock inside the notifier chain, and storage must not disappear under running applications. The PCIe check and the closing of PCIe admission happen in one critical section, so no tunnel can appear in between. From teardown until devices resume, cable changes are only recorded. CD321x drops its cached state in prepare and reapplies the cable state after resume, once tasks have thawed; that call restarts the port with a fresh snapshot of the cable, and a start failure goes back to CD321x as an error. If no successful restart follows, as after a suspend that aborted before devices suspended, a worker sends CD321x a restore request for a fresh cable read: at once after an abort, otherwise after 10 s. The port is never started from the state recorded before sleep. Only a successful start settles the restart, since CD321x also sends OFF as an intermediate step of a reconnect; a restart still owed when the next suspend begins keeps cable changes recorded-only again. Apple Silicon only offers s2idle, so PM_SUSPEND_PREPARE implies it. Tunnels do not survive: the network interface and dock displays are removed and rediscovered after resume. The parameter defaults to N. Signed-off-by: Marcelo Alcantara <[email protected]>
54f78d6
|
Thanks @maralcbr, this is merged through #124 with your four commits unchanged and one review-fix commit on top. The fixes:
On the M1 Air with the Kensington dock, every parameter reads off, the dock's tunnel comes up and there are 0 regressions. CD321x KUnit is 35/35. Details are in #124. |
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.
Summary
A connected Thunderbolt/USB4 port keeps its link trained through s2idle. On a 14-inch M1 Pro with a peer attached, that costs about 1.3 W of the 4.0 W sleep draw. This series adds an opt-in way to power the port off for sleep, plus the CD321x support it needs. Every new behaviour defaults to off.
resume_recovery, default N). Recovers a port that the stock driver never rediscovers after resume, at most once per driver load.router_sleepstays N). Router sleep saves 1 W but lost the link on every wake in testing.TYPEC_THUNDERBOLT_SWITCH_RESTORErequest. CD321x answers it with one bounded fresh cable read that isn't charged to the link-fault budget. Includes a KUnit case.s2idle_teardown, default N). Connected ports without a PCIe tunnel are stopped before tasks freeze. The CD321x post-resume revalidation then restarts them with a fresh cable snapshot. A 10 s fallback sends the restore request instead of starting from state recorded before sleep.Measurements
j314s, M4 Mac attached over Thunderbolt, 5 V input power:
s2idle_teardown=Y.pm_test=freezer) and 5 of 5 back-to-back sleeps with a restart still pending, link back each time.Limits
@iconidentify @DjDeveloperr, could you review? The CD321x restore request in commit 3 is the part I'd most like eyes on.