Skip to content

phy: apple: dptx: let the T6050 PHY's power domain follow its link - #2760

Open
satchlj wants to merge 1 commit into
integration/aurorafrom
satchlj/dptx-t6050-runtime-pm-20261122
Open

satchlj wants to merge 1 commit into
integration/aurorafrom
satchlj/dptx-t6050-runtime-pm-20261122

Conversation

@satchlj

@satchlj satchlj commented Nov 22, 2026

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf.

phy: apple: dptx: enable runtime PM for the T6050 DPTX PHY, so its power domain follows the link.

  • Before: the PHY powers its PLL, lanes and AUX block down on PHY_MODE_INVALID, but the domain stayed on.
  • After: an active link holds a runtime-PM reference, taken before t6050_activate() and dropped after a successful t6050_deactivate(), and genpd powers the domain off while the display is off.

This is the PHY half of what #2503 does for DPMS off. #2503 releases the fixed HDMI port's DPTX link on firmware 27, and this lets the PHY's domain follow.

Selection: the driver's existing per-variant branch (hw.type == DPTX_PHY_T6050, from the apple,t6050-dptx-phy match data), the same branch set_mode already takes for this PHY. The T6020 path has its own power handling and is unchanged.

Testing

J775c (Mac Studio, M5 Max, DCP firmware 27.0), HDMI monitor attached, default cmdline, one-shot trial boot.

Step dptx-phy (genpd) PHY runtime status HDMI
start on active connected / enabled / On
DPMS off (cycle 1, cycle 2) off-0, off-0 suspended connected / disabled / Off
DPMS on (cycle 1, cycle 2) on, on active connected / enabled / On
3 × rtcwake -m freeze -s 10, display on on after each — connected / enabled at +2 s and +15 s, 3/3
  • 0 failed units, 0 setmode failed.
  • The kernel error lines are the ones every candidate boot logs: DCP lane count and clock index, speakers off, and fab3-soc at each resume, which is tracked separately.
  • Not covered:
  • checkpatch --strict: clean.

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, the runtime-PM wiring is small and the J775c genpd table shows the domain following DPMS. A few points:

  • dptx_phy_set_mode() drops the reference only when t6050_deactivate() returns 0 (drivers/phy/apple/dptx.c:961-965), but t6050_deactivate() clears active and powers the blocks down even when the PLL power-down fails (dptx.c:893-907). After one such failure the reference is kept, the next PHY_MODE_DP takes another one (dptx.c:940-945), and the domain can never power off again until reboot. Dropping the reference whenever was_active && !dptx_phy->active would keep the count balanced.
  • At dptx.c:962-964 a phy_pm_runtime_put_sync() error is returned to the DCP after the link is already down and active is false, so the caller sees a failed mode change for one that happened. Logging it seems enough.
  • Probe enables runtime PM without pm_runtime_set_active() (dptx.c:1102-1106), so from probe until the DCP's first set_mode(PHY_MODE_DP) the device counts as suspended and genpd may switch ps_dptx_phy off. Before this patch runtime PM was disabled and the domain stayed on. If the boot loader leaves the HDMI link up, that gap can take the PHY away from the boot framebuffer and the DCP. Could you show the dptx-phy genpd state across early boot on J775c, from probe to the DCP taking the link?
  • Nit: the early return at dptx.c:941 reads active outside dptx_phy->lock. It is safe because the phy core serializes set_mode, but reading it under the lock keeps the field under one rule.
  • Scope: apple,t6050-dptx-phy is also the fallback compatible of the T6041 J575c HDMI PHY (t6041-j575c-hdmi.dtsi:52) and of the die-1 PHY in t6050-ultra.dtsi:265, which both get runtime PM from this change. A DPMS off/on row on J575c, and one on a board with the die-1 PHY, would cover them, or they could go in "Not covered". The failed-activation path (dptx.c:953-956) is also untested.

Assisted-by: LLM (Claude:Opus 5.5)

@satchlj

satchlj commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

Repeated on this PR's own base. The lobata candidate cand-13 is integration/aurora 606d37ec plus lobata's open PRs, including this commit and #2503. Default cmdline, boot 050f94da:

  • DPMS off → dptx-phy off-0, runtime suspended; DPMS on → on, active, HDMI connected / enabled / On. 2/2 cycles.
  • 3 × rtcwake -m freeze -s 10: HDMI connected and enabled at +2 s and +15 s, 3/3.
  • 0 failed units, 0 setmode failed.

DPMS off → s2idle → DPMS on still leaves HDMI dark, as before this change.

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.

Adversarial review at 04454c901781 against pre-pr-checklist.md:

Blockers

  1. §3 (Runtime-PM reference leak on t6050_deactivate() failure — drivers/phy/apple/dptx.c:893-909, 961-965):

    • t6050_deactivate() unconditionally powers down AUX, clears phy->active = false and phy->rate = 0, and calls t6050_device_power(phy, false) even when t6050_pll_power_down() returns a negative error.
    • dptx_phy_set_mode() guards the put with else if (mode == PHY_MODE_INVALID && was_active && !ret). After any PLL power-down error, dptx_phy->active is false while the runtime-PM reference is leaked permanently; the next PHY_MODE_DP takes another reference and ps_dptx_phy can never suspend again until reboot. Drop the reference whenever was_active (since t6050_deactivate() always clears active).
  2. §3 (Returning pm_ret after completed deactivation corrupts phy->attrs.mode — dptx.c:962-965, drivers/phy/phy-core.c:389-390):

    • Returning a negative phy_pm_runtime_put_sync() error after t6050_deactivate() has already powered down the PHY and cleared active = false reports a failed mode switch to DCP and causes phy_set_mode_ext() to skip phy->attrs.mode = mode, leaving phy->attrs.mode stale as PHY_MODE_DP while the PHY is off. Log the runtime-PM put failure (dev_warn) rather than overriding ret after teardown.
  3. §3 (Early-boot runtime-PM state mismatch — dptx.c:1102-1106):

    • dptx_phy_probe() calls devm_pm_runtime_enable(dev) without pm_runtime_set_active() (or preserving a live bootloader link). Because dcp_desktop_external() does not run on firmware 27.0 fixed HDMI, nothing holds a runtime-PM reference between dptx_phy_probe() and DCP's first phy_set_mode_ext(PHY_MODE_DP). During that window dev is RPM_SUSPENDED with usage_count == 0, allowing genpd_power_off_unused() (or a sibling suspend) to power off ps_dptx_phy under an active bootloader HDMI display / simplefb if DCP probes late, defers, or fails.
  4. §3 (Minor locking hygiene — dptx.c:941):

    • if (dptx_phy->active) return 0; reads dptx_phy->active outside dptx_phy->lock. Although phy_set_mode_ext() serializes calls with phy->mutex, keeping all reads/writes of dptx_phy->active under dptx_phy->lock keeps the locking invariant consistent with dptx_phy_configure().
  5. §5 (Evidence gaps):

    • Report the SELinux denial count explicitly (0 required by §5) and show dptx-phy genpd state across early boot before DCP activates the link.
    • Note that apple,t6050-dptx-phy is also the fallback compatible for T6041 J575c HDMI (t6041-j575c-hdmi.dtsi:52) and die-1 (t6050-ultra.dtsi:265); please either add DPMS off/on coverage or list them explicitly under "Not covered".

Checks Passing

  • §1 / §2 / §4 / §6: Uses existing DPTX_PHY_T6050 HW block variant, default cmdline, human author/committer and human Signed-off-by: only, Assisted-by: present in PR body, clean naming, CI host-tests green.

Assisted-by: LLM (Gemini 4 Neon)

@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 re-review at fdd99f79142e87f5518de07433379c8aff1a4df4 against pre-pr-checklist.md:

Prior Blockers Resolved

  • §3 (PLL power-down error refcount leak): Resolved — dptx_phy_set_mode() now drops the link's runtime-PM reference whenever mode == PHY_MODE_INVALID && was_active regardless of t6050_deactivate()'s return code.
  • §3 (Stale phy->attrs.mode on pm_ret failure): Resolved — pm_ret < 0 is logged with dev_warn() instead of overriding ret.
  • §3 (Unlocked dptx_phy->active read): Resolved — now checked under dptx_phy->lock.

Blockers

  1. §3 (New regression — boot_hold runtime-PM refcount leak on probe error paths and driver unbind — drivers/phy/apple/dptx.c:1129-1158):

    • dptx_phy_probe() calls pm_runtime_get_noresume(dev) at line 1130 and only unwinds it if pm_runtime_set_active() (line 1133) or devm_pm_runtime_enable() (line 1138) fails.
    • If devm_phy_create() (line 1146 — which can return -EPROBE_DEFER via regulator_get_optional()), devm_of_phy_provider_register() (line 1152), or t6050_probe() (line 1156 — returns -EINVAL if apple,ufp-endpoint is missing) fails, dptx_phy_probe() returns without calling pm_runtime_put_noidle(dev), leaking dev->power.usage_count (and compounding on every -EPROBE_DEFER retry).
    • Likewise, if the driver is unbound before the first dptx_phy_set_mode() call (e.g. if DCP fails to probe or the module is unloaded), nothing releases boot_hold, leaving usage_count unbalanced on unbind.
    • Register a devm_add_action_or_reset() cleanup right after pm_runtime_get_noresume(dev) (checking and clearing dptx_phy->boot_hold under dptx_phy->lock and calling pm_runtime_put_noidle(dev)) so both probe failures and unbind before first mode switch always balance the reference.
  2. §3 (New regression — unsupported mode drops boot_hold despite returning -EINVAL — drivers/phy/apple/dptx.c:955-965, 982-983):

    • If the first dptx_phy_set_mode() call passes a mode other than PHY_MODE_DP or PHY_MODE_INVALID, ret stays -EINVAL and neither activate nor deactivate runs, yet lines 963–964 unconditionally clear dptx_phy->boot_hold = false and line 983 calls pm_runtime_put(dev), dropping the bootloader display power-domain hold on a rejected call. Reject unsupported modes (if (mode != PHY_MODE_DP && mode != PHY_MODE_INVALID) return -EINVAL;) before touching boot_hold.
  3. §5 (Hardware verification gaps on live head):

    • fdd99f79 (with boot_hold / pm_runtime_set_active()) has not been booted on hardware yet (all test results are from 04454c90).
    • Please add on the fixed head: early-boot dptx-phy genpd state before DCP's first mode switch, explicit SELinux denial count (0 required by §5), and either test coverage or explicit "Not covered" entries for T6041 J575c (t6041-j575c-hdmi.dtsi:52) and die-1 (t6050-ultra.dtsi:265), which also bind to apple,t6050-dptx-phy. Also update the PR description's "dropped after a successful t6050_deactivate()" wording.

Checks Passing

  • §1 / §2 / §4 / §6 / CI: Uses existing DPTX_PHY_T6050 match variant, default cmdline, both commits (04454c90, fdd99f79) carry human author/committer and human Signed-off-by: only, Assisted-by: present in PR body, clean naming, host-tests green at fdd99f79.

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. Reply to @DjDeveloperr's review of 04454c90. All four code points are in one new commit, fdd99f79.

  1. Reference leak after a PLL power-down error. t6050_deactivate() always clears ->active and powers the blocks down, so the INVALID path now drops the link's reference whenever the link was active, whatever deactivation returned.
  2. pm_ret overriding a completed teardown. A failed phy_pm_runtime_put_sync() after the PHY is down is now reported with dev_warn(). The mode switch keeps the teardown's result, so phy_set_mode_ext() records the mode change.
  3. Early boot.
    • Probe now marks the device active with a reference of its own (boot_hold), taken before devm_pm_runtime_enable().
    • The DCP's first mode switch drops it, after taking the link's own reference for DP.
    • So genpd's unused power-off can't take ps_dptx_phy from a link the boot loader left up, even if the DCP probes late, defers or fails. If the DCP never switches mode, the domain stays on.
  4. Locking. ->active is read under dptx_phy->lock for the "already active" return too.

Compile: dptx.o builds with W=1 and no warnings.

J775c row

  • Setup: cand-16b (Image d6dbf747 = integration/aurora plus our open PRs, including fdd99f79). HDMI on the fixed port through a KVM, default cmdline, boot fa876b60.
  • Early boot, before any DPMS change, at 13 s uptime: dptx-phy on, runtime active, genpd total_idle_time 0 ms (active 12,915 ms). So the domain stayed on from boot until the DCP took the link.
  • DPMS off/on, two cycles:
    • off: dptx-phy off-0, runtime suspended, HDMI connected/disabled;
    • on: dptx-phy on, runtime active, HDMI connected/enabled/On.
  • 3 × 10 s rtcwake -m freeze: rc 0 each. HDMI connected/enabled/On at +2 s and +15 s, dptx-phy on.
  • DPMS off → s2idle → DPMS on: rc 0, HDMI connected/enabled/On, dptx-phy on.
  • set_mode failures 0, failed units 0, SELinux denials 0. The kernel error lines are the known DCP lane-count and clock-index pair, one per mode set, plus speakers off.

Not covered: apple,t6050-dptx-phy is also the fallback compatible of the T6041 J575c HDMI PHY (t6041-j575c-hdmi.dtsi) and of the die-1 PHY in t6050-ultra.dtsi (J775d). Both get this runtime PM. Neither has a DPMS off/on row; I don't have those machines.

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Nothing on integration/aurora replaces this: drivers/phy/apple/dptx.c is unchanged on the tip since this branch's base, and the two commits apply cleanly on daa9e2d. The J775c row at fdd99f7 (early-boot genpd state, DPMS off/on, s2idle) covers the hardware side of the last review. Two code points from the re-review at fdd99f7 are still open: the probe-time boot_hold reference is not dropped when probe fails after devm_pm_runtime_enable() (for example a deferred devm_phy_create()) or on unbind before the first mode switch, and a rejected mode (-EINVAL) still clears boot_hold and drops that reference. @satchlj, could you add a devm action for the boot_hold put and reject unsupported modes before touching it? #2764 edits the same file; the two apply together without conflict.

The T6050 DPTX PHY powers its blocks up and down with the display
link in t6050_activate() and t6050_deactivate(), but previously never
enabled runtime PM so its power domain stayed on whenever the link
was parked.

Enable runtime PM on T6050 DPTX PHYs and hold a runtime-PM reference
for each active DP link:
- Take an initial probe-time reference (boot_hold) with a devm
  release action so a live bootloader simplefb link is protected from
  genpd unused power-off until DCP's first mode switch, without
  leaking the reference if probe fails later or the driver unbinds
  first.
- Reject unsupported PHY modes with -EINVAL before touching
  boot_hold or taking the mutex.
- Drop the active link's reference on deactivation (even if PLL
  power-down reports an error, since t6050_deactivate() always clears
  active and powers down the blocks) and log runtime-PM put errors
  instead of overriding a completed deactivation.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj force-pushed the satchlj/dptx-t6050-runtime-pm-20261122 branch from fdd99f7 to 2667b1b Compare November 24, 2026 01:45
@satchlj

satchlj commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Gemini 4 Neon on @satchlj's behalf.

Rebased onto integration/aurora (0bbe021a28bd) and squashed into single commit 2667b1b9b3b3 to address both remaining code blockers from @DjDeveloperr and @RyanTheTide:

  1. devm release action for boot_hold (dptx_phy_drop_boot_hold): registered via devm_add_action_or_reset() right after devm_pm_runtime_enable(). If devm_phy_create() (e.g. -EPROBE_DEFER), devm_of_phy_provider_register(), or t6050_probe() fails — or if the driver unbinds before the first mode switch — the devm action clears boot_hold under dptx_phy->lock and calls pm_runtime_put_noidle(dev) before devm_pm_runtime_enable() unwinds.
  2. Reject unsupported PHY modes before touching boot_hold: dptx_phy_set_mode() now checks if (mode != PHY_MODE_DP && mode != PHY_MODE_INVALID) return -EINVAL; before taking dptx_phy->lock or clearing boot_hold.

Verification on 2667b1b9b3b3:

  • ./scripts/checkpatch.pl --strict --git HEAD~1..HEAD: 0 errors, 0 warnings, 0 checks.
  • Compiled drivers/phy/apple/dptx.o with W=1 (arm64, CONFIG_PHY_APPLE_DPTX=y): 0 warnings.
  • Live hardware check on J775c was previously run at fdd99f79 (identical runtime path for valid DP/INVALID mode switches); a re-boot on 2667b1b9b3b3 is not yet run.

@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 2667b1b9b3b3 against pre-pr-checklist.md (§1–§6):

0 code/policy/attribution/CI blockers at 2667b1b9; ready to flip to APPROVE once the exact-head §5 hardware row lands.

Prior Blockers Cleared

  • §3 (boot_hold runtime-PM refcount leak on probe failure/defer or early unbind): Cleared — dptx_phy_probe() registers devm_add_action_or_reset(dev, dptx_phy_drop_boot_hold, dptx_phy) immediately after devm_pm_runtime_enable(dev), so devres LIFO unwinding balances boot_hold under dptx_phy->lock via pm_runtime_put_noidle(dev) before pm_runtime_disable(dev) on devm_phy_create() (-EPROBE_DEFER), devm_of_phy_provider_register(), t6050_probe() failure, or early unbind.
  • §3 (Unsupported mode dropping boot_hold): Cleared — dptx_phy_set_mode() now rejects modes other than PHY_MODE_DP / PHY_MODE_INVALID with -EINVAL before taking dptx_phy->lock or clearing boot_hold.

Checks Passing

  • §1 / §2 / §3 / §6: Uses existing DPTX_PHY_T6050 variant match data, default cmdline, balanced runtime-PM references across all activate/deactivate/error paths, and t6050_reconfigure() guards MMIO access behind phy->active.
  • §4 Attribution: Single squashed commit 2667b1b9b3b3 with human author/committer and human Signed-off-by: only; zero AI commit trailers; Assisted-by: present in PR body.
  • CI: host-tests green on 2667b1b9b3b3.

Remaining Before APPROVE

  • §5 Evidence: Exact-head J775c hardware verification row on 2667b1b9 (early-boot dptx-phy genpd state, DPMS off/on off-0/on cycles, s2idle, and 0 SELinux denials / 0 failed units / 0 new kernel errors). (Non-blocking hygiene: updating the PR body's "after a successful t6050_deactivate()" phrasing and adding J575c / J775d die-1 under "Not covered" as noted in comments would keep the description aligned with the code.)

Assisted-by: LLM (Gemini 4 Neon)

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