Re: [PATCH 1/2] thunderbolt: add opt-in to preserve tunnels across s2idle

From: Tobias Heath

Date: Wed Nov 25 2026 - 09:27:11 EST


Hello,

Many thanks for your reply.


On this hardware the dock-side host router is pinned in D0 by active USB4 tunnels and has not runtime-suspended since boot (active_time=515s, suspended_time=0). The quiet host router does go to D3cold exactly as the spec describes. The s2idle_preserve=1 path keeps the state that runtime-PM would have kept anyway — it prevents the system-suspend path from forcing a D3cold transition that tears down tunnels users still have open. Would you be open to a v2 that scopes to 'suspend target is s2idle AND domain has active tunnels' rather than a global module parameter?


On 25/11/2026 13:22, Mika Westerberg wrote:
Hi,

On Wed, Nov 25, 2026 at 12:45:36PM +0000, Tobias Heath wrote:
The current implementation of tb_switch_suspend() / tb_switch_resume()
writes ROUTER_CS_5 SLP into each USB4 switch on entry to s2idle and
rebuilds the tunnel on resume, independently of whether the host router
and connected switches actually need that teardown.
Well after router sleep is set and acked and the implementation specific
method is run (typically ACPI power resource is turned off) the routers
reset their config spaces to default except certain fields that are
mentioned in the spec.

On AMD USB4 host
controllers (verified on Ryzen AI 9 HX 370; same expected on Phoenix /
Strix generation hardware), the switch config survives D3hot intact,
and the mandatory rebuild produces an entirely avoidable re-enumeration
cascade on wake:
It is expected to go into D3cold and at that point you lose everything.

* Every downstream USB device goes through USB disconnect + fresh add,
device numbers increment, open file descriptors onto those devices
are invalidated (audio streams interrupted, filesystem mounts
unmounted-and-remounted by udisks, etc.).
* PCIe hot-plug fires for the dock-side bridges.
* The dock's PD controller is reset, producing a 1 - 2 s
ADP1 ONLINE=0 blip that interferes with any userspace relying on
AC state at wake time (for instance systemd's HibernateOnACPower=
policy).
* resume_devices takes ~2 - 5 s of avoidable work.

Add a module parameter, thunderbolt.s2idle_preserve (default: off), which
skips both the tb_switch_suspend() teardown on suspend_noirq and the
tb_switch_resume() + tb_tunnel_activate() rebuild on resume_noirq, when
the sleep target is PM_SUSPEND_TO_IDLE. S3 and hibernate paths are
unaffected.
Adding new module parameters should be avoided.

Measured on GPD Win Max 2 with CalDigit TS5 Plus dock:

Default upstream: resume_devices = 2.6 s; USB storm per wake; AC blip.
s2idle_preserve=1: resume_devices = 0.2 s; zero re-enumeration events;
AC stable; downstream connections (audio, storage,
keyboard) survive unchanged.

The opt-in gate is deliberate. Where the TB tree is not preserved by
hardware across s2idle (e.g. some Intel generations under specific
firmware configurations), enabling this would leave the kernel with
stale state at wake; users are expected to test on their own hardware
before enabling.
That's actually everything except your system according to the USB4 spec at
least and I would also assume AMD follows that too. Why it does not enter
D3cold is not clear at this point. Do you disable it via sysfs?

There is also the power problem if you keep them alive.

What we can do is to avoid the unnecessary runtime resume if the domain is
already runtime suspended when entering s2idle but that's USB stack that
does the wake up.