Skip to content

phy: apple: atc-t6050: keep the PHY's domains through suspend-to-idle (J714s Type-C dead after s2idle) - #2008

Closed
Isaac-Duarte wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
Isaac-Duarte:j714s/phy-s2idle-domains
Closed

Isaac-Duarte wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
Isaac-Duarte:j714s/phy-s2idle-domains

Conversation

@Isaac-Duarte

@Isaac-Duarte Isaac-Duarte commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What

One commit, drivers/phy/apple/atc-t6050-combo.h and atc-t6050-dp.c (+33/−3). It is in force on the J714s only.

When the default sleep is suspend-to-idle, the T6050 combo PHY's existing PM notifier now holds every power domain device of the PHY out of the system transition: the four domains (usb-aon, common, wrapper, usb) and the dp0..dp3 tunnel-clock gates. Each is marked dev_pm_syscore_device() at PM_SUSPEND_PREPARE and released at PM_POST_SUSPEND, so the hold covers prepare through complete. thunderbolt/apple.c uses the same syscore mark for its router's domains, for a cable's lifetime.

  • genpd then never sees all of a domain's devices suspended, so it leaves each domain as runtime PM had it. On an idle port:

    • the wrapper stays off;
    • the usb domain stays as the USB controller holds it (on in the snapshots);
    • the crossbar's usb-aon/common stay on.

    A port in use stays as it was.

  • The deep-sleep path (aon_syscore, combo_suspend_late() and the rest) is unchanged. The new branch is taken only when pm_suspend_default_s2idle().

Why the PHY, not the crossbar or the DT:

  • The PHY is the device whose cold start needs these domains not gated since boot, and it already has the J714s sleep notifier.

  • Its other domains (wrapper, usb, tunnel clocks) are held too, harmlessly: they stay as runtime PM has them.

  • apple,sleep-retained on the domains would apply to deep sleep too, where the PHY's own sleep handling decides what the always-on domain keeps.

  • Giving atc*_usb GENPD_FLAG_ACTIVE_WAKEUP, as the J813's domains have:

    • It would keep the chain on only while the dwc3 glue's power/wakeup stays enabled. Userspace, udev or TLP can turn that off, and the gating would come back.
    • The flag follows a domain's state at probe, on every domain of every SoC, so it would need a new pmgr-pwrstate DT property or policy.
    • It would change deep sleep for those domains too.

    The PHY hold states the PHY's own requirement, whatever the wakeup policy.

Why

On the J714s, both Type-C ports are dead after an s2idle wake until a reboot. A dock plugged in after the wake fails on either port in the PHY's first power-up step, before its firmware is reached:

apple-t6050-dp-phy 2ab000000.phy: start of mode 1 failed (-110)
apple-t6050-dp-phy 383000000.phy: CIO mode failed (-110), reverse orientation, 1 ms
apple-t6050-dp-phy 383000000.phy: start of mode 4 failed (-110)
sn201202x 2-0c: failed to configure Type-C connection: -110
sn201202x 2-0c: failed to place Type-C mux in safe mode: -5

This was seen in two boots. In one, the ports had not been used before the sleep, and both failed after it. In the other, both had run in CIO mode before the sleep, and the right port, the only one tried, failed after it.

  • The display crossbar (apple-display-crossbar.c, T8142 ops) takes each port's usb-aon and common domains at probe and never releases them, so they never switch off at runtime.
  • genpd's noirq suspend ignores runtime holds (and stay_on). It gates a domain once all of its devices have suspended, so the first s2idle switches those domains off for the first time since boot.
  • No firmware runs at an s2idle wake, and the PHY has no s2idle callbacks. Its next cold start then times out at the first poll (1 ms, one 1000 µs timeout).

Traced in one failing run, with the PHY module from before this change and pmgr-pwrstate plus genpd dynamic debug (s2idle 12:04:42 to 12:05:46, then the dock on the right port).

During the noirq suspend:

PS atc2_usb: pwrstate = 0x0
PS atc2_common: pwrstate = 0x0
PS atc2_usb_aon: pwrstate = 0x0
PS atc1_usb: pwrstate = 0x0
PS atc1_common: pwrstate = 0x0
PS atc1_usb_aon: pwrstate = 0x0
  • All six went back to 0xf at the resume.
  • Each domain's genpd idle_states usage went from 0 to 1.
  • The PMGR PS words of atc*_usb_aon gained the was-power-gated bit.
  • The plug then failed: start of mode 1 failed (-110).

What made the domains go off:

  • atc*_usb was off when genpd took it over (idle 4–5 ms at boot, usage 0); the controller powered it up later.
  • pmgr-pwrstate gives GENPD_FLAG_ACTIVE_WAKEUP only to a domain that is on at probe (pmgr-pwrstate.c ~1024). So atc*_usb lacks the flag. This is inferred from that rule plus the boot idle time; the flag was not read back.
  • Without the flag, genpd counts the dwc3 glue in that domain as suspended even though its wakeup is enabled (core.c ~1592).
  • The domain went off when its last device, a DART (382f00000.iommu for ATC2), suspended.
  • common and usb_aon are its parent domains, and went off in the same cascade once their last subdomain still on (this one) went off. Their own devices, the crossbar's and the PHY's, had already been counted as suspended.

Contrast with the J813 (T8142, phy-apple-atc), reported by Thomas Glanzmann: there the ATC domains were on at boot, so atc*_usb has the flag. dwc3's wakeup then keeps the whole chain on, and over a 9 h s2idle those domains never went off.

Still open: what exactly the gated domains lose (state the boot loader left, or the PHY firmware in SRAM). The fix doesn't depend on it.

Context: s2idle is only reachable on the J714s with #1647 plus apple,j714s in apple_pcie_check_adopted_s2idle()'s allowlist (local, not yet PR'd). Before those, every s2idle was refused, so this path never ran. This PR is a prerequisite for enabling s2idle on the J714s, and changes nothing until then: the notifier is registered on apple,j714s only and acts only when the default sleep is s2idle.

Tested

J714s (MacBook Pro 14" M5 Pro). Running kernel 7.3.0-b248cfe (integration/aurora b248cfe + 13 carried commits, #1647 and #1789 among them, plus the local allowlist line). On top: the identical patch e49cad0c6 (same diff as this head). In the first boot with the patch, a debug commit was also on top: it logs the hold/release and the PHY's power-up registers, and adds an opt-in cycle-and-retry, though neither its retry nor its timeout path ran. In the second boot with the patch, the clean module ran alone. Dock: Ugreen Thunderbolt 5, 3 displays.

run result
Without the commit, boot 1: ports unused, s2idle, lid wake, then the dock on each port fails as above, on both ports
Without the commit, boot 2: both ports in CIO before the sleep, s2idle, lid wake, then the dock on the right port only. The patched module was on disk, but the initramfs held the old one (see below), so this boot ran without the commit. fails as above
With the commit + debug commit: s2idle attempt with the dock connected (CIO, 3 DP tunnels up), refused in noirq suspend by thunderbolt-apple-nhi: refusing system sleep: a DP tunnel to an external display cannot be kept (-16) hold and release logged for both PHYs; dock re-plugged, right port CIO up. This covers the refused-after-prepare path only, not a completed noirq phase.
With the commit + debug commit: real s2idle, 75 s, lid wake, then the dock on the right port, then the left-front port both CIO up, 3 displays each
Clean module only (build-id 397e7396…, read from /sys/module/atc_t6050_dp/notes on that boot, since the log doesn't show it): three real s2idle sleeps on one boot (34 s, 39 s, 49 s), lid wakes. The dock went on the right port after each wake, and on the left-front port after the second and third. every PHY start reached CIO; 3 displays after each wake; no start of mode, CIO mode failed or sn201202x errors in the boot. After the second wake, the first plug on the right port hit an NHI PCIe tunnel activation failure (thunderbolt-apple-nhi 381f00000.nhi: 1:9: PCIe tunnel activation failed, aborting, then USB dropped). The dock was re-plugged until it came up: two more starts dropped too, and the displays came with the fourth. Seen once, not yet attributed.
Same boot, clean module: one long unplugged s2idle, 57 min (10:27:06 to a lid wake at 11:23:41). Then the dock on the right port, then on the left-front port. CIO up on the first plug on both ports (right 11:27:26, left-front 11:27:46), 3/3 displays each; no start of mode, CIO mode failed, sn201202x or PCIe tunnel activation failed errors after this wake
  • The 75 s sleep logged the hold and release for both PHYs.
  • No genpd power-state write for atc1/atc2_common or atc1/atc2_usb_aon during that sleep (pmgr-pwrstate dyndbg).
  • Read-only snapshots before and after it: the genpd idle-state usage of those four domains stayed 0 (idle time 0 ms), and their PMGR PS words were unchanged (tgt=f act=f).
  • Boot 2 above first looked like a failure of this commit, but it was invalid: the PHY module is in the initramfs (appledrm soft-depends on it), so the old module was the one running. In the runs with the commit, the build-id was checked in /sys/module/atc_t6050_dp/notes.
  • Unrelated to this patch: in the three-sleep boot, three attempts right after a lid close were aborted during entry (one in the freezer, two before it). Each was retried about 10 s later and succeeded.

Build: clean cherry-pick onto integration/aurora 580e911; there it builds (M=drivers/phy/apple, LLVM, W=1, no warnings). checkpatch: one line over 75 characters, a quoted log line in the commit message.

Not tested / open questions:

  • The NHI PCIe tunnel activation failure on the first plug after the second wake of the three-sleep boot: seen once, in no other boot, not yet attributed to this patch or to anything else. It did not recur after the later 57 min sleep in the same boot, where the first plug came up on both ports.
  • A completed s2idle with a dock connected across it (USB/PCIe only).
  • Deep sleep: unreachable on the J714s today (apple-sleep fails to probe with -ENODATA, no commit schedule, and mem_sleep offers s2idle only). The deep path is untouched by this commit; a check once deep sleep runs is a follow-up.
  • An overnight-length s2idle (the longest so far is 57 min).
  • The power cost of usb-aon/common staying on through s2idle, as they are when awake: not isolated. The whole system drew 1.95 W over the 57 min sleep (PCI: apple: suspend-to-idle on the J714s (adopted N1 link; stacks on #1647) #2012).
  • Other T6050 boards.

To run before merge

  • J714s: three or more s2idle cycles on one boot, with a dock plugged in after each, on both ports (three cycles; right port after each, left-front after the second and third).
  • J714s: s2idle with a dock connected across it, without display tunnels (USB/PCIe only): the sleep completes and the dock works after the wake. With a DP tunnel up, the NHI refuses the sleep (as above); then check that the ports are usable afterwards.
  • Follow-up, not blocking: other T6050 boards (J716c, K116s) likely have the same failure (same crossbar hold), but this commit doesn't change them; enabling it there is a one-line follow-up once tested. Deep sleep on the J714s once it can run.

On the J714s both Type-C ports are dead after a suspend-to-idle wake. A
dock plugged in after it fails on either port before the PHY firmware is
reached:

  apple-t6050-dp-phy 2ab000000.phy: start of mode 1 failed (-110)
  apple-t6050-dp-phy 383000000.phy: CIO mode failed (-110), reverse orientation, 1 ms

and the port controllers then give up ("failed to place Type-C mux in
safe mode: -5"). The same dock comes up in CIO mode on both ports after a
fresh boot. It happened in two boots: in one the ports had not been used
before the sleep and both failed after it; in the other both had run in
CIO mode before it, and the right port, the only one tried, failed after
it.

The display crossbar holds each port's usb-aon and common domains from
its probe on, so those never switch off at runtime. genpd's noirq
suspend gates a domain once every member device has suspended, runtime
holds or not, so suspend-to-idle switches them off for the first time
since boot. No firmware runs at an s2idle wake to set them up again, and
the PHY has no s2idle callbacks: its cold start then times out in the
first power-up step (1 ms, one 1000 us poll).

Traced with the PHY module from before this change (pmgr-pwrstate and
genpd dynamic debug): at the noirq suspend genpd gates atc2_usb, then
atc2_common and atc2_usb_aon, then the same three for ATC1, and powers
all six on again at the resume; each domain's genpd usage goes from 0 to
1. The usb domain was off when genpd took it over, and the controller
powered it up after boot. So
pmgr-pwrstate did not give it GENPD_FLAG_ACTIVE_WAKEUP, and the dwc3
glue in it is counted as suspended although its wakeup is enabled. The
domain goes off once the glue, its DARTs and the PHY's device have
suspended, and common and usb-aon follow, their own devices (the
crossbar's and the PHY's) being suspended too. On a T8142 J813, whose
ATC domains were on at boot, dwc3's wakeup keeps them all on through
s2idle.

Hold the PHY's domain devices out of the system transition when the
sleep is suspend-to-idle, from the PM notifier's PM_SUSPEND_PREPARE to
PM_POST_SUSPEND, so that they cover the prepare and complete phases as
well. genpd then never counts a domain's devices all suspended, and each
domain stays as runtime PM had it: an idle port's wrapper off, its usb
domain as the USB controller holds it, the crossbar's on, a port in use
as it was. thunderbolt/apple uses the same syscore mark for its
router's domains, for a cable's lifetime.

The hold is in the PHY rather than the crossbar or the device tree: the
PHY is the device whose cold start needs the domains not gated since
boot, and it already has the J714s sleep notifier. Its other domains
(wrapper, usb, tunnel clocks) are held too, harmlessly: they stay as
runtime PM has them. apple,sleep-retained would apply to deep sleep as
well, where the PHY's own sleep handling decides what the always-on
domain keeps.

Suspend-to-idle was refused on the J714s until now, so this path has not
run there before. As with the PHY's deep-sleep notifier, this is in
force on the J714s only, where the notifier is registered. A
suspend-to-idle reached by writing "freeze" while "mem" means deep is
not covered: the notifier goes by the default sleep, as dwc3-apple's
does.

Signed-off-by: Isaac Duarte <31712685+Isaac-Duarte@users.noreply.github.com>
@Isaac-Duarte

Copy link
Copy Markdown
Contributor Author

Superseded by #2018: a force-push of this branch went out with a parentless commit, GitHub closed this PR and won't reopen it. #2018 carries the same change (same tree) on the correct parent, with the reviewed description.

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.

1 participant