Repository navigation
drm/asahi: g14_v27_2: enable runtime idle power-off - #3218
Conversation
When the firmware power-controller calibration is present (root.has_pwr_controller()), publish the allow-off idle policy after the boot job and after warm restart from deep sleep so firmware powers the GPU down after fender_idle_off_delay_ms of inactivity instead of holding it powered continuously while idle. Track idle_off_allowed in State so sleep_prepare(), sleep_complete(), and stop() avoid redundant allow-off/keep-powered policy flips when runtime idle power-off is already active. Measured on J313 (M1 MacBook Air, T8103): lowers idle SoC power (PHPC) by 186-201 mW (1.074 W -> 0.873-0.888 W) with no regression in Borealis compute, rendering, s2idle, or deep sleep. Signed-off-by: Erik Bourget <[email protected]>
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at e4c0b4847713. No code blockers, but it needs the GPU power rows before merge.
Blockers (evidence, not code):
- G14G (M2 / T8112) is the main user of
g14_v27_2, and Not yet lists it as untested. Our M2 mini (J473) is that GPU on 27.2. Its 27.2 backend has a history of idle and sleep-transition hangs, which is why it keeps the GPU powered today. Before merge it needs a J473 row at this head: GB6 Vulkan back-to-back plusgpubenchvk+gl ≥ 8 loops and 10 fresh short-lived Vulkan clients, with idle gaps between them so the firmware actually powers off and back on. That means 0 timeouts and 0 firmware crashes, plus 3 s2idle wakes. The same soak on G13G (your J313) covers that generation. Our lab rule for GPU power/clock changes asks for that soak on each affected generation, and compute-check/render-check alone don't reach the power-off/power-on cycle often enough. - Please put the J313 idle-power numbers in the PR body as one row line with the head SHA:
J313 M1 Air at e4c0b484: ….
Checked:
- The behaviour keys on
root.has_pwr_controller(), the DT power-controller calibration, with no chip or firmware gate. idle_off_allowedis set once at backend start and used consistently:- deep-sleep prepare skips a redundant allow-off and passes
policy_publishedtoabort_deep_prepare(), so a refused sleep no longer restores keep-powered when runtime idle-off is on; sleep_complete()keeps the allow-off state;- warm restart goes keep-powered →
gpu_powered→ allow-off again; stop()skips the duplicate allow-off.
- deep-sleep prepare skips a redundant allow-off and passes
- The boot path sets the policy only after
boot_job_complete(), under its ownstepname in the start-failure log.
We'll queue the J473 row with the M2 GPU lane, which owns that Mac's 27.2 GPU work.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
…ower-off # Conflicts: # drivers/gpu/drm/asahi/g14_v27_2.rs
|
Merged |
There was a problem hiding this comment.
The new startup path propagates any error from enabling optional idle-off through the firmware boot result, although the boot job already completed. Show that a refusal cannot occur on healthy calibrated firmware, or continue in the previous keep-powered mode on a failure that occurs before publication. For an uncertain publication, retain a controlled failure unless you can establish the active policy. Add a test for this startup error path and the requested G14G M2 hardware row.
…blication Once keep-powered mode and the boot job have already succeeded, enabling optional runtime idle power-off uses try_set_idle_policy() and startup_idle_policy() to distinguish pre-publication failures from uncertain post-publication failures: - If publish_idle_policy(true) fails before writing the allow-off record to shared memory (published == false), warn and continue in the confirmed keep-powered mode (idle_off_allowed = false) instead of failing GPU startup or warm restart. - If a failure occurs after publication (send_message or wait), retain controlled teardown since the active firmware policy is uncertain. - Pass the resolved idle_off_allowed flag into Backend::start() and update State.idle_off_allowed across warm restart so sleep_prepare(), sleep_complete(), and stop() stay consistent with the active policy. - Add unit coverage for startup_idle_policy() in g14_v27_2_abi.rs. Signed-off-by: Erik Bourget <[email protected]>
|
Fixed the startup error path in
|
There was a problem hiding this comment.
Startup and warm restart now preserve confirmed keep-powered operation on a pre-publication failure and only take the teardown path when publication makes the policy uncertain. Checked the resolved flag reaches backend state and the reported J313 row. Code approved. G14G J473 coverage and required CI remain for landing.
|
Tested Host ABI tests ( On hardware, however, I hit a deterministic render timeout (2/2 boots) that does not occur on the unpatched base kernel: Repro on J413 (
|
|
Merged Thanks to
Local verification at
Hardware verification at
|
|
Merge-train note at |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 18c47950
Blockers:
- G14 firmware 27.2
allow-offhardware row (noted under**Not yet:**): Still needs a calibrated G14 (J473orJ413,T8112) run whereidle_off_allowed = trueis actually entered and left (idle power-off + GPU smoke after resume +s2idle+ 0 GPU faults), as well as the exact-headJ313(G13G) A/B once J313 is recovered. - Hosted CI at
18c47950: 20 queued CI jobs still need to finish green on this head.
Checked:
- Audited the forward merge
18c47950(origin/mainee36fbdcd1c8intoc9f59b98) and the full 2-file diff (drivers/gpu/drm/asahi/g14_v27_2.rs,drivers/gpu/drm/asahi/g14_v27_2_abi.rs,+163/-25); zero code blockers found. - Verified the conflict resolution in
g14_v27_2.rs::start()cleanly retainsgraph.kernel_uat().attach_firmware_window(window)from#3250beforeBackend::start(..., idle_off_allowed)?, preservingenable_optional_idle_off()'s pre-publication fallback tokeep-poweredand post-publicationFailUncertainteardown across startup and warm restart. - Verified
sleep_prepare(),sleep_resume(), andstop()honorstate.idle_off_allowedwithout redundant policy transitions or corruptingkeep-poweredfallback. - Verified PR text (
What/Tested/Risktwo-way door/Revert/Not yet) and unit teststartup_idle_policy_handles_calibration_and_publish_errors.
Evidence
drivers/gpu/drm/asahi/g14_v27_2.rs:start()attaches the firmware window tograph.kernel_uat()after the boot job and optional idle-off attempt succeed, then passesidle_off_allowedintoBackend::start().drivers/gpu/drm/asahi/g14_v27_2_abi.rs:startup_idle_policy()unit tests cover absent calibration, confirmed enable, pre-publication error (KeepPowered), and post-publication error (FailUncertain).
|
Merge-train re-review at |
…7-2-gfx-auto-pm Take #3218's current head, which now carries #3468, so this stack merges cleanly after both. Keep #3468's fabric/DCS busy reference next to this branch's ps_gfx auto-PM state. The try-bind host harness models the backend's State: give it the auto-PM state, from the real AutoPmState in g14_v27_2_abi.rs, and a host stub of set_gpu_auto_pm() like its fabric/DCS hooks, as the extracted sleep and restart paths now use both. Signed-off-by: Erik Bourget <[email protected]>
1e03faa to
18c4795
Compare
RyanTheTide
left a comment
There was a problem hiding this comment.
Re-reviewed at 18c4795. Since my last review the only author change is c9f59b9. Optional idle power-off now goes through startup_idle_policy(): a failure before the allow-off record is published keeps the confirmed keep-powered mode with a warning, and a failure after publication still tears down, because the firmware's policy is unknown then. The unit test covers all six cases. Warm restart re-applies the policy State had before and stores the resolved value, so sleep_prepare/sleep_complete/stop follow the active policy. The rest of the delta is the main merge-up (the 27.2 recovery work). Better than before (a pre-publication failure no longer fails GPU start) and it doesn't change the success path.
There was a problem hiding this comment.
Verdict: MERGE at 18c47950df2a
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Audited the forward merge 18c47950 (origin/main ee36fbdcd1c8 into c9f59b98) and the full 2-file diff (drivers/gpu/drm/asahi/g14_v27_2.rs, drivers/gpu/drm/asahi/g14_v27_2_abi.rs, +163/-25); zero code blockers found.
- Verified the conflict resolution in
g14_v27_2.rs::start()cleanly retainsgraph.kernel_uat().attach_firmware_window(window)from#3250beforeBackend::start(..., idle_off_allowed)?, preservingenable_optional_idle_off()'s pre-publication fallback tokeep-poweredand post-publicationFailUncertainteardown across startup and warm restart. - Verified
sleep_prepare(),sleep_resume(), andstop()honorstate.idle_off_allowedwithout redundant policy transitions or corruptingkeep-poweredfallback. - Verified PR text (
What/Tested/Risktwo-way door/Revert/Not yet) and unit teststartup_idle_policy_handles_calibration_and_publish_errors.
Follow-ups (not blocking): G14 27.2 allow-off row on J473/J413, J313 A/B, queued CI
Conflict in drivers/gpu/drm/asahi/g14_v27_2.rs: main added gpu_busy_held (PMGR busy reference) to State next to this branch's idle_off_allowed; both fields kept. The try-bind host-test harness copies State, so it gets idle_off_allowed (false) too. g14-v27-2 host tests 25/25 pass and the asahi driver builds.
|
Merged main in at 43793c2 (no change to this PR's own code). One conflict in |
RyanTheTide
left a comment
There was a problem hiding this comment.
The merge-up preserves both idle_off_allowed and gpu_busy_held and initializes the new field in the try-bind harness. The reported asahi build and 25/25 host checks cover the resolution.
|
Merging at |
What: Enable GPU firmware runtime idle power-off on the 27.2 backend whenever DT power-controller calibration is present (
root.has_pwr_controller()), falling back to keep-powered mode if enabling idle-off fails before publication.Tested: Host and ARM64 KUnit/compile checks passed at
18c47950df2a(see Evidence); prior J313 (G13G) run atc9f59b988c24passed Vulkan render/compute soak +s2idle×3 +deepS2R ×1. Prior J413 (T8112/G14G) testing by@satchljatc9f59b988c24hit a deterministic render timeout (2/2) onmaina40c5131071d1, then passed when stacked on#3414(which is now inmainee36fbdcd1c8), though@satchljconfirmed the fourapple,pwr-*DT calibration properties were absent on J413 so that passing#3414follow-up was keep-powered coverage (idle_off_allowed = false). Exact-head J313 isolated A/B verification at18c47950df2acould not complete after J313 stopped responding on the second deep-sleep cycle on baselinemain(needs-human, awaiting physical recovery).Risk: two-way door · M1/M2 Macs using the G14/G13G 27.2 GPU backend (
DRM_ASAHI_G14_V27_2).Revert:
git revert -m 1 <merge-commit>restores keep-powered mode on startup and warm restart; no persistent disk or firmware state is written.Not yet: J313 (M1 MacBook Air, T8103;
G13G) exact-head isolated A/B verification and idle-power A/B at18c47950df2a(could not complete in this pass because the J313 test machine stopped responding after the second deep-sleep cycle on baselinemainee36fbdcd1c8(needs-human, awaiting physical recovery); note also that baselines2idlehard-resets J313, so deep S2R with RTC wake is the working sleep path); calibrated G14G (M2 / T8112, J473) hardware soak exercisingallow-off(requested before merge: GB6 Vulkan +gpubenchvk+gl >= 8 loops + 10 fresh short-lived Vulkan clients with idle gaps + 3×s2idlewakes;t8112.dtsiandt8112-j473-fw27.dtsomit the fourapple,pwr-*DT properties soroot.has_pwr_controller()staysfalseunless the live DT supplies all four properties, and the passing J413/#3414run only exercised keep-powered mode); GB6 Vulkan andgpubenchvk+gl >= 8 loops on G13G (not installed on J313).Details
Previously
g14_v27_2left the GPU powered continuously after the boot job and only sent the allow-off idle policy when entering deep sleep or stopping the firmware.enable_optional_idle_off()(backed bytry_set_idle_policy(&root, &mut peer, true)andg14_v27_2_abi::startup_idle_policy()) afterboot_job_complete()instart()whenroot.has_pwr_controller()(self.graph.dyncfg.pwr.pwr_controller_from_dt) is true, and after warm restart insleep_complete()whenidle_off_allowedwas active.publish_idle_policy(true)fails before writing the control record to shared memory (published == false), log a warning and continue in the already-confirmed keep-powered mode (idle_off_allowed = false); if a failure occurs after publication (published == true, leaving the active firmware policy uncertain), retain controlled teardown viahalt_unowned()on startup and controlled runtime failure viafail_all()on warm restart.idle_off_allowedstate intoBackend::start()and updateState.idle_off_allowedacross warm restart sosleep_prepare(),sleep_complete()(refused deep sleep), andstop()stay consistent with the active policy, and passpolicy_publishedtoabort_deep_prepare().startup_idle_policy()indrivers/gpu/drm/asahi/g14_v27_2_abi.rs(run bytools/asahi/g14-v27-2-abi-tests.rsand KUnitasahi_g14_fw_queues).Evidence
18c47950df2a(merged withorigin/mainee36fbdcd1c8, including#3414and#3250):python3 -I tools/asahi/run-host-tests.py --only g14-v27-2: 12/12 passed (g14-v27-2-abi-testsincluding 25/25 unit tests withstartup_idle_policy_handles_calibration_and_publish_errors, plusg14-v27-2-fw-window-gc-testsand mutations).python3 -I tools/asahi/run-host-tests.py --only m3: 13/13 passed.make ARCH=arm64 LLVM=1 drivers/gpu/drm/asahi/(defconfig+arch/arm64/configs/asahi.config:CONFIG_DRM_ASAHI_G14_V27_2=y,CONFIG_APPLE_SOC_SLEEP=y): built cleanly.drivers/gpu/drm/asahi/.kunitconfig: 503 tests run, 499 passed, 4 skipped (CONFIG_UCLAMP_TASK/unrelatedasahi_fwidcases).18c47950df2a:G13G) exact-head isolated A/B vsmainee36fbdcd1c8was built and parity-checked but could not run in this pass because the J313 test machine stopped responding after the second deep-sleep cycle on baselinemain(needs-human, awaiting physical recovery). Note that baselines2idlehard-resets J313 (deep S2R with RTC wake is the working sleep path).T8112/ M2 MacBook Air 13",G14GB0, 8 active cores, firmware 27.2) testing reported by@satchljatc9f59b988c24:maina40c5131071d1(without#3414; timeout report): 6/6 short-lived Vulkan compute clients with 1.5 s gaps passed (mismatches=0), followed by a deterministic render timeout (2/2boots) on the first surfaceless EGL/GLES2 500-draw loop (TA retired=false fragment retired=true, failing GPU runtime withEIO/ENODEV), whereas unpatchedmaina40c5131071d1passed12/12(6×compute +6×render,0timeouts).#3414(97ca44dc, full controllerHwDataShared3init, now merged inmainee36fbdcd1c8) underneath#3218(passing follow-up, calibration check):30/30heavy full-ALU Vulkan compute dispatches (5.510 s),6/6batched EGL/GLES2 500-draw rounds (1.5 sgaps), and3/3 × 500individual render passes (1.5 sgaps) all passed (submitted=3048 completed=3048,0timeouts,0faults).@satchljreported that neithert8112.dtsi(t8112-j413-fw27) nor J413's ADT supplies the fourapple,pwr-*DT calibration properties required byroot.has_pwr_controller(), so#3218stayed in keep-powered mode (idle_off_allowed = false; post-workloadGPU PP1b628–653 mW, matching#3414alone at632–669 mW). This follow-up therefore establishes keep-powered coverage on J413, notallow-offcoverage.G13G) run atc9f59b988c24in batched candidateac44bee46ee4(main9e38a276dcb4; default cmdline, firmware 27.2):G13Gbound onrenderD128; 12/12 alternating fresh short-lived Borealis Vulkan clients with 1.5 s idle gaps: 6×render-check 1(0 mismatches) and 6×compute-check 1(881–924 runs/s); 5,431 verified submissions, 0 wrong, 0 timeouts, 0 recoveries.s2idle×3:GPU held for sleep: submitted=14438 completed=14438 pending=0, thenrunning=Ok(0) pending=0; post-wakecompute-check 2(1796 runs, 0 wrong) andrender-check 1PASS.deepS2R ×1:boot object resumes 0 -> 1,GPU firmware 27.2 back in 8633 us (commit idle=0 130 us, pending=0); post-wakecompute-check 2(1856 runs, 0 wrong) andrender-check 1PASS.G13G) rows (prior toc9f59b988c24, retained as historical reference):476b7343895d: 19/19 checks passed (Apple build and KUnit:apple-buildand 15KUnitsuites;Host tests;pr-text;pr-readiness).476b7343895d(batched candidate8963018bbcb1, DPMS-OFF, default cmdline; bundlesfeat/g14-v27-2-idle-power-off476b7343895dwith GPU busy tracking and PMGR fabric/DCS scalingf99e24abff54/f275697d1653, PCIe ASPM L1SS70033a174df9, zero-duty PWM RPM42a2c37fd846,opp-shared262e263dae4c, and T8103 display DART fixesdefba2698f51):PHPC) observation on8963018bbcb1:0.873–0.888 Wvs1.074 Won an earlier unrecorded baseline (-186 to -201 mW across the bundled candidate changes; bundled-power caveat: not an isolated measurement of this PR alone).12fresh short-lived Borealis Vulkan clients with1.5 sidle gaps:0timeouts,0firmware crashes.3xs2idlewakes:GPU held/released running=Ok(0).1xdeepS2R:boot object resumes 0 -> 1,GPU firmware 27.2 back in 6285 us.e4c0b4847713(default cmdline):compute-check 5:PASS: 4243 runs in 5.0 s, 0 with wrong results.render-check 2:PASS: 2 runs, 0 wrong.rtcwake -d /dev/rtc1 -m freeze -s 4+ post-wakecompute-check 2:PASS: 1366 runs in 2.0 s, 0 with wrong results.rtcwake -d /dev/rtc1 -m mem -s 6:back from sleep, boot object resumes 0 -> 1.