Repository navigation
drm/asahi: allow firmware-managed GFX idle power-off - #3697
Conversation
The shared G15/G16 runtime sends device-control opcode 0x0a with a zero argument at startup. This requests a wake and keeps the GPU on. On the G15S handoff the boot loader also forces the GFX power domain active while the GPU lacks a PMP supplier. When the kernel supplies that missing link, release the matching power-domain hold in the same changeset. At GPU admission check that PMGR permits automatic power and the runtime has a handoff guard for powered-register accesses. Release the bootstrap hold in the final policy command and persist the value for firmware re-import. Give the cores the longer of the two successive idle intervals and Fender the shorter interval. This keeps short gaps between submissions warm while retaining the full-domain idle budget. On J773g the domain gated at about 42 ms in 16/16 post-fence windows and the 2 ms and 20 ms wake latencies returned to their control levels. Signed-off-by: DjDeveloperr <hey@djdev.me>
Admission decides whether the domain can idle. Only InitData setup and the final boot control consume that decision. Pass it directly to both steps. Keeping a copy in the firmware graph changed field offsets in the submission, polling and retirement paths even though they never read that flag. Signed-off-by: DjDeveloperr <hey@djdev.me>
Autonomous GFX idle also stops the firmware notifications that drive GPU housekeeping. On J773g the package stayed at 50-58 C, but the driver took just one cooling sample over eight seconds and kept the startup ceiling at S1. The first workload then spent 1.4-1.8 seconds qualifying for the top state. Arm the existing idle worker when the admitted GPU can idle and uses PMP cooling. Collect real provider readings at the thermal polling cadence while the startup backstop can still relax. Stop the extra polls on a sensor error, a warm reading, or once the independent backstop reaches the governor demand. Keep the normal protection and time checks and require a live reading for these startup observations. Signed-off-by: DjDeveloperr <hey@djdev.me>
Signed-off-by: DjDeveloperr <hey@djdev.me>
The supplier harness compiles the production display-gate link helper. Model the OF lookup and removal APIs used to drop the GFX hold when adding the missing PMP link. Exercise the handoff path and check that an existing supplier or a tree without the handoff retains the hold. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Superseded 12-01: not a hold under the merge bar (no shown failure). Only commit series checked, no code affirmation; follow-ups: queued CI, confirm exact-head or zero driver delta rows
Verdict: HOLD at c53b7255
Blockers:
- CI checks are still queued at
c53b7255.Host tests,Apple build and KUnit,PMGR power state KUnit, andSEP source checksare still queued (pr-textandpr-readinesspassed). - Hardware rows predate the
bff1fbd8merge andc53b7255head. The J773g/G16G (40178c02) and J516s/G15S (98d103b8) rows predate mergingorigin/main(bff1fbd8) and addingc53b7255; please confirm exact-headc53b7255(or verify zero driver delta since40178c02once CI finishes green).
Checked:
- Commit series (
98d103b8..c53b7255, 15 files,+233/-35),MERGEABLEagainstmain.
Evidence
- Waiting for queued
Host tests,Apple build and KUnit,PMGR power state KUnit, andSEP source checksatc53b7255, plus exact-head hardware row confirmation.
|
PASS — J773g (M4 mini, T8132 G16G) standalone rows at
|
|
J516s (M3 Pro, T6030, G15S B1, 27.2 stub) second-generation A/B row at exact head
|
|
Merge-up check against current main ( |
|
We carry this PR in our unified daily kernel across J716c (M5 Max, T6050), J713 (M4 Air, T8132), and J313 (M1 Air, T8103). Enabling firmware-managed GFX idle power-off lets the GPU power down cleanly when idle instead of sitting powered up between desktop frames, directly improving battery life on M1/M4/M5 laptops. Booted and verified on our unified daily across J716c, J713, and J313 (desktop + Vulkan CTS smoke + Cyberpunk 2077 2.5 T2 on J716c) with zero GPU faults. |
|
J615 (M3 Air, T8122, os-fw 27.2 / 26B123, aurora-g16) row at exact head d66b146 — PASS, no regression vs main. Method: both arms booted as one aura-try trial with the same board DT, main's t8122-j615.dtb (byte-identical to this head's). On each arm, a GRUB one-shot into the kernel, the trial guard and a 30 min dead-man, then back to production. Order A, B, B, A. Each was measured about 240 s after boot. Kernel config: fleet94 + olddefconfig, the same for both arms.
Terrain varies run to run on both arms by the same amount (one low run each: 443 on main, 361/637 on the head). The best runs match (913 vs 911). On T8122 the GFX genpd stays Note for other J615 rows: a 12-02+ kernel booted as a plain one-shot on our lab J615's older committed Stage 2 DT resets about 5 s into boot. Boot it with its own DTB (trial), as above. Evidence (ours, untainted): |
Conflict in g16/boot.rs: main (#3695) sends the last boot control from Session::idle_power_off(), the same rule the compute UMA idle check reads. Use that one rule for the control, the Globals word and the idle delays, and drop this branch's separate Admitted::allow_idle copy of it. test-publication.py checks the order of the merged code. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merged main ( Conflict: one, in Changed against
New on main, matters for the rows: #3695 and #3699 keep compute UMA managers bound and drop them when nothing is in flight on a layout that may power off. With this PR's delays the GPU does go off there, so the rows at this head test that too. Checks: Rows owed at |
RyanTheTide
left a comment
There was a problem hiding this comment.
The merge uses the same layout-derived policy for the Globals word, final boot control and idle checks. The Globals update stays before the final control, and the existing host test now checks that ordering. Exact J516s and J773g rows remain pending.
|
J773g (Apple M4 Mac mini,
|
…ng its pool When a shared compute UMA manager's binding may be gone (it was displaced, or the GPU may have powered off while idle), its next command rebuilds its manager record. The rebuild also rewrote all 8192 freelist records (64 KiB of uncached writes) and the 16 pool-table rows. When the firmware may power the GPU off on its own, every publication with nothing in flight invalidates the held managers, so nearly every job after an idle gap paid for that. The freelist is a ring of 16384 records. The hardware takes pages at the head cursor and returns them at the tail cursor, and both wrap at the record count that bind loads with them. A rebuild restarts the cursors at their seed: head 0, tail 8192. Taking a page only reads its record; returning one writes the record at the tail. So after a restart, returns fill the records from 8192 upwards, and none reaches the first 8192 records before one has written the last record of the ring. Until then the first 8192 records still hold the seed, every page exactly once, and cursors at their seed describe the drained pool exactly, wherever the hardware cursors were. Pages the hardware still held when its cursors were lost do not matter: they are in the seed, and with no command in flight no page is in use. So the rebuild now reads two freelist records before it decides. The last record reads zero until a return reaches it: the freelist is zeroed when it is allocated, and a returned record holds a page address. The first record still holds the first seed unless taking a page wrote its record. If both hold, the rebuild writes only the 160-byte manager record and the 16 pool-row words. Otherwise it reseeds the freelist as before and clears the last record, so that a later rebuild can trust the seed again. Some events do not show in the freelist. A system sleep, a recovery, and a shared command that failed or was aborted advance a seed generation in the slot ledger, and the next rebuild of every manager then reseeds, whatever its freelist shows. Sleep and recovery call the new restart_compute_uma(), which also invalidates the bindings; the idle path still calls only invalidate_compute_uma(). On J773g, with aurora-silicon#3695 and aurora-silicon#3697 combined, skipping the reseed unconditionally (idle invalidations unchanged, about 179k per boot) measured: row as is no reseed no invalidation idle.wake 2/20/200 ms 175/272/539 145/193/458 142/192/458 compute queue d1 121.5 99.1 101.2 compute procs d2 67.9 59.0 58.3 That run passed the CRC smoke test 10/10 and the idle.wake stress with checked compute, with the GPU physically off in 16 of 16 checks and no faults. The reseed was the whole cost of the idle rebuild. This change skips it only while the ring has not reached its end since the last seed, which a run of short jobs between idle gaps never does. The stats line gains the reseed count: "compute_uma: rebuilds N invalidations M idle_invalidations K reseeds R". Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J516s (Apple MacBook Pro 16-inch, M3 Pro,
|
|
J700 (MacBook Neo, A18 Pro, T8140, G17P) row, 12-03 12:55-13:03Z: PASS for no regression, as part of the dsrows merge tree
|
|
Local checks on this head merged with main
Hosted |
What: Let the G15S/G16G firmware turn GFX off after idle. Keep the cores available through short gaps and service the startup cooling backstop while GFX is off.
Tested: J773g/G16G at
40178c02b870and J516s/G15S at the earlier98d103b8a5b4. Each board gated in 32/32 post-fence windows at about 42 ms. Controls stayed on in 32/32. Both compute and render CRCs matched throughout, with zero GPU faults, recoveries or hang kills. All 26 driver host tests passed at the head. J773g standalone atc53b7255vs maindbfbced7(one boot each): compute-wide CTS 119,249 cases and the render-turnaround sync list 39,375 cases identical to main with 0 Fail; GFX off in 16/16 idle windows at about 42 ms (main stays on);compute.lightd4/d16/d64 within ±0.7 % of main; 10/10 pinned CRCs.Risk: Two-way door · G15S/G16G. After a 200 ms idle gap, repowering GFX added 194 µs to the median M4 wake and 384 µs on M3 Pro. M4 first-workload d1 improved 2.9%. Its short depth-4/16/64 runs took 2.8%/1.5%/2.3% longer per submit. The longer unpinned comparison measured +0.18%/+0.08%/+0.52% at those depths.
Not yet
pm_test: main has no deep sleep on T6030 without soc: apple: enable T6030 suspend-to-RAM on J516s #4067, so only s2idle ran there.At the head
ecd95b8ad8cf: J773g and J516s GFX off in 16/16 windows at 42 ms, 22/22 CRCs; J700 three deep sleeps with no regression. All three are in the comments below.Driver change and physical measurements
Linux kept the bootstrap hold in place after channel setup. Its final device-control request held the GPU awake and its persistent Globals policy requested the same hold. Release both together on firmware layouts with guarded register access when GFX PMGR automatic mode is enabled. The running firmware can then gate the GPU and wake it on the next queue doorbell.
On J516s the loader also suppresses GFX automatic power management. Where Linux supplies the missing PMP link, release that hold in the same device-tree changeset. Keeping the loader hold in an isolation trial gave 0/16 off windows even with the firmware idle policy enabled.
The core and Fender timers run in sequence. A 40 ms core delay followed by 2 ms for Fender preserved short-gap wake latency and the overall gate time. On M4, gating also stopped the firmware events that used to service the cooling backstop after driver load. The new startup worker takes live PMP readings while the backstop needs them. It stops on a sensor error, a warm reading or completed qualification. Each transition still follows the existing temperature and elapsed-time rules.
A dedicated PMGR probe sampled ACTUAL after successful user timeline waits, for up to 250 ms. The intervals below are medians of the bracket around the first off sample. All 32 candidate windows on each board began with GFX on and ended with it off; subsequent submissions completed.
Matched performance and correctness
Values are in microseconds. Each arm ran on two fresh boots with two uninstrumented passes per boot, 600 ms warmup and six 250 ms timed samples on throughput rows. The table gives the median of the four pass medians. The first-workload row uses only the first pass per boot. Timing runs and PMGR sampling were separate.
On J773g, the order was head/control/control/head, using the same kernel Image (
42169a041546), Mesa285776c6afand GPUBenchae90a40. The signed head module had build ID3bcab0e65213, the control50b687b7c434. Each run waited eight seconds after driver load before the first workload. All 18 pre-work PMGR reads across the two head boots found GFX off. S10 became available at 53.74 and 53.96 seconds of boot time, within the controls' 53.59–54.25 seconds. First d1 took 99.86 and 101.42 µs on the head, versus 103.54 and 103.71 µs on control. In both visits the candidate took longer at d4/d16/d64. Uniform compute throughput changed from 367.33 to 367.13 Mthreads/s, and shadow throughput from 19.73 to 19.86 Gpixel/s.In a separate single-boot diagnostic, the same module toggled between hold and allow across eight interleaved visits. Each visit validated the physical GFX state after a CRC-checked shadow render. Relative to hold, allow changed d1/d4/d16/d64 by −2.4%/−0.5%/−0.6%/−1.6%, and two-queue sync by +0.05%. This isolates the live policy toggle. The production/control binary comparison above still measured a difference.
Two further fresh J773g boots compared the unmodified control and head modules. The benchmark ran the same light compute sweep in six passes, with ordinary placement, high-capacity CPU, low-capacity CPU, low, high and ordinary. Each depth had 1.2 s of warmup and six 500 ms timed samples. Each cell gives the change in median µs per submit across the two passes in that placement.
On ordinary placement the absolute times were 40.25 → 40.33 µs, 23.53 → 23.55 µs and 22.68 → 22.80 µs. The longer test used one boot per binary and did not repeat the two-queue sync row. Both boots reported zero GPU faults, recoveries or hang kills.
A separate M4 dEQP-VK compute-wide run on integration build
6f929cd5matched main with 36,794 passes, zero failures and 82,455 unsupported cases. That build combined an earlier idle-gating revision with compute-manager changes.On J516s the order was control/candidate/candidate/control, using the same
98d103b8a5b4Image, Mesa69179743d9ae, GPUBenchcba9025d3fd9and six active SLC planes. All eight passes on each board produced compute CRCb022fbafand render CRC7be9463a. All boots returned to stock.A separate J516s sleep experiment observed both SpitfireE2 byte pairs at
01 01after rendering with automatic GFX power. System sleep still stopped at stage 01 in that experiment.Reproduce the second-generation row on J516s
Use a working T6030/J516s configuration and its usual 26B123 G15S boot handoff. Build the head and a baseline from
e6c7b032633cwith the same toolchain, config and board DT. Keep the normal module signing, boot and rollback procedure. The tested configuration usedCONFIG_RUST=y,DRM_ASAHI=m,DRM_ASAHI_G15=y,DRM_ASAHI_G16=y,DRM_APPLE=m,DRM_APPLE_DCP_T8132=y,APPLE_DISPLAY_GATE=y,APPLE_PMP=m,THERMAL_OF=yandAPPLE_PMGR_PWRSTATE=y. VerifyCONFIG_APPLE_T6030_GPU_PMP_LINK=yin the resulting config; DRM_ASAHI_G15 selects it. The register sampler usesCONFIG_DEVMEM=y. Build the kernel Image, modules (includingdrivers/gpu/drm/asahi/aurora.ko) and DTBs. The built-in supplier change needs the head Image. Record the kernel and loaded module build IDs on each arm.Use a separate output directory per boot. Boot headless, with
modprobe.blacklist=aurora, and load the selected driver after its dependencies. Pin the same Borealis Vulkan ICD and GPUBench binary across arms. Run the first compute sweep after an eight-second idle. Save the output of every command, the kernel journal and before/after debugfs stats. The following shell fragment assumesGpoints at gpubench-vk andVK_DRIVER_FILESnames the pinned ICD.Save the C block below as
gate.c; it requires Vulkan headers and read access to the board's GFX PMGR register. A passing head should reach ACTUAL 0 from f in all 16 post-wait windows (about 42 ms), complete later submissions, match both CRCs, and have zero new GPU errors, recoveries, hang kills or quarantines. Report the paired timing rows, early or late gates, censored windows and any regressions.