Skip to content

phy: apple: atc-t6050: keep active combo PHY domains powered across s2idle - #2664

Merged
RyanTheTide merged 3 commits into
integration/aurorafrom
satchlj/t6050-combo-phy-s2idle-syscore-20261121
Nov 23, 2026
Merged

RyanTheTide merged 3 commits into
integration/aurorafrom
satchlj/t6050-combo-phy-s2idle-syscore-20261121

Conversation

@satchlj

@satchlj satchlj commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Problem

On T6050, t6050_dp_suspend_late() only quiesces the combo PHY for firmware deep sleep (pm_suspend_no_platform() == false). During s2idle, an active combo PHY remains running, and drivers/thunderbolt/apple.c holds ACIO's virtual genpd devices out of system suspend with dev_pm_syscore_device(..., true).

However, combo_pm_notify() in drivers/phy/apple/atc-t6050-combo.h was gated on combo_sleep_board() (j714s/j716c) and only held domain[0] during firmware deep sleep. During s2idle, genpd_suspend_noirq() powered off active combo PHY virtual genpd devices (including atc1_phymxwrap) under the still-running PHY RTKit CPU. On resume, the first CIO-to-SAFE transition timed out with apple-t6050-dp-phy 2ab000000.phy: PHY firmware stop failed: -62 and marked the PHY faulted (dp->faulted = true), permanently wedging the port (-5) until reboot.

Fix

  • Register combo_pm_notify() for all apple,t6050-combo-phy instances (not gated on combo_sleep_board()).
  • In PM_SUSPEND_PREPARE when pm_suspend_no_platform() is true (set in enter_state() before suspend_prepare() invokes notifiers, merged in T6050: a "freeze" with mem_sleep at deep is a suspend-to-idle (no dock teardown, no -67) #2510), hold every active dp->domain[] and dp->dp_gate[] virtual genpd device out of system suspend with dev_pm_syscore_device(..., true) and record the held devices in bitmasks (s2idle_domain_syscore, s2idle_gate_syscore).
  • In PM_POST_SUSPEND, release every device recorded in those bitmasks unconditionally (covering both normal resume and suspend abort via pm_notifier_call_chain_robust, independent of whether active changed in the meantime).
  • Hardware-state-driven only; works on the default kernel command line with no runtime switches or module parameters.

Hardware verification (J775c / Mac Studio M5 Max, T6050, ATC1 XDomain, s2idle)

Tested on cand-11 (8f345b748824) on the default command line (s2idle_teardown=N) across rtcwake -d rtc0 -m freeze:

  • Without this patch (Exp B): Post-resume CIO teardown failed with apple-t6050-dp-phy 2ab000000.phy: PHY firmware stop failed: -62 (dp->faulted = true), leaving the PHY wedged (-5) even after a USB-C PD replug succeeded.
  • With this patch (Exp D & Exp E, sole PHY delta vs Exp B):
    • pmgr-pwrstate dynamic debug confirmed zero atc1_phymxwrap or atc1_* power-off transitions across s2idle (only idle atc0/2/3_phymxwrap cycled).
    • In Exp E (boot 10ee7606-bb95-48ac-aae9-022620fed01f), post-resume set cable state: 0 cleanly received PHY firmware ep20: 8000010000000001 (zero -62), cycled atc1_phymxwrap 0x0 -> 0xf, and restarted 2ab000000.phy to CIO mode up: UC_TNBL_DONE (0), reverse orientation, 11 ms.
  • Compile check: drivers/phy/apple/atc-t6050-dp.o builds cleanly on integration/aurora 107047f61826.

(Note: This PR fixes the combo PHY s2idle domain power-off and -62 stop wedge. On the J775c↔macOS XDomain pair, 2a9ac0000.acio still hits Training TO HL0 -> Dead End ~2 s into s2idle separately; that link-drop cause is being isolated independently.)

Review follow-up at 6fb5e78 (now squashed into 02e964d1, same tree; the deferred-stop blocker fix is 56bc4ebc): the late snapshot and mutation fence now share the PHY mutex. Early resume releases the saved masks. Zero-rate requests during the fence are queued for stop after thaw, and a pending stop must complete before reuse. The deep-sleep board gate remains separate.

The 6fb5e78f revision (now 02e964d1, same tree; before the deferred-stop fix 56bc4ebc, so not the current head's tree) completed one RTC-backed XDomain s2idle cycle on a cand-11 J775c integration build with 1 success and 0 failures, no logged ATC1 PMGR power-off and no PHY stop -62. The HL0 timeout still dropped the link. An active DP tunnel, injected suspend abort and matched forced PHY restart were outside this run.

Assisted-by: LLM (Codex:GPT-6.2)

@RyanTheTide

Copy link
Copy Markdown
Contributor

The approach looks right: on s2idle, hold the active combo-PHY domains and DP tunnel gates out of genpd's system suspend, release exactly what was recorded at POST_SUSPEND (abort included), and select it all from what is active, with no switch. The J775c before/after, with no atc1_* power-off and no -62 stop failure, is a good row. Points:

  • PM_SUSPEND_PREPARE runs before tasks are frozen, and the loop reads dp->domain[i].active and dp->dp_gate[i].active without the PHY's lock. A tunnel or mode change that brings a domain up between this snapshot and genpd_suspend_noirq() would not be held, so the original fault could still happen in that window. A domain that goes down after it would just stay powered, which is harmless. Taking the same lock the PHY uses to change active, or re-checking from suspend_late/suspend_noirq where nothing can change any more, would close it.
  • s2idle_domain_syscore and s2idle_gate_syscore are u8 bitmasks indexed by ndomains and ATC_DP_TUNNELS. A BUILD_BUG_ON(ATC_DP_TUNNELS > 8) and a check of ndomains against the mask width at probe would catch a later PHY with more domains.
  • The deep-sleep branch still gates on combo_sleep_board() (J714s/J716c). Not this PR's job, but now that the s2idle path is keyed on hardware state, a note that the board gate is left for the deep-sleep pass would help.

Assisted-by: LLM (Claude:Opus 5.5)

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Codex GPT-6.2 Sol on @satchlj's behalf

The local revision moves the s2idle snapshot into the PHY's suspend_late callback under the PHY mutex and releases the recorded holds in resume_early, including the PM unwind after a successful late callback. It bounds both u8 masks and documents that the existing deep-sleep board gate is left for the deep-sleep work.

The local revision compiled and the cand-11 trial containing it booted. It returned to known-good Aura with direct Thunderbolt connectivity. That boot did not exercise s2idle, so it does not establish the late-to-noirq ordering under live tunnel activity or validate resume/abort release on hardware. The earlier domain-hold and PHY restart observations apply to the earlier implementation. The separate link-training drop remains open.

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Codex GPT-6.2 Sol on @satchlj's behalf

Updated to 6fb5e78f9b46. Late suspend snapshots active PHY domains and gates under the same mutex that fences mode and clock changes through noirq. Early resume releases the recorded masks on resume or unwind. Both masks are bounded. The firmware deep-sleep board gate is separate. A clock stop arriving under the fence is recorded and serviced after thaw, or before the clock is reused.

J775c cand-11 integration boot b2bfd495-b39c-48a4-9776-feda075092ba (Image SHA-256 f77cde6c7fdef4afdf9888c361314e401742b55c7228c53458b7dc49e2cef72b, DTB SHA-256 682476cf49f1f98852a8b2df9cb3d3cadf989b6d5cb4a21b0c9aba64d152d5c6) completed one RTC-backed XDomain s2idle cycle, 1 success / 0 failures. The journal showed late suspend and early resume in order, zero logged ATC1 power-offs and zero PHY stop -62. The separate Training TO HL0 event still took the peer link down. Active DP tunnel teardown, an injected suspend abort and a matched forced PHY restart remain untested on this revision. Warm return to default Aura passed.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of 6fb5e78: Blockers: 1.

Earlier points:

  • Snapshot race: resolved. The hold now runs from t6050_dp_suspend_late() (drivers/phy/apple/atc-t6050-dp.c:1224) under dp->lock in combo_s2idle_hold() (drivers/phy/apple/atc-t6050-combo.h:389), and s2idle_frozen fences mode, orientation, configure, CIO and tunnel-clock changes until t6050_dp_resume_early() (atc-t6050-dp.c:1240), which the PM core also runs on a late/noirq unwind.
  • Mask width: resolved (atc-t6050-dp.c:1141-1143).
  • Deep-sleep board gate: resolved, noted at atc-t6050-combo.h:775.

New in 6fb5e78:

  1. drivers/phy/apple/atc-t6050-dp.c:626 / :806-815: a stop deferred during the fence can outlive USB4 mode. atc_dp_tunnels_stop() (called by combo_stop(), atc-t6050-combo.h:151, and by apple_t6050_phy_cio_off()) zeroes tunnel_rate[] but leaves s2idle_clock_stops set. If the port leaves CIO before the deferred work runs, for example the cable came out during s2idle and the type-C resume work sets SAFE first (both run on system_freezable_wq after thaw, in no fixed order), atc_s2idle_clock_work() then calls atc_dp_tunnel_apply() -> atc_dp_tunnel_switch(). That writes the DP switch/enable registers in banks[39] after the mode's shutdown and polls for 10 ms, though the comment at :618-620 says the switches are written only in USB4 mode. A later apple_t6050_dp_tunnel_clock() on that clock goes through the same stale bit at :872-873. Fix: clear dp->s2idle_clock_stops in atc_dp_tunnels_stop(), which already parks and gates every clock, and skip the deferred stop in atc_s2idle_clock_stop() when dp->faulted or dp->combo_mode != COMBO_CIO.
  2. Nit, atc-t6050-dp.c:812: the deferred stop calls atc_dp_tunnel_apply() for the one clock. An immediate stop goes through atc_dp_tunnels_apply() (:777), which the comment at :747-752 says every change does. Use atc_dp_tunnels_apply(dp, i + 1, NULL) so a deferred stop follows the same path as an immediate one.

Commits have a human Signed-off-by and no agent trailers. The PR body ends with the Assisted-by line.

HW row: J775c on 6fb5e78 plus fix 1, default command line. Run 5 RTC s2idle cycles with an active DP tunnel through the XDomain/dock port, one cycle with the cable pulled while asleep, and one suspend abort injected after the PHY's late suspend. Pass: no PHY stop -62, no SError, no "Deferred DP tunnel clock" warning, the display comes back, and 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J714s (Apple M5 Pro / T6050) combined-stack s2idle + deep hardware row: PASS

  • Exact tested stack: base cc145705c592 + #2007 (36ef4f8b60cf, incl. #1743) + #2592 (a142752404ed) + #2557 (f90f377c8c5e) + #2664 (6fb5e78f9b46) + #2739 (075bd14d3dec, T6050 PCIe-C s2idle_hold_domain), rebuilt t6050-j714s.dtb (1fbcc4fe2c55, MTE enabled; no_console_suspend ignore_loglevel appended for serial capture; Dell Thunderbolt dock attached with active PCIe-C tunnel + USB3/DP).
  • s2idle (rtcwake -d rtc1 -m freeze -s 15): 3/3 PASS (asleep 14.5 s / 14.0 s / 14.6 s, rtc_delta=20 s each, macsmc-rtc IRQ 118 0 -> 1 -> 2 -> 3, pciec_ebusy=0, refusal=0, disp=3/3, usb=20, wifi=1, bt=1, nvme=1, aer=0, link_err=0, gpu_lost=0).
  • deep regression (rtcwake -d rtc0 -m mem -s 15): 1/1 PASS (asleep=13.1 s, rtc_delta=23 s, refusal=0, disp=3/3, usb=20, wifi=1, bt=1, nvme=1, aer=0, gpu_lost=0).
  • Regression line: suspend_stats success=0 -> 4, fail=0; GPU LIVE (vulkaninfo + compute dispatch) pre/post; 0 kernel oops/WARN, 0 DART faults, 0 SELinux AVCs, 0 new failed systemd units (only pre-existing offline tailscaled.service).
  • Scope note: Combined-stack J714s verification (not isolated from the other four s2idle PRs listed above).

Assisted-by: LLM (Gemini 4 Neon)

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf

J775c (Mac Studio, M5 Max) rows for #2664 at head 6fb5e78f.

Stack. integration/aurora a84637dca209 plus #2102, #1743, #2488, #2557 and #2498, plus this PR. The DTB was that stack's own J775c DTB (no apple,sleep-retained or apple,always-on on the ATC USB domains, i.e. without #2592). One boot per row.

Row Cmdline Result
pm_test=platform, direct-peer NHI unbound, 3 cycles diagnostic serial console 3/3 returned; no SError; no failed to place Type-C mux in safe mode lines; atc1_usb never offered to genpd (usage 0, rejected 0)
real rtcwake -m freeze -s 10 ×3, peer bound, HDMI attached installed default plus arm64.nomte (our trial helper's) 3/3 returned; HDMI connected and enabled after each; end0 up, 3/3 pings; PCIe noirq 0/0; 0 setmode failures, 0 SELinux denials, 0 failed units

Without this PR, the same stack and DTB:

  • took an asynchronous SError at the PHY's first core-bank read after the platform timer (bank 2 +0xc, right after resume, with the PMGR word reading atc1_usb on);
  • returned from 0 of 1 real RTC cycles.

With apple,sleep-retained instead (#2592) the SError went away, but the PHY's firmware stop then failed with -62, followed by repeated safe-mode -5. This PR removed both.

Limits.

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf

Current-tip J775c row for #2664 at 6fb5e78f. The stack is integration/aurora cacf35543b4d (which has #2692) plus #2102, #1743, #2488, #2557 and #2498, with the stock J775c DTB. One boot per row; the only difference between the two arms is this PR.

  • With this PR (Image 5a2b7d50):
    • pm_test=platform ×3 (diagnostic console cmdline, peer NHI unbound): 3/3 cycles, no SError, no mux safe-mode lines.
    • Real rtcwake -m freeze -s 10 ×3 (default cmdline plus our helper's arm64.nomte): 3/3 returned. HDMI was connected and enabled after each, end0 came back, PCIe noirq was 0/0, and there were 0 setmode failures, 0 SELinux denials and 0 failed units.
  • Without it (Image 8281ecb1): the platform arm took the SError at the first CIO-shutdown read (0x2ab000120), about 2 s after resume, as on the older base. thunderbolt: Apple native CIO deep sleep with a host-to-host peer or no PCIe tunnel (M4 MacBook Air) #2692 doesn't change this.

#2592 is closed in favour of this PR.

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf

Follow-up to the current-tip row above (#2664): the same Image (5a2b7d50: cacf35543b4d plus the J775c stack plus this PR, stock DTB) on the exact installed default command line. /proc/cmdline was rdinit=/init nr_cpus=18 maxcpus=18 root=UUID=…, without the arm64.nomte our trial helper normally adds. One boot.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at 6fb5e78: BLOCKERS.

Not merging until the blockers below are fixed or answered; the details give file:line and a failure case.

Full review

#2664 phy: apple: atc-t6050: keep active combo PHY domains powered across s2idle @6fb5e78f

VERDICT: BLOCKERS

The head is unchanged since Ryan's re-review of 6fb5e78. Its blocker 1 is still open, and I reproduced it from the code.

Blockers:

  1. drivers/phy/apple/atc-t6050-dp.c:622-635 and :806-835: a deferred clock stop can outlive USB4 mode and then write the tunnel-switch registers outside CIO.
    • While s2idle_frozen is set, a rate-0 request only sets s2idle_clock_stops and returns 0 (:865-870). dcp-fabric.c:477-479 then records route->tunnel_rate = 0.
    • atc_dp_tunnels_stop() (:622-635) zeroes tunnel_rate[] but does not clear s2idle_clock_stops. It runs from combo_stop() (atc-t6050-combo.h:151) on any mode change and from apple_t6050_phy_cio_off().
    • combo_s2idle_release() (combo.h:432-433) queues atc_s2idle_clock_work on system_freezable_wq. The cd321x mux work runs on the same freezable wq after thaw (tipd/core.c:1686), in no fixed order. If the cable came out while asleep and the mux work runs first, CIO is stopped to SAFE.
    • The deferred work then calls atc_s2idle_clock_stop() -> atc_dp_tunnel_apply(dp, k, NULL) with rate 0 -> atc_dp_tunnel_switch() (:521-546). That writes banks[39] DP_SWITCH/DP_ENABLE and polls for 10 ms after the mode's shutdown.
    • Before this PR, a rate-0 request on a clock already at rate 0 only dropped the gate (:762-766) and never touched the switch bank. The comment at :618-620 says the switches are written only in USB4 mode. A later rate request on that clock also takes the stale bit at :872-874 and does the same write.
    • With the mode's domains down, that MMIO is the same class of access as the SError this PR exists to fix.
    • Fix: clear s2idle_clock_stops in atc_dp_tunnels_stop(), and in atc_s2idle_clock_stop() skip the switch write when dp->faulted || dp->combo_mode != COMBO_CIO.

Nits:

  1. atc-t6050-dp.c:812: the deferred stop calls atc_dp_tunnel_apply() for one clock. An immediate stop goes through atc_dp_tunnels_apply() (:777), which the comment at :747-752 says every change uses. Use atc_dp_tunnels_apply(dp, i + 1, NULL) (same as Ryan's nit 2).

  2. Every guarded entry point now returns -EBUSY from suspend_late until resume_early:

    • the guarded entry points: set_mode, configure, orientation, mux, cio_prepare/off/on/usb;
    • consumers of those calls: tipd and DCP work on freezable workqueues (run after thaw), and the thunderbolt CIO hooks (gated on PM_SUSPEND_MEM, apple-cio-sleep.c:495);
    • not checked: whether a thunderbolt resume_noirq DP tunnel restart can reach dcp_route_clock_rate() with a non-zero rate before the PHY's resume_early. That would be a silent -EBUSY on the display path.

    A one-line dev_dbg when the fence refuses a call would make that visible.

  3. apple_t6050_phy_cio_finish() and apple_t6050_phy_cio_lost() are not fenced, though the other CIO calls are. They are deep-sleep only today, but the asymmetry is not commented.

  4. Commit 843c5f5 describes the PM_SUSPEND_PREPARE-notifier design that 6fb5e78 replaces. A bisect lands on a design the tree no longer has, so squash them or reword 843c5f5.

Hygiene: both commits have only Signed-off-by: Satya Benson, with no agent trailers. No new chip, board or firmware gates: combo_sleep_board() is pre-existing and documented as left for later (combo.h:775). No params, no delays.

Missing rows:

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adversarial review at 6fb5e78f9b46b3c69c6032303f17c07c2f25b81b: REQUEST_CHANGES (1 open code blocker reproduced from source; CI host-tests: pass; mergeable/clean).

Blockers

  1. Deferred DP tunnel clock stop can outlive USB4/CIO mode and write banks[39] MMIO after domains are powered off (drivers/phy/apple/atc-t6050-dp.c:622-634, :806-835, :864-876; drivers/phy/apple/atc-t6050-combo.h:431-434)
    • While dp->s2idle_frozen is set, a rate-0 call to apple_t6050_dp_tunnel_clock() sets dp->s2idle_clock_stops |= BIT(clock - 1) and returns 0 (atc-t6050-dp.c:865-870), causing dcp_route_clock_rate() (drivers/gpu/drm/apple/dcp-fabric.c:479-480) to set route->tunnel_rate = 0.
    • atc_dp_tunnels_stop() (atc-t6050-dp.c:622-634), invoked from combo_stop() (atc-t6050-combo.h:151) and apple_t6050_phy_cio_off() (atc-t6050-dp.c:1313), zeroes dp->tunnel_rate[] and drops the gates, but does not clear dp->s2idle_clock_stops.
    • On resume, combo_s2idle_release() (atc-t6050-combo.h:432-433) queues dp->s2idle_clock_work onto system_freezable_wq — the same workqueue used by tipd (drivers/usb/typec/tipd/core.c:1662, :2733), with no ordering guarantee. If the cable was unplugged while asleep and tipd's resume_work runs first, combo_mux(SAFE) -> combo_stop() tears down CIO to COMBO_SAFE and powers off the PHY domains.
    • atc_s2idle_clock_work() then runs atc_s2idle_clock_stop() -> atc_dp_tunnel_apply(dp, i + 1, NULL) -> atc_dp_tunnel_switch() (atc-t6050-dp.c:521-545), writing dp->banks[39] (ATC_CFG_DP_SWITCH / ATC_CFG_DP_ENABLE) and polling ATC_CFG_DP_STATUS for 10 ms outside COMBO_CIO with the PHY domains off — risking an asynchronous SError.
    • A subsequent apple_t6050_dp_tunnel_clock() call on that clock also hits the stale bit at atc-t6050-dp.c:872-875 and performs the same switch write.
    • Fix: Clear dp->s2idle_clock_stops = 0 in atc_dp_tunnels_stop(), and in atc_s2idle_clock_stop() skip banks[39] switch writes when dp->faulted || dp->combo_mode != COMBO_CIO (only releasing dp_gate[i] if still active, then clearing the bit).

Checklist audit (§1–§4, §6) & non-blocking nits

  • §1 / §2 / §3 / §4 / §6: Pass. No new chip/board/firmware gates (combo_sleep_board() is pre-existing and noted at atc-t6050-combo.h:775); default-cmdline safe; u8 bitmask widths are bounded at probe (atc-t6050-dp.c:1141-1143); both commits (843c5f5c, 6fb5e78f) carry human-only Signed-off-by: Satya Benson <satya@benson.earth> with no agent trailers; PR body ends with Assisted-by: LLM (Codex:GPT-6.2).
  • Nits:
    • atc-t6050-dp.c:812: atc_s2idle_clock_stop() calls single-clock atc_dp_tunnel_apply() instead of atc_dp_tunnels_apply(dp, i + 1, NULL), diverging from the comment at :751-752 and immediate stop at :777.
    • Adding a dev_dbg() when s2idle_frozen refuses a call with -EBUSY would make any unexpected late/noirq caller visible.
    • apple_t6050_phy_cio_finish() and apple_t6050_phy_cio_lost() are unfenced unlike the other CIO exports (deep-sleep only today; worth a brief comment).
    • Commit 843c5f5c describes the superseded PM_SUSPEND_PREPARE notifier design replaced by 6fb5e78f; squashing or rewording avoids a misleading bisect point.

§5 HW evidence needed after fixing the blocker

  • J775c (default cmdline, isolated PR on current tip with the fix):
    • 5 RTC s2idle cycles with an active DP tunnel through the XDomain/dock port;
    • 1 s2idle cycle with the cable pulled while asleep (exercises the s2idle_clock_work vs tipd SAFE ordering);
    • 1 suspend abort injected after t6050_dp_suspend_late().
    • Pass criteria: 0 PHY stop -62, 0 SError, 0 Deferred DP tunnel clock warnings, display recovery, and 0 SELinux denials / 0 failed units / 0 new kernel errors.
  • Additional T6050 combo-PHY board coverage (e.g. J716c or standalone J714s s2idle + deep regression; the existing J714s row is a combined stack with #2007/#2592/#2557/#2739).

Assisted-by: LLM (Gemini 4 Neon)

@satchlj

satchlj commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

@DjDeveloperr @RyanTheTide b0fb7aab (a new commit) addresses the blocker.

  • Blocker:
    • atc_dp_tunnels_stop() now clears s2idle_clock_stops, under dp->lock. Both callers, combo_stop() and apple_t6050_phy_cio_off(), hold it.
    • When a deferred stop in atc_s2idle_clock_stop() finds dp->faulted or combo_mode != COMBO_CIO, it releases only that clock's gate and writes no banks[39] switch.
    • This covers both the tipd SAFE ordering after a cable pull and the next call that hit the stale bit.
  • Nits:
    • The deferred stop now goes through atc_dp_tunnels_apply(), like the immediate stop.
    • A start refused while frozen now logs at dev_dbg.
    • Not done in this push: the comment on the unfenced cio_finish()/cio_lost(), and the stale 843c5f5c message. Squashing that one needs a force-push, and I'll ask before doing it.

Testing: drivers/phy/apple/atc-t6050-dp.o compiles with W=1 on aarch64 gcc and 0 warnings. This is the object only, with no modpost and no boot. None of the J775c rows you list (5 RTC s2idle cycles with a DP tunnel, a cable pull while asleep, an abort after suspend_late) have run. The J775c machine is unavailable right now.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Checked b0fb7aa. The first two commits are unchanged; only the new commit is added.

Earlier points:

  • The deferred stop outliving USB4 mode is fixed. atc_dp_tunnels_stop() now clears s2idle_clock_stops (drivers/phy/apple/atc-t6050-dp.c:628), and atc_s2idle_clock_stop() only drops the gate when the PHY is faulted or out of CIO (:819-820), so the banks[39] switch is not written after SAFE. The stale-bit path in apple_t6050_dp_tunnel_clock() (:885) goes through the same helper.
  • The deferred stop now uses atc_dp_tunnels_apply() (:822), as the immediate stop does.
  • The dev_dbg covers the refused clock start (:878), which was the display-path case.
  • Still open, both minor: a comment on why apple_t6050_phy_cio_finish()/apple_t6050_phy_cio_lost() are not fenced, and the 843c5f5 message, which still describes the PM_SUSPEND_PREPARE notifier. Squashing on merge fixes the second without a force-push to the branch.

I found nothing new in the delta.

Still needed before merge: the J775c rows at b0fb7aa on the default command line. Run 5 RTC s2idle cycles with an active DP tunnel through the XDomain/dock port, one cycle with the cable pulled while asleep, and one suspend abort injected after the PHY's suspend_late. Pass means no PHY stop -62, no SError, no "Deferred DP tunnel clock" warning, the display back after each cycle, 0 failed units and 0 new kernel errors. The rows posted so far are at 6fb5e78 over HDMI with no DP tunnel, so the deferred-stop path has not run on hardware yet.

Assisted-by: LLM (Claude:Opus 5.5)

…2idle

On T6050, t6050_dp_suspend_late() quiesces the combo PHY only for
firmware deep sleep. During suspend-to-idle an active combo PHY keeps
running, but genpd_suspend_noirq() still powered off its virtual genpd
devices (atc1_phymxwrap among them) under the running PHY CPU. On
resume, the first CIO-to-SAFE transition timed out with "PHY firmware
stop failed: -62" and marked the PHY faulted, wedging the port (-5)
until reboot.

In t6050_dp_suspend_late(), on a suspend without platform support
(pm_suspend_no_platform()), take a snapshot of the active domains and
DP tunnel gates under the PHY lock and hold each of them out of genpd's
system suspend with dev_pm_syscore_device(..., true), recording them in
bounded masks. t6050_dp_resume_early() releases exactly the recorded
holds, which also covers a suspend that unwinds after late suspend.

Between the two, mode, tunnel-clock and CIO changes are fenced
(s2idle_frozen), including from work that can still run after the
freezer. A zero-rate tunnel clock request during the fence records a
stop, so DCP can release the route; the stop runs after the thaw, or
before the clock is used again, and its pending state is cleared only
once the clock is parked and its gate released. The firmware deep-sleep
handling (combo_pm_notify(), on the boards combo_sleep_board() names)
is unchanged.

Signed-off-by: Satya Benson <satya@benson.earth>
A tunnel clock that DCP asks to stop while the PHY is frozen for s2idle
is only marked in s2idle_clock_stops, and the stop runs from
s2idle_clock_work after the thaw. atc_dp_tunnels_stop(), which stops
every clock when the PHY leaves USB4 mode, did not clear those marks.
If tipd's resume work took the PHY to SAFE first (a cable pulled during
the sleep), the deferred stop then wrote the tunnel switch registers in
banks[39] and polled their status with the PHY out of USB4 mode and its
domains off, and so did the next call for that clock.

Clear the marks in atc_dp_tunnels_stop(), where every clock is stopped
anyway. A deferred stop that finds the PHY out of USB4 mode, or faulted,
releases only the clock's gate and writes no switch. It stops through
atc_dp_tunnels_apply(), as an immediate stop does, rather than the
single-clock helper.

Also log, at debug level, a clock start refused while the PHY is frozen.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj force-pushed the satchlj/t6050-combo-phy-s2idle-syscore-20261121 branch from b0fb7aa to 56bc4eb Compare November 22, 2026 20:46
@satchlj

satchlj commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

@DjDeveloperr Following your nit, I squashed 843c5f5c into 6fb5e78f and force-pushed with a lease on the old head. The tree is unchanged.

  • Before, head b0fb7aab: 843c5f5c, 6fb5e78f, b0fb7aab.
  • After, head 56bc4ebc, on the same base 107047f6:
    • 02e964d1 "keep active combo PHY domains powered across s2idle". Its tree is 6fb5e78f's. The message now describes the final design: the snapshot and holds in suspend_late/resume_early, the fence, and the deferred tunnel-clock stop. The firmware deep-sleep notifier is unchanged. The J775c lines that tested the superseded PM_SUSPEND_PREPARE design were dropped from the message.
    • 56bc4ebc, the blocker fix (same as b0fb7aab).
  • Checks:
    • git diff b0fb7aab 56bc4ebc is empty, and both heads have tree f5ca3bd98a71.
    • Each commit has Satya as author and committer, with his Signed-off-by only.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Checked 56bc4eb. It is a squash only: 02e964d has 6fb5e78's tree, and 56bc4eb has b0fb7aa's. The new message for 02e964d describes the final design, so the stale-message point is fixed.

Left: the short comment on why apple_t6050_phy_cio_finish()/apple_t6050_phy_cio_lost() are not fenced (minor), and the J775c rows from my last comment (5 RTC s2idle cycles with an active DP tunnel, one cable pull while asleep, one abort after suspend_late, on the default command line). A row at b0fb7aa counts, since the tree is the same.

Assisted-by: LLM (Claude:Opus 5.5)

…fenced

apple_t6050_phy_cio_finish() and apple_t6050_phy_cio_lost() do not check
s2idle_frozen, unlike the other CIO calls. Say why in a comment: they
write no PHY register and change no mode, clock or domain, and their one
caller, the Thunderbolt host's CIO sleep, runs them only for a
suspend-to-RAM it prepared (PM_SUSPEND_MEM), never across s2idle.

No functional change.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj

satchlj commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

@RyanTheTide fcb27ed7 (a new commit, comment only) adds the note on why apple_t6050_phy_cio_finish() and apple_t6050_phy_cio_lost() are not fenced:

  • They write no PHY register and change no mode, clock or domain.
  • Their one caller, the Thunderbolt host's CIO sleep in apple-cio-sleep.c, runs them only for a suspend-to-RAM it prepared: cio_prepared is set only when pm_suspend_target_state == PM_SUSPEND_MEM, and all three call sites require it.

There is no functional change, and I did not build it. I also corrected the body: the one RTC-backed s2idle cycle there ran at 6fb5e78f's tree, before the deferred-stop fix. The J775c rows you list are still owed.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Checked fcb27ed: comment only, explaining that cio_finish/cio_lost write no PHY register and run only on a prepared suspend-to-RAM. That closes the last nit. Code is approved from my side. The J775c rows at this head (the same tree as b0fb7aa) remain.

Assisted-by: LLM (Claude:Opus 5.5)

@satchlj

satchlj commented Nov 23, 2026 •

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

J775c row, 2026-11-23 15:58–16:10Z. This is DP alt mode (a USB-C→HDMI cable), not a DP tunnel, so the tunnelled deferred-stop path these rows target was not exercised. The kernel logged no DP tunnel clock line, and it reported Type-C DPTX PHY 2.

Kernel: 56bc4ebc and fcb27ed7 cherry-picked onto lobata's candidate stack (lobata/cand16-20261122), Image 4a394908, one-shot boot 83920b43 on the default cmdline.

Step Result
5 × 15 s RTC s2idle, display attached 5/5, rc 0. DP-1 connected and enabled after each.
150 s s2idle, cable pulled while asleep Resumed, success 5 → 6, fail 0. (The script's own result line was lost when SSH dropped during the sleep; these come from the kernel log and the success counter.) DP-1 disconnected afterwards, as it should be. DCP logged DPTX link-fault notices from the unplug.
Cable re-plugged DP-1 connected and enabled.
15 s s2idle after the re-plug rc 0, then DP-1 read disconnected 30 s later, after DCP dropped a sink that asserts HPD, relinking the Type-C sink (1/3). Inconclusive: only relink 1/3 was logged (no 2/3 or 3/3), and the journal has no tipd/typec line in that window. So it can't show whether the display was still attached at the check. Satya disconnected it around then for the end of the session.
pm_test=platform rc 0. This is a test resume after suspend_late and noirq, not an injected error abort. I couldn't produce a real abort after suspend_late without a fault hook.

Across all cycles: no PHY firmware stop failed/-62, no SError, no Deferred DP tunnel clock warning, 0 failed units.

New against the same kernel with no display attached:

  • dwc3-apple 382280000.usb: PM: device_prepare(): genpd_prepare returns -11 on every s2idle with the display attached (7 times).
  • dcp_dptx_connect: timed out waiting for port 0 link configuration, once, at the cable-pull resume.

Still owed:

  • A DP-tunnel run (a USB4/Thunderbolt dock with a display): 5 cycles, a pull while asleep, and an abort.
  • A clean repeat of the post-re-plug sleep, with the display left attached.
  • The DP-1 mode list and EDID, read before any sleep. The session ran 1920×1080@120 from the first modeset: either the EDID's preferred timing, or 4K modes pruned by a 2-lane pin-D link; that wasn't read.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@satchlj

satchlj commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

The DP-tunnel rows (5 × s2idle with an active tunnel, a cable pull while asleep, and an abort after suspend_late) can't run on lobata: there's no Thunderbolt/USB4 dock here. They need someone with an M5 Mac and a TB/USB4 dock or display. The DP-alt row above stands as what lobata can cover.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-review at fcb27ed757813ea4d386e217a1d5c5895e2501a4 against the pre-PR checklist (§1–§6): APPROVE.

Prior blocker & nits resolved

  1. Deferred DP tunnel clock stop outliving USB4/CIO mode (blocker from review 6011118748 at 6fb5e78f) — RESOLVED in 56bc4ebcfb53:
    • atc_dp_tunnels_stop() (drivers/phy/apple/atc-t6050-dp.c:628) now clears dp->s2idle_clock_stops = 0 under dp->lock.
    • atc_s2idle_clock_stop() (atc-t6050-dp.c:819-823) skips banks[39] switch writes when dp->faulted || dp->combo_mode != COMBO_CIO (releasing only dp->dp_gate[i] if present) and stops via atc_dp_tunnels_apply(dp, i + 1, NULL) when in COMBO_CIO, matching the immediate-stop path.
  2. All 4 prior nits resolved:
    • Deferred stop uses atc_dp_tunnels_apply(dp, i + 1, NULL) (56bc4ebc).
    • Refused clock start while frozen logs via dev_dbg() (atc-t6050-dp.c:878, 56bc4ebc).
    • Unfenced apple_t6050_phy_cio_finish() / apple_t6050_phy_cio_lost() asymmetry is clearly documented (atc-t6050-dp.c:1375-1382, fcb27ed7).
    • Superseded PM_SUSPEND_PREPARE commit squashed into 02e964d1 with an accurate commit message.

Checklist & integration verification (§1–§6)

  • Merge / tip interaction: Merges cleanly onto current integration/aurora (880a97a3dca2), not superseded; orthogonal to 468200cd4c5d (combo_dp2_join_usb() runs inside combo_mux(), which is fenced by dp->s2idle_frozen).
  • Live CI: host-tests passed at fcb27ed75781 (run 45072567685).
  • §1 / §2 / §3 / §4 / §6: Pass cleanly. Hardware-state driven (no new chip/board/firmware gates; pre-existing combo_sleep_board() deep-sleep gate documented at atc-t6050-combo.h:774-777), default-cmdline safe, bounded u8 bitmasks, all 3 commits carry human author/committer + Signed-off-by: only with zero AI commit trailers, PR body includes Assisted-by:.
  • §5 Evidence (non-blocking note): J775c DP-alt row on 56bc4ebc + fcb27ed7 (5/5 RTC s2idle, cable pull while asleep, pm_test=platform, 0 -62, 0 SError, 0 failed units), earlier J775c default-cmdline A/B (5a2b7d50 vs 8281ecb1), and J714s combined-stack TB-dock 3/3 s2idle + 1/1 deep rows are on record. Because lobata has no TB/USB4 dock, the active DP-tunnel deferred-stop and injected-abort rows remain to be run on a TB/USB4-dock M5 Mac (e.g., J714s/J716c).

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide
RyanTheTide merged commit 18c9193 into integration/aurora Nov 23, 2026
1 check passed
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