Skip to content

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

Open
satchlj wants to merge 2 commits into
integration/aurorafrom
satchlj/dptx-t6050-runtime-pm-20261122
Open

satchlj wants to merge 2 commits 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)

The T6050 DPTX PHY powers its PLL, lanes and AUX block up when the DCP
sets DP mode (t6050_activate()), and down again on PHY_MODE_INVALID
(t6050_deactivate()). Its power domain stayed on throughout, however,
because the driver never enabled runtime PM. On J775c the dptx_phy
domain therefore reads "on" after DPMS off, although the DCP has
released the link and the PHY's blocks are down.

Enable runtime PM for the T6050 variant. An active link holds a
reference, taken before t6050_activate() and dropped after a successful
t6050_deactivate(); a failed activation drops it again. With that, genpd
can power the domain off while the display is off. The T6020 path, which
has its own power handling, is unchanged.

Signed-off-by: Satya Benson <satya@benson.earth>
@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)

…e link

Three fixes to the previous commit's reference handling, plus one lock:

- t6050_deactivate() powers the PHY down and clears ->active even when
  t6050_pll_power_down() fails, but the INVALID path dropped the link's
  reference only when deactivation returned 0. One PLL error leaked it
  for good, and ps_dptx_phy could never suspend again. Drop it whenever
  the link was active.

- A failed runtime-PM put after the PHY is already down overrode the
  return value. phy_set_mode_ext() then reports the switch as failed and
  keeps attrs.mode at DP for a PHY that is off. Report the put failure
  with dev_warn() instead.

- Between probe and the DCP's first mode switch nothing held the domain:
  the device was suspended with a zero usage count, so genpd's unused
  power-off could turn ps_dptx_phy off under a link the boot loader left
  up for simplefb, if the DCP probes late, defers or fails. Probe now
  marks the device active with a reference of its own (boot_hold), which
  the first mode switch drops after it has taken the link's.

- ->active is now read under dptx_phy->lock for the "already active"
  early return too, like every other access.

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

@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)

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