Skip to content

phy: apple: atc: enable T6030 runtime idle power-off - #4367

Open
DjDeveloperr wants to merge 10 commits into
mainfrom
feat/t6030-atc-idle-power-off
Open

DjDeveloperr wants to merge 10 commits into
mainfrom
feat/t6030-atc-idle-power-off

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What:
Enable runtime idle power-off for unused Apple T6030 (M3 Pro) ATC PHYs and display crossbars, following the T6041 pattern:

  • Register apple,t6030-pmgr on simple-pm-bus so all four T6030 PMGR banks bind cleanly and do not hold sync_state on atc*_common or atc*_* power domains.
  • Opt T6030 ATC PHYs into runtime idle power-off in device tree: arch/arm64/boot/dts/apple/t6030.dtsi adds apple,idle-power-off to atcphy0–atcphy3 (using their existing ps_atc0_usb–ps_atc2_usb, ps_atc3_common, and crossbar power-domains), and arch/arm64/boot/dts/apple/t603x-j514s-j516s-hdmi.dtsi removes apple,always-on from ps_atc3_common.
  • Enable .runtime_pm = true on apple_dpxbar_t6030_hw in drivers/mux/apple-display-crossbar.c, quiesce any selected output across all runtime_pm layouts (T6030/T6041/T8132, T8103, and T8122/T602x) and drop held runtime-PM references via a serialized devm cleanup action before devm_pm_runtime_enable() unwinds on provider unbind, and capture T8103 link-up debug register reads under dpxbar->lock.
  • Harden atcphy_restore_after_pd_off() and domain-loss recovery in drivers/phy/apple/atc.c:
    • Keep pd_was_off set and preserve atcphy->mode / pipe_pending on power-off, PIPE-parking, or mode-replay failures instead of letting callers proceed.
    • Run pending cold restore before the mode_dirty / pipe_pending guards in atcphy_dp_configure() and atcphy_dp_stop(), and reject physical DP rate configuration in atcphy_dp_configure() with -EBUSY when the PHY is not in a physical DP mode (DP or USB3_DP).
    • Track one-shot domain-loss state forgetting (pd_state_forgotten) separately from pending restore so retries after an incomplete replay unwind partially acquired ownership (such as J700 aux_power_requested) cleanly while a genuine second domain loss forgets state again; clear stale t8103_dummy_pending once cold PIPE parking succeeds; invalidate dp_link_rate and tunnel state (tunnel_attempted, tunnel_saved, tunnel_saved_regs, tunnel_dpin_rate) on domain loss so stale tunnel snapshots are never kept across SAFE/power-loss transitions; finalize pending usb_off_pending transitions to OFF; and skip replaying an obsolete prior mode in atcphy_mux_update_to() when a valid superseding target mode (including OFF and USB2 / fixed-hub SAFE) replaces it after domain loss.
    • Add KUnit regression tests (atcphy_test_t6030_restore_pipe_park_fail, atcphy_test_t6030_restore_dp_mode_fail) plus matching host-test fixture updates.

Tested:

  • Exact head 5bea9d8aed1d43f81930ff656c8613d9a0509b80 built cleanly for ARM64 (Image, apple/t6030-j516s.dtb, phy-apple-atc.ko, mux-apple-display-crossbar.ko, zero warnings in changed drivers).
  • All 7 host test suites passed on exact head 5bea9d8aed1d43f81930ff656c8613d9a0509b80: pmgr-bus-tests.py, atc-usb3-tests.py (39 cases), atc-dp-drive-tests.py (8 cases), t6030-clock-tests.py (22 cases), atc-cio-sleep-tests.py (41 cases + 11 negative controls), atc-t8132-usb3.py (13 cases), and apple-dcp selftests (103/103 cases), plus exact-function host MMIO checks covering superseding SAFE/USB2 after domain loss, non-DP atcphy_dp_configure() rejection, and T602x tunnel state invalidation.
  • Live hardware verification on MacBook Pro 14" M3 Pro (Mac15,7, t6030-j516s, exact head 5bea9d8aed1d43f81930ff656c8613d9a0509b80 kernel, modules, and t6030-j516s.dtb):
    • KUnit passed live on target (63/63): 38/38 atcphy-mode (including atcphy_test_idle_power_off_dt), 7/7 atcphy-t8132-pm (including atcphy_test_t6030_restore_pipe_park_fail and atcphy_test_t6030_restore_dp_mode_fail), 16/16 atcphy-t8152, and 2/2 atcphy-t8103-dp.
    • All four T6030 PMGR banks bound to simple-pm-bus with zero pending sync_state.
    • All four display crossbars (70304c000.mux, b0304c000.mux, f0304c000.mux, 130304c000.mux) stayed suspended with active_ms=0; live unbind/bind of 130304c000.mux succeeded cleanly with status=suspended, active_ms=0, atc3_* remaining off-0, and zero warnings.
    • Idle 1303000000.phy (HDMI port with no display attached) suspended (status=suspended) and all seven atc3_* domains (atc3_usb, atc3_usb_aon, atc3_cio_usb, atc3_cio_pcie, atc3_cio, atc3_pcie, atc3_common) entered off-0.
    • Sleep/wake matrix: 1x s2idle (rtcwake -m freeze -s 8) + 2x deep (rtcwake -m mem -s 10, with 1.0.0b19 stage2 tunables) all passed (suspend_stats/success=3, fail=0, last_failed_errno=0, boot object resumes 0 -> 1 -> 2), preserving idle off-0 across every wake with NVMe and USB4 dock intact and zero new kernel errors.

Risk: two-way · M3 Pro (T6030). Scoped to T6030 PMGR/ATC/display-crossbar runtime PM, apple_dpxbar_rpm_release() teardown, and atcphy_restore_after_pd_off() failure/domain-loss handling; a plain revert restores prior always-on behavior. Non-T6030 SoCs keep existing behavior; active Type-C/USB4/DP ports continue to hold their runtime-PM references while in use.

Not yet:

  • On systems running native macOS 14.7 dcpext0 firmware, apple-dcp selects fixed_xbar and sets atcphy3 to DP mode at probe while bound, so the fixed HDMI port remains active when dcpext0 is bound (no regression from current behavior; dynamic HPD-gated fixed-HDMI release in dcp is separate follow-up work requiring physical HDMI display testing).
  • Live Type-C DisplayPort / USB3 hotplug cycle on an unplugged T6030 USB-C port has not yet been exercised alongside this branch (the test machine had all three USB-C ports occupied by power/debug/dock cables).

t6030.dtsi lists its PMGR register banks as "apple,t6030-pmgr",
"apple,t8103-pmgr", "syscon", "simple-mfd". Because
simple_pm_bus_probe() refuses ONLY_BUS matches that are not the first
compatible string, the T6030 PMGR banks never bound, leaving
sync_state() permanently pending on ps_atc{0,1,2,3}_common (due to
pmgr_mini) and blocking genpd from clearing GENPD_FLAG_DEFER_OFF.

Add "apple,t6030-pmgr" to simple_pm_bus_of_match[] and extend
tools/asahi/pmgr-bus-tests.py with T6030 positive and negative checks.

Signed-off-by: DjDeveloperr <hey@djdev.me>
On T6030, the four ATC display crossbars sit in ps_atc{0,1,2,3}_usb
and previously fell back to the non-RPM T6020 hw table, holding the
ATC USB and common power domains powered continuously even when no
output is selected.

Add apple_dpxbar_hw_t6030 with t6030_flow, no_tunable, and runtime_pm
enabled and match "apple,t6030-display-crossbar" ahead of the T6020
fallback, matching T8122, T8132, and T6041.

Signed-off-by: DjDeveloperr <hey@djdev.me>
Enable runtime idle power-off for T6030 (M3 Pro) ATC PHYs:
- Guard apple_atc_dp_tunnel_rate_source() against touching core MMIO
  when any idle_rpm PHY is outside USB4/TBT mode (matching the
  existing T8132 guard; leaving CIO mode already stops the tunnel
  clock).
- Allow DP-only PHYs in atcphy_pd_can_power_off() when their attached
  power domain (ps_atcN_common) lacks apple,always-on even though its
  fabric bus parent (ps_lw30) is always-on.
- Advertise apple,idle-power-off on atcphy0, atcphy1, atcphy2, and
  the HDMI DP-only atcphy3 in t6030.dtsi (atcphy_hw_t6030 already
  sets restore_after_pd_off and sleep_drops_common), and drop the
  apple,always-on override on ps_atc3_common in
  t603x-j514s-j516s-hdmi.dtsi now that atcphy3 and atcphy3_xbar
  manage ps_atc3_common dynamically and restore after power loss.
- Extend atc-idle-pm-test.dtso and atcphy_test_idle_power_off_dt() in
  atc-test.c with T6030 USB-C and DP-only positive/negative cases.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 4, 2026 22:28
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Merge readiness at 2ad5fc98: not ready yet

Check Detail
CI at head running running: host-tests, source, pr-text / pr-text, DWC3/ATC
Review no needs one approving review from Core, Omarchy Mac or Aurora Maintainers (not the author)
Requested changes no requested by RyanTheTide
Hardware row at head no no line with the head SHA 2ad5fc98, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · M3 Pro (T6030). Scoped to T6030 PMGR/ATC/display-crossbar runtime PM, appledpxbarrpmrelease() teardown, and atcphyrestoreafterpdoff() failure/domain-loss handling; a plain revert restores prior always-on behavior. Non-T6030 SoCs keep existing behavior; active Type-C/USB4/DP ports continue to hold their runtime-PM references while in use.

Areas: area:gpu, area:platform, area:usb

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

…PM on unbind

Propagate failures from atcphy_restore_after_pd_off() instead of clearing
pd_was_off early and letting callers proceed:
- Defer clearing pd_was_off until cold restore completes cleanly.
- Preserve atcphy->mode on power-off, PIPE-parking, and mode-replay
  failures; keep pipe_pending set rather than falsely recording
  ATCPHY_PIPEHANDLER_STATE_DUMMY when PIPE parking fails.
- Propagate the error across callers including atcphy_dwc3_reset_deassert()
  and atcphy_resume(), and update host-test stubs/fixtures accordingly.
- Add KUnit regression tests covering T6030 cold-restore PIPE parking
  timeout and DP-only mode-replay failure.

In apple-display-crossbar, register a devm cleanup action right after
devm_pm_runtime_enable() to serialize against active mux operations, mark
the provider removed, and drop any runtime-PM references still held for
selected or preselected outputs before runtime PM is disabled on unbind.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) and removed ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-template PR body lacks Tested or Risk (bot) labels Dec 4, 2026
… on unbind

Address cold-restore and crossbar-unbind edge cases:
- Clear t8103_dummy_pending alongside pipe_pending once cold restore
  parks the PIPE on a freshly powered-up domain, so T8103 reset
  deassert retries are not stuck returning -EBUSY.
- Discharge pending J700 usb_off_pending shutdowns after domain loss
  and baseline atcphy_power_off() instead of replaying the pre-OFF
  mode into the usb_off_pending guard.
- In apple_dpxbar_rpm_release(), call apple_dpxbar_t6030_link(..., false)
  for any selected T6030 output while its runtime-PM hold is still owned
  so shared-domain registers do not retain stale enables or FIFO clocks
  across provider unbind/rebind.
- Capture apple_dpxbar_t8103_link_up() debug register reads under
  dpxbar->lock before unlocking.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Dec 4, 2026
Address three state-recovery edge cases across cold restore and crossbar unbind:

- Run pending atcphy_restore_after_pd_off() before the mode_dirty/pipe_pending
  guards in atcphy_dp_configure() and atcphy_dp_stop() so a transient PIPE
  timeout during cold restore does not trap subsequent DP retries or stop in
  -EBUSY without retrying restore.
- Track whether cached common/AUX register ownership was already forgotten for
  the current domain-loss event (pd_state_forgotten) so retrying an incomplete
  replay without a second domain loss preserves partially acquired ownership
  (such as J700 aux_power_requested) for atcphy_power_off() to unwind cleanly.
- Extract locked T8103 and T602x disconnect helpers in apple-display-crossbar
  and run the matching layout disconnect sequence from apple_dpxbar_rpm_release()
  while the runtime-PM hold is still owned, instead of only quiescing T6030.

Signed-off-by: DjDeveloperr <hey@djdev.me>
…retries

Close four remaining cold-restore recovery edge cases across T6030,
T8103, and J700:

- When a Type-C mux update requests SAFE (APPLE_ATCPHY_MODE_OFF) after a
  power-domain loss on a non-T8132-common-owned PHY, restore directly to
  OFF and clear mode_dirty rather than failing to replay an obsolete
  previous mode.
- Clear stale t8103_usb3_retry alongside t8103_dummy_pending once cold
  PIPE parking succeeds so a later same-mode USB3 mux event cannot
  reconnect the PIPE while DWC3 is held in reset.
- Run atcphy_restore_after_pd_off() unconditionally at the start of
  atcphy_dp_stop() and atcphy_dp_configure() so pending cold restores in
  USB3 and OFF modes are completed before dirty/pending guards.
- Call atcphy_restore_after_pd_off() at the start of j700_dp_configure()
  (and wrap the J700 DP configure path with atcphy_rpm_get/put) so rate
  and stop retries recover from an incomplete AUX replay instead of
  returning -EBUSY, and stub atcphy_restore_after_pd_off() in the
  apple-dcp unwind host selftest.

Signed-off-by: DjDeveloperr <hey@djdev.me>
RyanTheTide
RyanTheTide previously approved these changes Dec 5, 2026

@RyanTheTide RyanTheTide 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.

Verdict: MERGE at 8843ffd50af14e5d9fa23fc6275ae1412ec74922

Checked: T6030 selects idle power-off through DT and the block's compatible. The crossbar serializes PM get/put against provider removal and clears selected outputs before dropping their references. Cold-restore errors preserve the pending state so callers can retry. The current head also handles SAFE/OFF without replaying the old mode and balances the temporary PM reference in the J700 DP path. Exact-head DT checks passed.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 5, 2026
When a valid superseding Type-C mux update arrives after a power-domain
off event, restore to the baseline OFF state before switching rather than
replaying the old mode first. This avoids failing J700 fixed-hub SAFE
(which maps to USB2) or T6030 DP-to-USB2 transitions on obsolete DP AUX
or RCAL bring-up, while preserving the current mode if the target mode is
rejected by atcphy_mux_check().

Also check that the restored mode supports physical DisplayPort before
programming the AUSPLL in atcphy_dp_configure(), and invalidate T602x
tunnel ownership flags, saved registers, DP IN rates, and cached DP link
rate in atcphy_forget_common_state() on domain loss.

Update the apple-dcp host selftest struct stubs to carry the invalidated
tunnel fields.

Signed-off-by: DjDeveloperr <hey@djdev.me>
RyanTheTide
RyanTheTide previously approved these changes Dec 5, 2026

@RyanTheTide RyanTheTide 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.

Verdict: MERGE at 5bea9d8aed1d43f81930ff656c8613d9a0509b80

Checked: The superseding mode must pass the mux capability check before the stale mode is discarded. Failed cold restore keeps the previous mode for retry, and physical DP configuration now checks the restored mode before programming the PLL. Domain loss clears the cached link rate and tunnel state. All eight DP-drive controls and 17 selected PHY retry, PIPE, unwind and AUX controls passed at this head.

…l/validate on cold restore

Avoid replaying an obsolete pre-domain-loss USB3 mode in atcphy_usb3_power_off()
and atcphy_usb3_set_mode() when tearing down to OFF or falling back to USB2
device mode on PHYs with restore_after_pd_off, preventing failed RCAL polls from
blocking phy_power_off() and pinning PHY power_count and runtime-PM references.

Also run atcphy_restore_after_pd_off() and reject dirty/pending PIPE state in
apple_atc_dp_tunnel_rate(), apple_atc_dp_tunnel_rate_source(), and
apple_atc_dp_tunnel_open(), clear tunnel_dpin_rate[] on idle-rpm stop, and
report zero usable DP lanes in atcphy_dpphy_validate() while a cold restore is
pending or incomplete.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot added the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 5, 2026

@RyanTheTide RyanTheTide 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.

Verdict: REQUEST_CHANGES at 2ad5fc9

Failure: atcphy_usb3_set_mode() loses the USB2 target when configuration times out after a successful cold restore to OFF (drivers/phy/apple/atc.c:5392–5403, 5438–5457). I replayed the shipped host fixture with one USB2 configuration timeout. The prior code returns ETIMEDOUT, then succeeds on the next identical request and reaches USB2. This head returns ETIMEDOUT, then EBUSY with mode still OFF and dirty. The retry never attempts to configure USB2. Keep the fallback target available on retry.

Failure: atcphy_dpphy_validate() now reports zero lanes during pending cold restore (drivers/phy/apple/atc.c:5650–5655). The ordinary DPTX maximum-lane callback treats a successful result below two as four lanes (drivers/gpu/drm/apple/dptxep.c:440–457). A pending cold restore on a previously valid two-lane USB3+DP assignment now advertises four. Native DPTX can instead reject the request before the operation that would restore the PHY. Make the pending-restore result explicit to the DPTX callers.

Checked: All 39 shipped USB3 host cases passed, and hosted DT checks passed at this head.

@github-actions github-actions Bot added the changes-requested A reviewer requested changes (bot) label Dec 5, 2026
…nd AUX state

Fix six cold-restore and teardown edge cases across T8122/T6030, T8132,
and T600x ATC PHYs:

1. Avoid replaying obsolete SuperSpeed modes during USB2-only device
   startup in atcphy_usb2_set_mode() so DWC3 can deassert reset without
   stalling on SuperSpeed RCAL after domain loss.
2. Restore directly to the USB2 fallback target inside
   atcphy_restore_after_pd_off() in atcphy_usb2_set_mode() and
   atcphy_usb3_set_mode(), restoring the prior mode on error so transient
   failures remain retryable with or without a second domain loss.
3. Clear t8132_common_owned once per domain loss in
   atcphy_forget_common_state() and allow pre-epoch teardown/fallback/mux
   shortcuts when the T8132 domain went off before any common touch,
   preventing pinned power_count and runtime-PM references.
4. Allow rate == 0 tunnel clock teardown to proceed when mode_dirty or
   pipe_pending is set (and short-circuit cleanly while pd_was_off) in
   apple_atc_dp_tunnel_rate_source() and apple_atc_dp_tunnel_rate().
5. Record dp_t8122.aux = true in atcphy_dp_aux_on_t8122() only when
   atc_t8122_dp_aux_is_on() confirms power-up, turning AUX off on failure
   so DP validation reports 0 lanes instead of stale lane counts.
6. Check for CIO mode before calling atcphy_restore_after_pd_off() in
   apple_atc_dp_tunnel_open() so an idle OFF PHY is not woken or touched.

Signed-off-by: DjDeveloperr <hey@djdev.me>

This branch has not been deployed

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

Labels

area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:usb Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants