Skip to content

drm/apple: enable v27 static-frame idle caching on T8122 - #4242

Merged
satchlj merged 3 commits into
aurora-silicon:mainfrom
satchlj:feat/t8122-v27-idle-cache
Dec 3, 2026
Merged

satchlj merged 3 commits into
aurora-silicon:mainfrom
satchlj:feat/t8122-v27-idle-cache

Conversation

@satchlj

@satchlj satchlj commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

What: Enable firmware-27 static-frame idle caching (v27_idle_cache) on apple_dcp_hw_t8122 (follow-up to #3289) and reset idle-cache state in dcp_v27_early_restart() before apple_rtkit_warm_restart() so idle caching re-negotiates cleanly after deep sleep.
Tested: J613 MacBook Air 13" M3 (T8122, os-fw 27.2 / 26B123) at 7894c2968b26 (identical drivers/ tree to hardware-tested 54aa91b4e4aa; 7894c2968b26 only adds v27_idle_cache to the boot.py host-test stub) on the default kernel command line: boots cleanly, 0 failed units, 0 new kernel errors; v27_idle_cache enters state 4 (mem=51117696 host=0) and exits cleanly on frame activity; same-machine A/B static-frame idle power delta at backlight 59/525 (AC): Total System -57 mW (2.687 W -> 2.63 W), AC Input -58 mW (2.688 W -> 2.63 W), Heatpipe -65 mW (838 mW -> 773 mW); 2/2 15 s RTC deep-sleep cycles (rtcwake -d rtc1 -m mem -s 15), including suspending directly from active state 4, with clean post-wake state-4 re-entry (replays=5) and camera / /dev/accel/accel0 intact; tools/testing/selftests/drivers/gpu/apple-dcp/run.py --group boot 6/6 PASS (v27-panel-handoff ok).
Risk: two-way door · M3 (T8122) internal panels running firmware 27.x, plus any Mac using dcp_v27_early_restart()
Not yet: Other T8122 boards (J504/J513/J615); T8122 systems on firmware 14.x (25G83, gated off by fw_compat == DCP_FIRMWARE_V_27_0); long-duration battery rundown with idle caching active.

Details
  1. drm/apple: reset v27 idle-cache state on early-stop firmware restart (88c2916a1daa): dcp_v27_early_restart() cold-restarts the DCP firmware after power-down via apple_rtkit_warm_restart(), matching dcp_v27_warm_restart(). Calling iomfb_v27_idle_cache_reset(dcp) before the restart clears v27_idle_method_set, v27_idle_registered, v27_idle_state, and v27_idle_fences so applyProperty(138, 2) is re-negotiated with the restarted firmware after deep sleep instead of stalling on stale pre-sleep state.
  2. drm/apple: enable v27 static-frame idle caching on T8122 (54aa91b4e4aa): Sets .v27_idle_cache = true on apple_dcp_hw_t8122. Because dcp_v27_idle_cache_supported() checks dcp->fw_compat == DCP_FIRMWARE_V_27_0, T8122 machines running older firmware remain unaffected.
  3. selftests: apple-dcp: declare v27_idle_cache in v27_panel_handoff stub (7894c2968b26): Adds v27_idle_cache to the local struct apple_dcp_hw_data stub in tools/testing/selftests/drivers/gpu/apple-dcp/boot.py so v27-panel-handoff compiles against apple_dcp_hw_t8122.
Evidence
  • Head SHA: 7894c2968b26 (base 7303d70ea68d, 3 commits; git diff 54aa91b4e4aa..7894c2968b26 -- drivers/ is empty)
  • Host checks:
    • scripts/checkpatch.pl --no-tree: 0 errors, 0 warnings on all 3 commits
    • python3 tools/asahi/dcpext26-startup-tests.py: PASS
    • python3 tools/testing/selftests/drivers/gpu/apple-dcp/run.py --group boot: 6/6 PASS (ok 3 - v27-panel-handoff)
  • Hardware run (J613 M3 Air, T8122, os-fw 27.2 / 26B123, default cmdline, s2idle [deep], 0 failed units):
    • Static-frame A/B on the same machine, same static login screen, same backlight 59/525, AC power (10 × 1 s macsmc_hwmon samples after 3 s settle):
      Metric Control (v27_idle_cache=false, dc68a27f33d8) Patch (54aa91b4e4aa, state 4 active) Delta
      Total System Power (median) 2.687 W (2.674–2.701 W) 2.63 W (2.62–2.64 W) -57 mW
      AC Input Power (median) 2.688 W (2.674–2.701 W) 2.63 W (2.62–2.64 W) -58 mW
      Heatpipe Power (median) 838 mW (773–902 mW) 773 mW (773–838 mW) -65 mW
    • Dynamic debug trace (file iomfb_v27.c +p) across initial entry, resume, deep sleep cycle 1, and deep sleep cycle 2 (entered directly from active state 4):
      [   45.911164] apple-dcp 28ec00000.dcp: v27 idle cache state 0 -> 1 (mem=0 host=0 replays=0)
      [   45.911256] apple-dcp 28ec00000.dcp: v27 idle cache state 1 -> 2 (mem=51117696 host=0 replays=0)
      [   45.938106] apple-dcp 28ec00000.dcp: v27 idle cache active (mem=51117696 host=0)
      [   58.488229] apple-dcp 28ec00000.dcp: v27 idle cache state 4 -> 0 (mem=51117696 host=0 replays=1)
      ...
      [  168.120069] PM: suspend entry (deep)
      [  169.290166] apple-dcp 28ec00000.dcp: V27 sleep: internal DCP stop: ...; result 0
      [  169.436058] apple-dcp 28ec00000.dcp: V27 wake: firmware back after the sleep: ... plain-on 0@23
      [  175.982464] PM: suspend exit
      [  202.350608] apple-dcp 28ec00000.dcp: v27 idle cache state 0 -> 1 (mem=51117696 host=0 replays=2)
      [  202.350699] apple-dcp 28ec00000.dcp: v27 idle cache state 1 -> 2 (mem=51117696 host=0 replays=2)
      [  202.380816] apple-dcp 28ec00000.dcp: v27 idle cache state 2 -> 4 (mem=51117696 host=0 replays=3)
      [  205.864230] apple-dcp 28ec00000.dcp: v27 idle cache state 4 -> 0 (mem=51117696 host=0 replays=3)
      [  236.430787] apple-dcp 28ec00000.dcp: v27 idle cache state 2 -> 4 (mem=51117696 host=0 replays=4)
      [  238.712479] PM: suspend entry (deep)
      [  238.797541] apple-dcp 28ec00000.dcp: v27 idle cache state 4 -> 0 (mem=51117696 host=0 replays=4)
      [  239.584242] apple-dcp 28ec00000.dcp: V27 sleep: internal DCP stop: ...; result 0
      [  239.730335] apple-dcp 28ec00000.dcp: V27 wake: firmware back after the sleep: ... plain-on 0@23
      [  241.069761] apple-dcp 28ec00000.dcp: v27 idle cache state 0 -> 1 (mem=51117696 host=0 replays=4)
      [  241.069849] apple-dcp 28ec00000.dcp: v27 idle cache state 1 -> 2 (mem=51117696 host=0 replays=4)
      [  241.092243] apple-dcp 28ec00000.dcp: v27 idle cache state 2 -> 4 (mem=51117696 host=0 replays=5)
      [  246.253250] PM: suspend exit
      [  250.442373] apple-dcp 28ec00000.dcp: v27 idle cache state 4 -> 0 (mem=51117696 host=0 replays=5)
      

In dcp_v27_early_restart(), the display coprocessor firmware is
cold-restarted after power-down, just as in dcp_v27_warm_restart().
Reset the firmware-27 idle-cache state (including v27_idle_method_set,
v27_idle_registered, v27_idle_state, and v27_idle_fences) before
apple_rtkit_warm_restart() so applyProperty(138, 2) is re-negotiated
with the restarted firmware and idle caching does not stall on stale
pre-sleep state after deep sleep.

Signed-off-by: Satya Benson <satya@benson.earth>
Enable hw.v27_idle_cache on apple_dcp_hw_t8122 so T8122 internal panels
running firmware 27.x participate in static-frame idle caching
("replay"). Older firmware profiles (14.x / 25G83) remain unaffected
because dcp_v27_idle_cache_supported() gates on
fw_compat == DCP_FIRMWARE_V_27_0.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj requested review from a team as code owners December 3, 2026 22:45
@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (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 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Merge readiness at 7894c296: not ready yet

Check Detail
CI at head ok 10 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 7894c296
Conflicts ok none
PR text ok Risk: two-way · M3 (T8122) internal panels running firmware 27.x, plus any Mac using dcpv27earlyrestart()

Areas: area:display

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

v27_panel_handoff() extracts apple_dcp_hw_t8122 from dcp.c and compiles
it against a local struct apple_dcp_hw_data stub. Declare v27_idle_cache
in that stub so the host test compiles after enabling v27_idle_cache on
apple_dcp_hw_t8122.

Signed-off-by: Satya Benson <satya@benson.earth>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 3, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 7894c29

Checked: The reset runs only on the existing stopped-DCP path after power and DART restoration, immediately before RTKit restart. The rollback path refuses to power-cycle while RUN remains set. The reset invalidates the old cache state under the idle lock and adds no retry, loop, or firmware operation. An active DCP skips this branch.

Checked: Idle caching still requires the firmware-27 interface, a matching hardware capability, the main display, and an internal panel. The T8122 change is a SoC capability with no board-name conditions, and the corresponding host-test fixture declares the capability field.

Checked: Exact-head Host tests, Apple build, and display KUnit passed. The authored J613 receipt reports resume and cache re-entry after both deep cycles. Verified that the hardware-tested commit and this head differ only in the host-test fixture.

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

Approving at 7894c29. The review-lane App review at this head covers the code (idle-cache ordering vs DCP power-state changes, early-restart reset path, SoC scoping); J613 exact-head row is the hardware evidence. This adds the code-owner approval the branch rules need.

@satchlj
satchlj merged commit 89ec99a into aurora-silicon:main Dec 3, 2026
14 checks passed
@satchlj
satchlj deleted the feat/t8122-v27-idle-cache branch December 3, 2026 23:30
@RyanTheTide

Copy link
Copy Markdown
Contributor

J615 (MacBook Air 13" M3, T8122), firmware 27.2, exact head 7894c2968b26 vs its base 7303d70ea68d: PASS. State-4 replay is entered and re-entered after deep wakes, with 0 DCP crashes. No idle-power difference was measurable on this Mac.

  • Kernels: 7.3.0-mrp4242 (head) and 7.3.0-mrp4242base (merge base with main), same config, no other patches, each with its own t8122-j615.dtb (identical bytes in both trees). One-shot boots via aura-try; saved default unchanged. Same Stage 2 for the deep and power rows: aura 1.0.0b19-24-gffaa715a (contains aura#659, the T8122 S2R wake fix). Method: dynamic debug on iomfb_v27.c (v27 idle cache state A -> B) plus kprobes on the idle-cache functions.
  • Replay (head): a static desktop enters 0 -> 1 -> 2 -> 4 about 1 s after the last frame (mem=64419456 host=0). New content exits it (4 -> 0); it re-enters about 1 s after content stops. surface_span returned 1 for every present. No v27 idle warnings, 0 DART faults.
  • Sleep (head, boot a28596f4): s2idle +1. deep x2 (rtcwake -d rtc1 -m mem -s 20, apple-pmu-rtc): success +1 each, fail 0, resume 0.408 s / 0.411 s, and state 4 re-entered about 1 s after each wake (2 -> 4 at +1.0 s and +1.6 s after PM: suspend exit). 0 DCP crash/panic/watchdog lines, 0 DART faults.
  • Idle power (static GNOME desktop, backlight 200/500, AC, battery full; SMC Total System Power, 90 x 1 s): head 11,302 mW median (p10–p90 11,124–11,336); base 11,225 mW (11,206–11,407); an earlier head boot read 11,164 mW. That is a −61 to +78 mW spread. A saving of the size seen on the M4 Air (about 0.1 W) would be inside the noise at this Mac's 11 W AC-side reading, so this row neither shows nor rules out a saving. A battery coulomb-count A/B would be needed for that.
  • Earlier first attempt (not this PR): with the older Stage 2 aura 70d844e3, which lacks aura#659, the first deep sleep of the head boot reset the Mac (boot 4fa414f7, the journal ends at suspend entry). The same head kernel then passed 2/2 deep on the Stage 2 that has wifi: mt7932: WPA2 PMF with PSK-SHA256 and 6 GHz LPI with J700 TPE projection #659, and this morning the same Mac passed deep 2/2 on main with that Stage 2 as well. So the reset belongs to the old Stage 2, not to this change.

Afterwards the Mac went back to its production default (7.3.0-aurora-edge, Stage 2 b18 unchanged, Enforcing, 0 failed 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.

Reviewed at 7894c29 (this landed as 89ec99a while the review was running). The code is right.

Reset in the early restart. The reset sits inside if (e->stopped), after the DARTs are back and before apple_rtkit_warm_restart(). So it only runs when the firmware really was stopped and power-cycled, the same as dcp_v27_warm_restart() and dcp_s2r_warm_restart() already do. Nothing races it:

  • The PM suspend calls iomfb_v27_idle_cache_cancel() before dcp_v27_early_suspend(). That closes admission, cancels the work with _sync and drains iomfb.lock.
  • During resume no swap or modeset can reach the DCP before the CRTC comes back.
  • The reset also clears template_valid, so re-entry waits for a new displayed frame. That is the 0 -> 1 -> 2 -> 4 after each wake in your trace.
  • The second RTKit cycle in dcp_v27_early_calls_on() (soft-off wakes) runs before any present, so it needs no second reset.
  • If the restart fails (goto lost), the cleared state does no harm: the DCP is marked crashed, its CRTC resumes off, and the next sleep power-cycles it.

T8122 flag. It is match data on the DCP's own compatible, the same as T8132, and fw_compat == DCP_FIRMWARE_V_27_0 keeps 14.x off. Side effect worth knowing: dcp_caches_scanout() now returns true on T8122 27.2, so front-buffer drawing goes out through swaps, as it already does on J773g. There is no runtime switch, module parameter, magic constant or ADT value.

Checks on the merge with main.

  • Hosted CI ran on the merge ref 764a052 (main a0e5cf1 + this head): build, DCP KUnit, host tests 1127/1127.
  • Locally, main vs merge: apple-dcp selftests 102/102 on both (v27-panel-handoff ok) and dcpext26 PASS on both.
  • W=1 of drivers/gpu/drm/apple with the J516s config: the same 2 warnings on both, both already on main, none in the touched files.

Still owed (after the merge): a J516s row. dcp_v27_early_restart() also runs on T6030 (v27_early_stop), so every J516s deep wake now runs this reset. Idle caching stays off there and the reset should be a no-op, but the merge rule wants a second-SoC row. We built a J516s A/B kit (main vs main + this PR, 2 deep sleeps each) and handed it to our M3 Pro lead. We'll post the result here.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

J516s (M3 Pro, T6030, OS firmware 27.2) second-SoC post-merge A/B verification for linux#4242 (7894c2968b26aa04d90b2b0bbddde3fa6b5ab7a7, merged 764a05273051310288674fca9bd4bd1ef2282f11 on a0e5cf1511594d92320a9fb11bd3d0948a2c35ad): HARDWARE PASS (3/3 committed deep sleeps per arm, identical A vs B; 0 DCP/WARN/SError lines)

Builds & boots

  • Arm A (main a0e5cf151159): 7.3.0-j516s-r4242a, build-id e521c5eea8f7c580163e34046e8627a6072c0735, trial Stage 2 m1n1/m3r4242.bin (fecc5a1a…, t6030-j516s.dtb), boot 63f77492-ff9f-4242-8165-132b29a609e8.
  • Arm B (main + #4242 764a05273051, head 7894c2968b26): 7.3.0-j516s-r4242b, build-id 403afc05f2fe5eae212b4de4682ff3d6ac091d51, same trial Stage 2/DTB, boot bc0b06cf-c2f0-4ac3-a97a-b9bd01f83bfe. Only the PR's 3 files differ between A and B.

Results (2x rtcwake -d rtc0 -m mem -s 30 per arm)

  • Arm A (7.3.0-j516s-r4242a):
    • Pre-sleep: eDP-1 connected enabled On, crtc_active=1, backlight=25, kwin_wayland active.
    • Cycle 1: rtcwake_rc=0, suspend_stats success 0->1, apple-sleep: back from sleep, boot object resumes 0 -> 1, V27 sleep: internal DCP stop ... result 0, V27 wake: internal DCP stopped and restarted after A500-wake, V27 wake: firmware back after the sleep ... plain-on 0@84, panel connected enabled On, crtc_active=1, backlight=25, same boot.
    • Cycle 2: rtcwake_rc=0, suspend_stats success 1->2, included a dark wake (apple-drm: dark wake: outputs stay off) and re-sleep (resumes 1 -> 2 and 2 -> 3), both completing V27 sleep: internal DCP stop ... result 0 and V27 wake: firmware back after the sleep (plain-on 0@83, 0@84), panel connected enabled On, crtc_active=1, backlight=25, same boot.
    • 0 DCP/WARN/BUG/Oops/SError lines in window (bad-window.txt: 0 lines; 354 apple-dcp lines).
  • Arm B (7.3.0-j516s-r4242b):
    • Pre-sleep: eDP-1 connected enabled On, crtc_active=1, backlight=25, kwin_wayland active.
    • Cycle 1: rtcwake_rc=0, suspend_stats success 0->1, resumes 0 -> 1, V27 sleep: internal DCP stop ... result 0, V27 wake: internal DCP stopped and restarted after A500-wake, V27 wake: firmware back after the sleep ... plain-on 0@85, panel connected enabled On, crtc_active=1, backlight=25, same boot.
    • Cycle 2: rtcwake_rc=0, suspend_stats success 1->2, same dark-wake + re-sleep sequence (resumes 1 -> 2 and 2 -> 3), both completing V27 sleep: internal DCP stop ... result 0 and V27 wake: firmware back after the sleep (plain-on 0@84, 0@85), panel connected enabled On, crtc_active=1, backlight=25, same boot.
    • 0 DCP/WARN/BUG/Oops/SError lines in window (bad-window.txt: 0 lines; 354 apple-dcp lines).

Harness note

The row script flagged Cycle 2 on both arms solely because it checked exact +1 increments (stop1 == stop0 + 1, wake1 == wake0 + 1) rather than >= +1, whereas Cycle 2 executed two clean hardware deep-sleep/wake cycles (1->3, due to an intermediate dark wake) identically on A and B. All 3/3 early DCP stop/restart cycles per arm succeeded with result 0 and full panel/CRTC/backlight restoration.

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) blast:m3 Macs affected, from Merge risk (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.

3 participants