Skip to content

drm/apple: power off idle firmware-27 external display processors - #3308

Closed
erikwb wants to merge 3 commits into
feat/apple-dart-display-dark-drainfrom
feat/dcp-v27-ext-idle-off
Closed

erikwb wants to merge 3 commits into
feat/apple-dart-display-dark-drainfrom
feat/dcp-v27-ext-idle-off

Conversation

@erikwb

@erikwb erikwb commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: Power off unattached Type-C-only firmware-27 external display processors (dcpext) after 5 seconds of inactivity once no Type-C route, cable, display connector, or Type-C background work is active, waking synchronously on display attach or system suspend. Stacked on #3307 (feat/apple-dart-display-dark-drain). On main, this remains gated by dcp_s2r_ext_capable() (requiring s2r_ext and either a DT power layout or appledrm.s2r_untested) until J713 v27.2 external display support lands.
Tested: Built drivers/gpu/drm/apple/{iomfb,iomfb_v27,iomfb_h17p,iomfb_v26_6_desktop,dcp,dcp-fabric}.o (ARCH=arm64 LLVM=1 W=1, 0 warnings), strict checkpatch.pl (0 errors, 0 warnings, 0 checks), tools/asahi/backlight-coldboot-tests.py PASS, and tools/testing/selftests/drivers/gpu/apple-dcp/run.py host suite PASS at 05d728d91d68. Hardware-verified on J713 (M4 MacBook Air, macOS 27.2 firmware, default cmdline, s2r_untested=N) in a combined trial build merging j713-dcpext/air-dcpext-272 (7a8022a6d24d) with #3297 (2b1bab104938), #3300 (6a84c1d95460), #3307 (eab8b5157340), and #3308 (05d728d91d68): both 286e00000.dcp and 48ae00000.dcp powered off in 1 ms after boot, woke in 1 ms on pm_test=devices deep suspend, recovered cleanly across refused-sleep power cycle, and re-gated in 1 ms after resume (0 warnings/errors, 0 failed units).
Risk: two-way door · Type-C-only firmware-27 external display processors with s2r_ext (currently gated behind dcp_s2r_ext_capable() on main).
Not yet: External Type-C/Thunderbolt display hotplug wake from idle-off and full hardware S2R wake cycle on J713; verification on T8142; retarget base to main once #3307 merges.

Details
  • Introduces an explicit idle state machine (DCP_EXT_IDLE_ON, OFF, FAILED, CLOSED) under ext_idle_lock strictly inner to dcp_typec_fabric_lock, scoped to dcp_ext_idle_capable(dcp) pipelines (dcp_s2r_ext_capable(), DCP_FIRMWARE_V_27_0, DRM_MODE_CONNECTOR_USB, !hdmi_hpd).
  • Tracks idle admission pause via a dedicated ext_idle_paused flag under hpd_mutex (avoiding dcp_disable_typec_work() / dcp_enable_typec_work() disable-depth imbalance) and checks pending Type-C work non-blockingly before quiescing.
  • Adds dcp_push_try() so pre-send A500 queue allocation failure (-ENOMEM) releases wait-cookie references without marking dcp->crashed, allowing DART reopen and deferral.
  • Darkens and drains display and DCP DARTs before sending A500, polls iomfb_channels_idle() before RTKit stop, aborts before lowering domains if stream shutdown fails, tracks ext_idle_domains_off strictly from the first power-control write until domains and DARTs are confirmed restored, and wakes idle-gated pipes before system suspend or component unbind/remove.
  • Re-arms idle power-off after route deactivation, failed route activation, and PM_POST_SUSPEND.
  • Note: on main, J713 uses the iomfb_m4.c external DCP path and its firmware-27 profile does not enable s2r_ext, while T8142 external profiles still require appledrm.s2r_untested. Once J713 v27.2 external display support lands (as verified in the j713-dcpext/air-dcpext-272 trial build), this path activates automatically on the default command line with the DT power layout.
Evidence
  • make O=build/j713 ARCH=arm64 LLVM=1 W=1 M=drivers/gpu/drm/apple iomfb.o iomfb_v27.o iomfb_h17p.o iomfb_v26_6_desktop.o dcp.o dcp-fabric.o — 0 errors, 0 warnings
  • scripts/checkpatch.pl --strict --no-tree — 0 errors, 0 warnings, 0 checks
  • python3 tools/asahi/backlight-coldboot-tests.py — PASS
  • tools/testing/selftests/drivers/gpu/apple-dcp/run.py --group quiesce --group lifecycle — matches origin/main baseline
  • J713 (M4 MacBook Air, macOS 27.2 firmware, default cmdline, s2r_untested=N, j713-dcpext/air-dcpext-272 7a8022a6d24d + pmdomain: apple-pmc: resolve display interfaces via consumer-switched power-domains #3297 2b1bab104938 + drm/apple: toggle display pipe PMC interfaces across S2R domain transitions #3300 6a84c1d95460 + iommu/apple-dart: drain TLB flushes and fault IRQs when display DART goes dark #3307 eab8b5157340 + drm/apple: power off idle firmware-27 external display processors #3308 05d728d91d68):
    • Initial idle power-off at t=6.11s:
      • apple-dcp 286e00000.dcp: display domains off: CPU 0xf000300 FE 0x2300 SYS 0x2100
      • apple-dcp 286e00000.dcp: dcpext idle: powered off in 1 ms
      • apple-dcp 48ae00000.dcp: display domains off: CPU 0xf000300 FE 0x2300 SYS 0x2100
      • apple-dcp 48ae00000.dcp: dcpext idle: powered off in 1 ms
    • pm_test=devices deep suspend/resume cycle:
      • Both pipes woke from idle-off in 1 ms (dcpext idle: woke in 1 ms), stopped cleanly for sleep (firmware stopped for sleep: control 0x0 status 0x6e), completed refused-sleep power-cycle recovery (sleep refused: firmware back after a power cycle: 0), and re-gated automatically 5 s after resume in 1 ms each.
    • 60 s unplugged battery idle (apple-panel-bl 150/500, 30 samples @ 2 s): avg -3.921 W (min -3.962 W, max -3.853 W) vs -4.084 W avg (floor -3.943 W) on daily 7.3.0-j713-272tb without idle gating. 0 failed systemd units, 0 kernel warnings/errors.

Power off unattached Type-C-only firmware-27 external display processors
(dcpext) after 5 seconds of inactivity once no Type-C route, cable,
display connector, or Type-C background work is active.

Use an explicit idle state machine (ON, OFF, FAILED, CLOSED) serialized
under ext_idle_lock strictly inside dcp_typec_fabric_lock and scoped to
idle-capable pipelines:
- dcp_ext_idle_wake() never blocks on cancel_delayed_work_sync() while
  holding fabric locks, and dcp_ext_idle_off_work() checks pending Type-C
  work non-blockingly under hpd_mutex without calling
  dcp_disable_typec_work(), avoiding fabric/worker lock inversions and
  workqueue disable-depth imbalance.
- Poll iomfb_channels_idle() after A500 instead of an unconditional sleep,
  restore admission on pre-send A500 allocation failure (-ENOMEM), abort
  before cutting power if quiescence or DART stream shutdown fails,
  recover only domain power-off failures via dcp_s2r_ext_cycle(), latch
  FAILED across subsequent wake attempts and dcp_poweron(), and reconcile
  state on a successful sleep restart.
- Initialize ext_idle state early at probe, close admission (waking an
  idle-gated pipe before unbind/remove tears down resources) on component
  unbind, platform remove, and shutdown, and wake an idle-gated pipe
  before system suspend so DART PM never accesses registers while the
  display domains are powered off, re-arming the idle timer on resume.

On main, this remains gated by dcp_s2r_ext_capable() (currently requiring
s2r_ext and s2r_untested on firmware-27 external processors) until J713
v27.2 external display support lands.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team and DjDeveloperr as code owners November 26, 2026 20:18
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (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) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 944b0ba7: not ready yet

Check Detail
CI at head ok 1 check passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 944b0ba7
Conflicts ok none
PR text ok Risk: two-way · Type-C-only firmware-27 external display processors with s2rext (currently gated behind dcps2rextcapable() on main).

Areas: area:display, area:gpu

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

…in' into feat/dcp-v27-ext-idle-off

# Conflicts:
#	drivers/gpu/drm/apple/dcp.c
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 27, 2026
@sithglan

Copy link
Copy Markdown
Contributor

Hardware verification row on J813 (M5 MacBook Air 13-inch, T8142, macOS 27.2 firmware, appledrm.s2r_untested=1) at exact PR head 944b0ba788d2 (carrying #3307 9dd8b87b003c): PASS.

  • Kernel: 7.3.0-aurora-j813-pr3308+ built at exact head 944b0ba788d2 (booted via one-shot aura-try; note: btcentauri preloaded before rom_boot=3 in n1-up to avoid the pre-#3373 fn2 BAR0 SError on main).
  • Idle power-off + two real deep sleep/wake cycles (t8142_wake_s=8, echo mem > /sys/power/state, SUSPEND_RC=0 on both, boot object resumes 0 -> 1 -> 2):
  • Health: 0 DART/IOMMU faults, 0 new kernel warnings or errors across both sleep/resume cycles, 0 failed systemd units.

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

Review at 944b0ba788d2: READY on the code, 0 blockers. Commenting for now rather than approving: the hotplug-wake row and post-retarget build CI are still owed (below). This PR is stacked on #3307 and merges after it. Build CI has not run here because the base is the feature branch.

  • Gating: dcp_ext_idle_capable() needs dcp_s2r_ext_capable(), firmware 27, a USB-C connector and no HDMI HPD. So on main this stays off by default, as the body says.
  • Locking:
    • The order is fabric lock → ext_idle_lock → hpd_mutex. The route activate and apply paths call dcp_ext_idle_wake() under the fabric lock, and the wake takes hpd_mutex inside ext_idle_lock.
    • The off-work never takes the fabric lock (only HDMI and mux callbacks do).
    • Route deactivate kicks without holding hpd_mutex.
    • Close and suspend drop ext_idle_lock before cancel_delayed_work_sync(), and wake uses the non-sync cancel under the lock. No inversion that I can see.
  • Power-off sequence:
    • It checks for pending Type-C work without blocking (work_busy()).
    • It pauses presentation, then darkens the display and DCP DARTs (and reopens both on any entry error).
    • It sends A500, polls iomfb_channels_idle(), then stops RTKit and the streams, and only then lowers the domains.
    • A domain power-off failure restarts through dcp_s2r_ext_cycle(). Every other failure latches FAILED with crashed.
  • dcp_push_try(): it hands back the queue error without calling the callback, so the two kref_put()s on -ENOMEM balance the wait cookie.
  • Wake:
    • Display attach (dcp_dptx_connect*(), route activate), dcp_poweron(), system suspend, unbind, remove and shutdown all wake or close the pipe.
    • Resume, PM_POST_SUSPEND and route deactivate re-arm the idle timer.
  • Checks: checkpatch.pl --strict is 0/0/0. The commit is signed off, with no attribution, and it merges cleanly onto main with #3307.
  • CI: 2/2 checks pass. The Apple build and KUnit don't run on a PR against a feature branch. sithglan's exact-head J813 kernel (7.3.0-aurora-j813-pr3308+) is the build evidence.
  • Question, not blocking: once a pipe is FAILED with ext_idle_domains_off set, dcp_ext_idle_suspend() returns ext_idle_err ?: -EIO on every later system sleep. A single failed idle power-off then keeps the Mac awake until reboot. If refusing sleep is the intent (so DART PM never touches powered-off registers), a log line saying so would help whoever hits it.
  • Hardware: the J813 (T8142, s2r_untested=1) row at this head covers idle power-off, two deep sleep cycles and re-gating after resume.
  • Owed before merge:
    • Hotplug wake from idle-off: attach a USB-C or Thunderbolt display while the pipe is gated, check it lights, unplug and check it re-gates. This is the main path the feature adds, and the PR's Not yet lists it.
    • Build CI: after #3307 merges and this PR is retargeted to main.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 27, 2026
@RyanTheTide
RyanTheTide deleted the branch feat/apple-dart-display-dark-drain November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (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.

4 participants