Skip to content

thunderbolt: Apple native CIO deep sleep with a host-to-host peer or no PCIe tunnel (M4 MacBook Air) - #2692

Merged
RyanTheTide merged 6 commits into
integration/aurorafrom
j713-s2r/cio-xdomain-sleep
Nov 21, 2026
Merged

RyanTheTide merged 6 commits into
integration/aurorafrom
j713-s2r/cio-xdomain-sleep

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown

Problem

The M4 MacBook Air's (J713) native CIO deep sleep was written for a dock with a PCIe tunnel. With anything else on a USB4 port, it refused every deep sleep at prepare:

  • a host-to-host cable to another Mac (an XDomain peer): tb_cio_check_topology() -EOPNOTSUPP;
  • a partner with no PCIe tunnel behind the router: apple_nhi_cio_prepare() -ENODEV.

Change

  • thunderbolt: apple: the native CIO sleep runs with no PCIe tunnel. Prepare, suspend, wake and complete skip the tunnel's steps. The T6050 sleep has only run with a dock's tunnel and still refuses without one.
  • thunderbolt: an XDomain peer is released for the sleep the way an unplug releases it, after the T6050 no-tunnel refusal:
  • (A lanes-down commit was tried and is reverted at the head: deep sleep works with the peer's link left up, 3/3.)

Testing

Review fixes

  • c46c72b: host tests cover XDomain peers and no PCIe tunnel; comments state the peer is not re-found after a wake.
  • afd6d5b: T6050 without a tunnel refuses before any release; a refusal after the release rescans (tb_cio_sleep_refused()); the release looks at lane adapters only.

Still to run

  • The peer is not found again after the first wake. It returns after a reboot, so the link is not lost for good; the lanes come back without error.
  • A dock with a PCIe tunnel (regression check for the docked case this path was written for).

Assisted-by: LLM (Claude:Opus 5.5)

…tunnel

A deep sleep with a USB4 partner that has no PCIe tunnel behind the
router, such as a host-to-host cable to another Mac or a device that
tunnels only USB or DisplayPort, was refused at prepare: the native CIO
sleep found no PCIe-C tunnel to stop and returned -ENODEV, so the M4
MacBook Air could not sleep with such a cable in.

There is then nothing behind the router to stop: prepare, suspend,
wake and complete skip the tunnel's steps, and the router, the NHI's
DART, the controller and the PHY sleep as with a dock. The T6050 sleep
has only run with a dock's tunnel and still refuses without one.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The native CIO sleep keeps the tunnels and routers behind the host
router across its power cycle, and refused any topology with an XDomain
peer: a host-to-host cable to another Mac kept the M4 MacBook Air out of
deep sleep. The host at the other end owns its half of the link, which
the power cycle cannot keep.

Release the peer as an unplug does, once nothing in the connection
manager can refuse the sleep any more: find it by its adapter's
downstream route (the adapter's xdomain pointer was not always set when
the sleep was prepared), stop it, and unregister it and its services
once the domain lock is dropped, as the hotplug handler does, so that
thunderbolt_net gives back its rings before the host's are checked. The
rescan after the wake, or after a later refusal, finds it again.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…O sleep

The host router's own sleep has only run with a router below it. With
a host-to-host peer the lane link to another host stays up across the
release; take the root lane adapters down as an unplug would, so the
router sleeps with no link, and enable them again when the sleep
completes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…ative CIO sleep"

Not needed: on the M4 MacBook Air the router sleeps and comes back with a
host-to-host peer's lane link left up (3/3 deep sleeps without it, after
10/10 with it), and the lanes stayed off through the firmware's lane
init at the wake for nothing. This reverts commit e1ce37e.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide marked this pull request as ready for review November 21, 2026 18:14
@RyanTheTide

Copy link
Copy Markdown
Author

Ready for review. It is what the J713 deep sleep needs whenever the USB4 tether, or any XDomain peer, is attached. The tip candidate t3 (integration tip plus the J713 PR heads, but not this PR) cleanly refused all three deep sleeps at NHI prepare with -95, and this series is the fix for that refusal. It has also run inside the lab kernel for #2721: 3/3 deep sleeps with the peer attached and an external monitor, each with "xdomain released for the sleep" and the CIO router asleep and back.

Peer return after a wake, from the logs on both ends: when the J713 sleeps, the J616s sees the link drop. Its apple_cio_link_lost_work restarts its own port once (1/3) while the J713 is still asleep, and is not re-armed after that. After the wake, both CIO firmwares sit in lane-init phase 3, and their sideband AT-register reads time out (367 on the J713). The link comes back only on a replug or a reboot. That is a recovery-policy follow-up on the ports. It does not affect the sleep itself or this series, so it is no longer blocking here.

@RyanTheTide

Copy link
Copy Markdown
Author

Blockers: 2.

  1. Host tests are red at 08dace1 (run 44907458017). cio-native-tests has a fixture replacement that no longer matches (ignore-lost-pci), and the tb-cio-sleep-tests harness doesn't stub struct tb_xdomain, tb_xdomain_find_by_route, tb_xdomain_remove, __tb_disconnect_xdomain_paths, tb_xdomain_put, tb_port_unconfigure_xdomain or tb_domain_unregister_unplugged_xdomains. These need to be green, and they should cover the new paths: one XDomain under the root switch released once; one behind a device router (the recursion); a refusal before the release leaving the peer untouched; and prepare/suspend/complete with cio_pcie == NULL.

  2. The code says the peer comes back, but the row shows it doesn't. tb_cio_release_xdomains() says "The wake's rescan finds it again", and the sleep_prepare comment says the same for a later refusal. The body's Still-to-run says the peer is not found after the first wake and only returns after a reboot. Nothing in this series makes a rescan happen. The router's power cycle brings the lanes back without a plug event, so the connection manager never looks at the port again. As it stands, a host-to-host Thunderbolt link (thunderbolt_net, or a target-disk peer) is gone for good after the first deep sleep, where before it kept the link and refused the sleep. Two ways out:

    • (a) At complete, rescan each downstream port that came back with its link up and no remote/xdomain. This is the same discovery a plug event would trigger.
    • (b) Keep this series as is, but make the comments and commit message state the limitation, and track the re-find as an issue linked from the PR. Today the comments claim the opposite of what was measured.

    (a) is the production fix. (b) is acceptable only as a joint call, since today the alternative is no deep sleep at all with a peer attached.

Smaller:

  • if (!pcie && anhi->cio_t6050) extends the T6050 flag to a new decision. It is fail-closed, keeping T6050's refusal where its sleep has never run without a tunnel, so I'm fine with it. Please keep the reason in the commit message (it is in the code comment).
  • The history carries e1ce37e and its revert 08dace1. They net to nothing, but whoever bisects or merges sees both. Squash-merging, or a fresh branch without the pair, would be cleaner. No force push is needed for either.

Checked and fine:

  • The release order matches the XDomain unplug path in tb.c: is_unplugged, remove, clear port->xdomain, __tb_disconnect_xdomain_paths(-1...), put, tb_port_unconfigure_xdomain. It runs under tb->lock. Services are unregistered after the unlock, which matches the unplug path's lock order.
  • The release runs after the last refusal in prepare, so a refused prepare doesn't drop the peer.
  • Every cio_pcie use in prepare, suspend, wake and complete is NULL-guarded, and the pci_lost path is guarded on both the T6050 and non-T6050 sides.
  • The rows cover 10/10 deep with the peer (row I) and 3/3 with the peer plus an external monitor (with drm/apple: dcp: stop a T8132 firmware-27.2 external DCP for a deep sleep #2721).

Still to run: the docked case with a PCIe tunnel, as the body says.

… in the host tests

The host models had not followed the two changes before this one:

- cio-native-tests: a partner with no PCIe tunnel no longer refuses the
  prepare. It now runs a full sleep and wake with nothing behind the
  router, and a prepare followed only by complete. The lost-tunnel
  mutation follows the NULL check.
- tb-cio-sleep-tests: models the bus's XDomain calls, and covers:
  - a peer on the root router, released once, with its services
    unregistered outside the domain lock;
  - a peer behind a device router (the recursion), and both at once;
  - a refusal before the release, which leaves the peer untouched;
  - a tunnel's refusal after it, where the release stands.
  Four new negative controls check that the peer is marked unplugged,
  unregistered, found behind the device router, and cleared from its
  port.

The comments said the wake's rescan finds the peer again. Hardware
shows otherwise. After a J713 deep sleep its link to a J616s does not
train back, and both routers stay in lane init until a replug or a
reboot, so the peer is not found again. Say so.

The T6050 sleep still refuses without a PCIe tunnel because it has only
ever run with a dock's tunnel. That is kept fail-closed as before.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Both blockers are addressed at c46c72b (one commit on top, no force push).

  1. The host tests pass locally on this head:
    • cio-native-tests: 32 cases and 15 negative controls. The new cases are a full sleep and wake with no PCIe tunnel (cio_pcie == NULL) and a prepare followed only by complete. The lost-tunnel mutation now follows the NULL check.
    • tb-cio-sleep-tests: 37 cases and 24 negative controls. It now models the bus's XDomain calls and covers a peer on the root router released once, with its services unregistered outside the lock; a peer behind a device router (the recursion); both at once; a refusal before the release that leaves the peer untouched; and a tunnel refusal after the release, where the release stands. Four new mutations check the unplugged mark, the unregister, the device-router recursion and the port's xdomain clear.
  2. I went with option (b), with data behind it. The comments now say what the rows measured: the peer is not found again. I also found why a rescan alone (option a) would not bring it back. The lanes never train: after the wake, both routers sit in lane-init phase 3 with sideband AT timeouts (367 on the J713) until a replug. The details from both ends and the two candidate fixes are in thunderbolt: native CIO sleep: XDomain peer not found again after a J713 deep sleep (link stays in lane init) #2726. The sleeping-host port cycle is being tested as a lab knob first.

The reason for keeping T6050 fail-closed without a tunnel is now in c46c72b's commit message. Squash-merging drops the e1ce37e / revert pair from the history.

@RyanTheTide

Copy link
Copy Markdown
Author

Re-review at c46c72b: no blockers left.

  1. Host tests are green here too. cio-native-tests: 32 cases + 15 negative controls. tb-cio-sleep-tests: 37 cases + 24 controls. The new cases cover:
    • a peer released under the root switch;
    • a second peer;
    • both together;
    • a refusal before the release, which leaves the peer, its port and its refs untouched;
    • a tunnel prepare that fails after the release, where the release stands;
    • prepare/suspend/complete with no PCIe tunnel.
  2. The comments now say what the row shows: the peer is not found again after a wake and comes back only with a replug or reboot. That is tracked in thunderbolt: native CIO sleep: XDomain peer not found again after a J713 deep sleep (link stays in lane init) #2726. With that documented, the trade-off against "no deep sleep at all while a peer is attached" is a reasonable call for this PR, and the rescan belongs in the issue.

One thing to keep in mind for #2726: the new prepare comment says a tunnel prepare that fails after the release also leaves the peers released. So a dock plus a host-to-host peer can lose the peer on a refused sleep too, not only after a successful one. That is rare (it needs both a dock tunnel and an XDomain peer) and is now documented and tested, so it's not a blocker.

Still to run, as the body says: the docked case with a PCIe tunnel.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review at head c46c72bfbc16da25a79e5edcd24a55b5afa923cf.

Blocker

  1. T6050 regression: apple_nhi_cio_prepare() destroys live XDomain peers before refusing -ENODEV when no PCIe tunnel is present (drivers/thunderbolt/apple-cio-sleep.c:504-533).
    • On T6050 (anhi->cio_t6050 == true, J714s / J716c), apple_nhi_cio_prepare() calls tb_cio_sleep_prepare(anhi->tb) at line 504 before checking if (!pcie && anhi->cio_t6050) at line 530.
    • Previously, with a host-to-host USB4 cable (XDomain peer, no PCIe tunnel), tb_cio_check_topology() returned -EOPNOTSUPP before mutating state, leaving the peer and thunderbolt_net intact.
    • With this PR, tb_cio_check_topology() skips port->xdomain, so tb_cio_sleep_prepare() runs tb_cio_release_xdomains() (marking xd->is_unplugged = true, calling tb_xdomain_remove(), clearing port->xdomain, disconnecting DMA paths, calling tb_port_unconfigure_xdomain()) and then tb_domain_unregister_unplugged_xdomains() (unbinding thunderbolt_net and unregistering the XDomain device).
    • apple_nhi_cio_prepare() then hits if (!pcie && anhi->cio_t6050) at line 530, calls tb_cio_sleep_complete() (which does not rescan XDomains), and returns -ENODEV from .prepare(). Because .prepare() failed, the PM core aborts suspend and never calls .complete() (apple_nhi_complete() -> tb_domain_complete() -> tb_complete() -> tb_scan_switch()), leaving tcm->resume_cleanup_pending stale and the live XDomain / thunderbolt_net link permanently torn down even though the machine never slept.
    • Fix: apple_nhi_prepare() already sets acio->pcie_pm_prepared = true before calling apple_nhi_cio_prepare() (freezing pcie_tunnel_work), and acio->native_sleep is set at line 501. Look up pcie and enforce if (!pcie && anhi->cio_t6050) { ret = -ENODEV; goto release_cable; } before calling tb_cio_sleep_prepare(anhi->tb) (and cover the T6050 no-PCIe refusal order in tools/asahi/cio-native-tests.c so tb_cio_sleep_prepare() is asserted not to run).
    • (Note: the same unrecovered peer teardown also happens on J713 if a later prepare step fails — e.g., PHY, DART, or apple_pcie_tunnel_cio_prepare() with both a dock and an XDomain peer. Checking fail-fast prerequisites before tb_cio_sleep_prepare() reduces that window as well.)

Non-blocking notes

  1. Non-null ports & lookup comment in tb_cio_release_xdomains() (drivers/thunderbolt/tb-cio-sleep.c:40-54):
    • Adding if (!tb_port_is_null(port)) continue; avoids computing tb_downstream_route(port) and walking the full router tree via tb_xdomain_find_by_route() for every protocol adapter (NHI, PCIe, USB3, DP IN/OUT).
    • tb_xdomain_find_by_route() (switch_find_xdomain() in drivers/thunderbolt/xdomain.c) only walks port->xdomain pointers in the switch tree rather than searching tb_bus_type, so the comment "the bus holds it wherever the port keeps it" is inaccurate; using port->xdomain directly with tb_xdomain_get() (matching tb_handle_hotplug()) is simpler and avoids the O(P²) walk.
  2. Hardware evidence & regression check:
    • Host tests CI (host-tests) is green at c46c72bf.
    • Once the T6050 refusal-order blocker is fixed, please post a fresh J713 hardware row on the new head SHA (and the docked PCIe-tunnel regression check still listed under ## Still to run).
  3. PR body / commit hygiene:
    • The PR body's ## Change section still states "the rescan after the wake, or after a later refusal, finds it again", which conflicts with ## Still to run, #2726, and the updated comments in c46c72bf.
    • Squash-merging will also drop the e1ce37e0 / 08dace13 commit+revert pair cleanly.

Checklist verification

  • Model/board/firmware gating: Pass — no new of_machine_is_compatible() or board/firmware gates added; anhi->cio_t6050 fail-closed rationale is documented in code and commit messages.
  • Default cmdline / no hacks / safety / clean-room: Pass.
  • Attribution: Pass — all 5 commits have human author/committer and Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> only (no Co-Authored-By or agent trailers); PR body ends with Assisted-by: LLM (Claude:Opus 5.5).
  • CI: Green (Host tests/host-tests: SUCCESS).

Assisted-by: LLM (Google:Gemini 4 Neon)

…d them again after a refusal

Review found that a prepare refusal could leave a host-to-host peer
torn down when the machine never slept. The CM releases XDomain peers
(services unbound, paths down) in tb_cio_sleep_prepare(). Two prepare
paths then refused afterwards:

- T6050 without a PCIe tunnel refused only after that release. A
  J714s with a host-to-host cable lost its thunderbolt_net link on
  every refused deep sleep.
- Any later refusal (rings still held, PHY, DART, the PCIe port's
  prepare) left the released peers gone. The PM core calls no complete
  for a device whose prepare failed, so tb_complete()'s rescan never
  ran.

Fixes:

- Find the PCIe tunnel and take the T6050 refusal before the CM closes,
  so nothing is released. pcie_pm_prepared already holds the tunnel
  until complete. The reference is now kept from the lookup and put on
  every error path.
- Add tb_cio_sleep_refused(). It completes the transaction, clears the
  pending resume cleanup, unregisters the released peers outside the
  lock, and rescans the root router; their links are still up, so the
  rescan finds them again. It does not rescan while the CM is stopping
  or before hotplug is active. The NHI's refusal paths after the CM
  prepare use it.
- The release now looks only at lane adapters, and its comment says why
  it looks the peer up by route.

Host tests:
- cio-native: T6050 without a tunnel refuses with nothing prepared and
  no CM call. Every refusal after the CM's prepare goes through the
  refused path, none before it. Two new negative controls.
- tb-cio-sleep: the refused path after a prepare, after the CM's own
  refusal, and before any release (an ordinary rescan); and no rescan
  while stopping. Three new negative controls.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Thanks. The blocker and both notes are addressed at afd6d5b, one commit on top with no force push.

  • T6050 order: apple_nhi_cio_prepare() now looks up the PCIe tunnel and applies the T6050 no-tunnel refusal before tb_cio_sleep_prepare(). A J714s with a host-to-host cable therefore refuses with nothing released. pcie_pm_prepared holds the tunnel until complete. The reference is kept from the lookup and put on every error path.

  • Your J713 note (a later refusal after the release): there is a new tb_cio_sleep_refused(), which every NHI refusal path after the CM prepare uses. Since no complete follows a failed prepare, it does what tb_complete() would do:

    • complete the transaction;
    • clear resume_cleanup_pending via tb_resume_cleanup();
    • unregister the released peers outside the lock;
    • rescan the root router. The peers' links are still up because nothing slept, so the rescan finds them again.

    It does not rescan while the CM is stopping or before hotplug is active.

  • Release loop: non-lane adapters are skipped. I kept the route lookup and its comment now says why: on the J713 the iterated adapter's own xdomain pointer was unset when the release first ran (that was the "found nothing" step during bring-up), and the route lookup found the peer.

  • PR body: the Change section no longer claims a re-find after the wake. It points at thunderbolt: native CIO sleep: XDomain peer not found again after a J713 deep sleep (link stays in lane init) #2726 and lists the review fixes.

Host tests pass locally:

  • cio-native: 33 cases and 17 negative controls. New: T6050 without a tunnel refuses with no CM call and nothing prepared; every refusal after the CM's prepare takes the refused path, and none before it.
  • tb-cio-sleep: 41 cases and 27 negative controls. New: the refused path after a prepare, after the CM's own refusal, before any release, and with the CM stopping.

tb.o and apple.o build with W=1 and no warnings, and checkpatch is clean.

Next is a fresh J713 hardware row on afd6d5b. It goes through the t5 candidate, and I'm asking for #2692 to be updated to this head there. The docked PCIe-tunnel check is still owed.

@RyanTheTide

Copy link
Copy Markdown
Author

J713 (M4 Air) hardware rows at head afd6d5b7, plus our side's adversarial re-review of the new commit.

Kernel: 7.3.0-bj713t5+ = the tip-built J713 default (t4) + this PR at afd6d5b (+ linux#2590, linux#2721 heads). ONE fleet command line, no parameters. Deep sleep = rtcwake -m mem -s 20 on the PMU RTC (short functional sleeps). The J616s USB4 host-to-host peer and the MSI USB-C monitor were attached throughout.

Real deep sleep: PASS (3/3). Every cycle logged 0:1: xdomain released for the sleep and CIO sleep with no PCIe tunnel behind the router, ran the router save/stop/restore, then physical sleep completed (boot object resumes 0->1->2->3). suspend_stats went to 6/0. After each wake the eDP panel and the 2560x1440 monitor were back, along with Wi-Fi and NVMe. 4K and 1080p encode were md5-stable before and after, the camera had 0 gaps, and there were 0 failed units/AVC/oops/DART faults. After a real deep the peer is not re-found, as #2726 documents.

Refusal ordering: host tests at afd6d5b pass here: cio-native 33 cases with 17 negative controls, tb-cio-sleep 41 with 27. The T6050 no-tunnel refusal now runs before tb_cio_sleep_prepare(). checkpatch is clean. No blocker from the code read.

Finding (should-fix or document): the refused-path recovery does not hold on hardware. A deep sleep refused by a later device (linux#2710 arm: dcpexts without apple,display-power, so dcp_platform_suspend returns -16) still releases the XDomain at the NHI's prepare. After the PM core's complete, the rescan does re-find the peer, 13.5 s later (thunderbolt 0-1: new host found). About 100 ms after that, both ends lose the link:

  • J713: retimer disconnected, host disconnected.
  • J616s: Port Group - entering Dead End state, then peer link lost with the cable attached, restarting the port (1/3).

Both ends then sit in lane-init timeouts until the J713 reboots. So the commit message's line "their links are still up, so the rescan finds them again" is only half true: the peer is found again, then lost. Before this PR, an aborted deep left the peer untouched, because the NHI refused first. Possible levers: release the peers as late as the CM allows (the NHI's suspend instead of prepare, which narrows the window to refusals after it), or find why re-discovery after a never-slept release drops the lane (the J713's adapter reconfigure versus the peer's state). Failing that, document it in #2726.

Evidence (our lab, untainted)
  • Real deep x3: P-fullrows.txt, P-journal-k-1e840264.txt (full boot), P-sleeplines.txt
  • Refused deep: R-row.txt, R-dmesg.txt (J713), R-j616s-peer-kernel.txt (J616s, 07:37:30-07:41:30)
  • Directory: traces/power/20261122-airs-promote2-t5 in the lab store, README with the full result.

Unrelated to this PR but seen on the same boot: the G16 GPU firmware crashes on the first deep wake (GPU stop at the commit ... (-110), then GPU firmware back in 691 us, then RTKit: co-processor has crashed, PC 0xfffffc0000052578). This PR only exposes it, because deep sleep now actually happens with the tether attached. Routed to the G16 lane (linux#2676).

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial re-review at head afd6d5b766f5b7b20f74826491b8d4e74633441a (interdiff from c46c72bf plus full PR diff).

Blocker from previous review — RESOLVED

  • T6050 refusal-order bug (drivers/thunderbolt/apple-cio-sleep.c:510-519): Fixed and tested. apple_nhi_cio_prepare() now looks up pcie = apple_cio_find_pcie_tunnel(acio) and enforces if (!pcie && anhi->cio_t6050) { ret = -ENODEV; goto release_cable; } before calling tb_cio_sleep_prepare(anhi->tb). apple_nhi_prepare() sets acio->pcie_pm_prepared = true beforehand, freezing pcie_tunnel_work/quiesce across prepare, and pcie refcounting is balanced across every error path (release_cm: puts pcie once) and normal completion (apple_nhi_cio_complete()). Covered by the new T6050 no-tunnel test case and negative controls (t6050-refuses-after-release, refused-without-rescan) in tools/asahi/cio-native-tests.{c,py}.
  • Prior non-blocking notes: Addressed (!tb_port_is_null(port) skip added in tb_cio_release_xdomains(), route-lookup comment updated, and PR body no longer claims post-wake peer re-discovery).

Assessment of hardware finding in #issuecomment-7068987112

  • Refused-sleep link drop on J713 (when a later device such as dcp_platform_suspend fails suspend after NHI prepare releases the XDomain peer, tb_complete() re-discovers the peer and both ends lose the link ~100 ms later until replug/reboot):
    • Bounded, non-blocking edge case: On T6050 (which refuses without a PCIe tunnel), afd6d5b7 now refuses before any XDomain release, so T6050 has zero regression. On J713, XDomain unregistration (tb_domain_unregister_unplugged_xdomains()) must happen in .prepare() before checking NHI rings (it cannot safely move into suspend_noirq() because unbinding thunderbolt_net calls device_unregister()). The post-reprobe Dead End / lane-init phase 3 stall is the same CIO host-to-host port-recovery class as #2726, and only triggers on an aborted sleep rather than normal deep sleep (which passes 3/3 on afd6d5b7 and 10/10 previously).
    • Follow-up: Please record this refused-sleep case in #2726 and soften the "finds it again" wording in the PR body (and comments when #2726 lands) so it reflects what hardware showed.

Non-blocking notes

  1. Docked PCIe-tunnel regression row: Still listed under ## Still to run and not yet reported on afd6d5b7. Code inspection of the moved apple_cio_find_pcie_tunnel() lookup and pcie_pm_prepared locking is clean and host tests cover both docked and no-tunnel paths, so not blocking approval, but please run the docked PCIe-tunnel check before/with promotion.
  2. Pre-release tb_cio_sleep_prepare() failure path: If tb_cio_sleep_prepare() fails before tb_cio_release_xdomains(), apple_nhi_cio_prepare() still jumps to release_cm: -> tb_cio_sleep_refused() -> tb_scan_switch(tb->root_switch), which runs tb_scan_port() (including tb_switch_alloc() / tb_retimer_scan()) even when no peer was released because tb_scan_port() only short-circuits on port->remote. Minor and bounded to an already-failed prepare.
  3. Merge hygiene: Recommend squash-merging to drop the e1ce37e0 / 08dace13 commit+revert pair from history.

Checklist verification

  • No model/board/firmware gating: Pass — fail-closed anhi->cio_t6050 rationale is documented in code and commit messages; no board/firmware-version gates.
  • Default cmdline / no hacks / safety / clean-room: Pass.
  • Attribution: Pass — all 6 commits have human author/committer and Signed-off-by: Ryan Murray <ryan@aurorasilicon.org> only (no Co-Authored-By or agent trailers); PR body ends with Assisted-by: LLM (Claude:Opus 5.5).
  • CI & Hardware Evidence: Host tests / host-tests is green at afd6d5b7 (run 44944726833); fresh J713 hardware row at afd6d5b7 passes 3/3 real deep sleeps on the default cmdline with 0 failed units, 0 AVC denials, and 0 oops/DART faults.

Assisted-by: LLM (Google:Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit a05c35c into integration/aurora Nov 21, 2026
1 check passed
@RyanTheTide

Copy link
Copy Markdown
Author

J713-S2R follow-up on the refused-later finding above, row Q (2026-11-22 08:13). This tested one lever, and it did not fix it.

Hypothesis. The release ran tb_port_unconfigure_xdomain(), clearing PORT_CS_19 PID on a live link while the J616s kept its end configured. The J616s logs nothing at the release; its link only drops when the J713's rescan re-finds it.

Test. Candidate 075f1eb keeps PID set on release (host tests 41 + 28 with a new control; not pushed). Lab kernel: this PR at afd6d5b + 075f1eb. The deep sleep is refused by a later device: a 27.2 dcpext without power words refuses at its suspend, as in your R arm.

Result: unchanged. Over two refused deep sleeps:

  • the J713 re-finds the J616s 13.5 s after the last one;
  • within ~100 ms its ACIO firmware logs a burst of high_speed_lane.c: Gen2/3 link error. lane=0, error=87, then retimer disconnected and host disconnected;
  • the J616s logs Port Group - entering Dead End state, then restarting the port (1/3), and both ends stay in lane init until a replug.

This is the same J713-to-J616s retrain failure as after a real deep sleep (#2726). So the drop is lane-level, in the firmware, and is not caused by the port's PID state.

Where that leaves this PR:

I'm documenting this in #2726 and leaving 075f1eb out. The levers still open:

Evidence: traces/power/20261121-j713-s2r/rowQ-x3/ (J713 journal, plus the J616s journal for 08:12:30-08:16:30).

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf

J775c (Mac Studio, M5 Max, T6050) row on integration/aurora cacf35543b4d, which includes this PR (#2692). The stack adds #2102, #1743, #2488, #2557 and #2498, with the stock J775c DTB. The USB4 port has a host-to-host Thunderbolt peer (another Mac), and J775c has only suspend-to-idle.

without #2664 with #2664
pm_test=platform ×3, peer NHI unbound SError at the ATC PHY's first CIO-shutdown read, ~2 s after resume 3/3, no SError
real rtcwake -m freeze -s 10 ×3, peer bound, default cmdline (+arm64.nomte) did not return from the first cycle 3/3; HDMI, end0 and PCIe back; 0 SELinux denials, 0 failed units

The failure without #2664 is the same one, with the same address, that we saw on a84637dca209 before this PR merged. It's the ATC PHY's USB domain being gated during suspend-to-idle (#2664), so we see no J775c regression from this PR. J775c has no deep sleep, so the PR's native CIO deep-sleep path isn't exercised here. One boot per row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants