Skip to content

drm/asahi: give the G14 27.2 firmware its power data and run the full GPU range - #3162

Merged
RyanTheTide merged 1 commit into
mainfrom
m2gpu/g14-v27-2-power-data
Nov 25, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
m2gpu/g14-v27-2-power-data

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What: The M2 GPU (G14G) on firmware 27.2 gets its full clock range back. Since #3091 it has been capped at its first operating point (444 MHz), because at the higher states the firmware stalled compute work under load (fetched > retired, no fault, no firmware timeout event) and held the top voltage even when idle. The cause: the G14 27.2 init builder left most of the firmware's power data zero, while the 27.2 records keep that data in the 13.5 layout. This driver already builds all of it for the 13.5 InitData. This PR copies it over, with no new constants:

  • Globals: the shared power tables HwDataShared1 (+0xec) and HwDataShared2 (+0x1b4), including the G14 curves computed per operating point from its frequency and voltage.
  • Power record: the average-power filter (+0x10..+0x20) and HwDataShared3 (+0x4f0).
  • Hardware data:
    • the 13.5 HwDataB words from the power sample period (+0xff4, which was 0) to the fragment count (+0x10a4);
    • the SRAM power coefficient of each state (sram_k);
    • the identity state index map;
    • the stray second MHz series at +0x1924 is no longer written.
  • Globals +0x9b8/+0x9bc/+0x9c0: the compute back-off words, which the M3 and M4 27.2 runtimes already set.

Globals +0x98 then takes the ceiling, like +0x88/+0x8c, and the firmware governs the whole range itself. offset_of checks tie every destination to the 13.5 structures at compile time.

Tested: J473 at b56f3d39 pass (M2 mini, G14G, firmware 27.2). Kit 7.3.0-aurora-m2p3 was built from the same tree (ce85dd1e). Guarded one-shot, default cmdline, fleet89 Stage 2, GNOME on both monitors:

  • Geekbench 6 Vulkan, twice: all workloads complete, 96 s wall each. The capped clock takes 152.6 s, so this is 1.59x faster. Before this PR, the full range stalled in GB6 within 35 s (m2p1, and m2p2 = the Globals tables alone).
  • gpubench GL native: 24/24 loops x 43 ok (drm/asahi: let the G14 27.2 GPU use its full performance-state range #3075 hung in loop 1).
  • gpubench compute.light: 8/8 loops x 7 ok.
  • 0 GPU timeouts, 0 MMU faults, 0 Oops. gnome-shell kept its PID, and fresh vkcube/vulkaninfo returned 0 afterwards.
  • GPU rail 0.68-0.82 V following the load (before: a fixed 0.94 V, idle included); GPU power peak 8.97 W.
  • Production restored and verified (fleet89, Enforcing, 0 failed units, next_entry empty).
  • Host test: g14_v27_2_abi.rs 8/8 (rustc --test).

Risk: two-way · G14G Macs on firmware 27.2 only (gpu/v27_2.rs, g14_v27_2_abi.rs). The 13.5 path and other GPU generations are untouched. The J413 (M2 Air) runs 13.5, so it does not exercise this code.

Not yet:

  • Top-state residency under a sustained ALU load. macOS 27.2 on this J473 runs 1398 MHz at 100% under a Metal FMA load. In these workloads ours peaked at 0.82 V (about the 1110 MHz state). A sustained-compute row is the follow-up.
  • A gpubench GPU clock/power soak beyond this gate.
How the layout was found
  • A macOS 27.2 reference on the same J473 (SPTM-virt guest, GPU parked, firmware records read through the UAT; the capture is private) showed the 27.2 Globals, power record and hardware data holding the 13.5 structures at the offsets above. The G14 curve values there equal what hw_shared2 computes from the DT operating points for every state.
  • macOS also publishes the ceiling statically at +0x88/+0x8c/+0x98, so there is no host-side DVFS governor to add.
  • The M3 27.2 producer writes the same HwDataB words at its own block offset.
  • Our own measurement (untainted): macOS 27.2 on this Mac reaches 1398 MHz under load. Data: traces/gpu/20261125-j473-macos-gpuref.
Evidence

Our own traces, traces/gpu/20261125-m2gpu-next/:

… GPU range

Since #3091 the G14 GPU on firmware 27.2 has been capped at its first
operating point (444 MHz): at the higher states the firmware stalled
compute work under load (fetched > retired, no fault) and held the top
voltage even when idle. The 27.2 builder left most of the firmware's
power data zero. The 27.2 records keep that data in the 13.5 layout,
and this driver already builds all of it for the 13.5 InitData:

- Globals: HwDataShared1 at +0xec and HwDataShared2 at +0x1b4, which
  includes the G14 curves computed from each operating point's
  frequency and voltage.
- Power record: the average-power filter at +0x10..+0x20 and
  HwDataShared3 at +0x4f0.
- Hardware data: the 13.5 HwDataB words from the power sample period
  to the fragment count, at the chip id's distance (power sample period
  at +0xff4, fragment count at +0x10a4); the SRAM power coefficient of
  each operating point (sram_k); the identity state index map. Drop the
  second MHz series at +0x1924, which is not part of the block.
- Globals +0x9b8/+0x9bc/+0x9c0, the compute back-off words that the M3
  and M4 27.2 runtimes also set.

Copy these values from the 13.5 InitData: same builders, same chip
configuration and DT operating points, with no new constants. offset_of
checks tie each destination to the 13.5 structures.

With the data in place, publish the ceiling at Globals +0x98, as +0x88
and +0x8c already do. The firmware then governs the whole range itself:
the rail follows the load (about 0.68-0.82 V instead of a fixed 0.94 V).

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners November 25, 2026 14:37
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Row: J473 b56f3d39 pass (G14G, firmware 27.2, full GPU range). Exact tree of this head (kit 7.3.0-aurora-m2p3), guarded one-shot, default cmdline:

  • GB6 Vulkan x2: rc=0, 96 s each (capped clock: 152.6 s).
  • gpubench GL native: 24/24 x 43 ok.
  • compute.light: 8/8 x 7 ok.
  • 0 GPU timeouts, 0 faults. Fresh vkcube/vulkaninfo rc=0, gnome-shell same PID.
  • Rail 0.68-0.82 V, GPU power peak 8.97 W.
  • fleet89 restored: Enforcing, 0 failed, next_entry empty.

Evidence: traces/gpu/20261125-m2gpu-next/20261126-005536-j473-pf3-m2p3.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at b56f3d399f8643d1f39886c85dea24bc2f3d205e
Blockers: The exact J473 soak has 24 GL loops, eight Vulkan compute loops and zero reported faults. The saved post-load log has one fresh vkcube and one fresh vulkaninfo. Please add the ten short-lived Vulkan clients on the same kit, with timeout/device-loss counts and ordinary restoration. Record the highest observed GPU state during a sustained Vulkan run if available so enabled operating points and observed residency stay distinguishable.
Checked: The kit commit and PR have the same tree. The enabled ceiling comes from the device-tree operating-point count. Gains, voltage curves and power fields reuse the existing InitData builder, and the three compute progress values match existing M3/M4 27.2 code. The standalone ABI tests passed 8/8 and the exact PR merges cleanly over current main. No code blocker found.

Evidence

The new writes occupy the power-table ranges reserved by the firmware layouts. The shared table sizes, curve field offsets and hardware-data translation are checked at compile time. The previous failure under Geekbench no longer reproduces in two reported runs. This build measured a lower voltage range and clean recovery. The unaffected 13.5 path still uses its existing builder.

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

Audited full diff at b56f3d3: clean G14G firmware-27.2-only change with zero impact on 13.5 or other GPU generations. Every destination offset and size in put_shared1/put_shared2/put_curve/put_shared3 and the HwDataB shift copy is pinned by compile-time offset_of! and size_of assertions against the existing 13.5 InitData builders, with no new magic constants. Exact-head J473 verification (2x GB6 Vulkan 1.59x speedup, 24/24 gpubench GL, 8/8 compute.light, dynamic 0.68-0.82V rail scaling, 0 faults) and host tests look solid; ready to merge once CI completes.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verdict: HOLD at b56f3d399f8643d1f39886c85dea24bc2f3d205e
Blockers: The later guarded J473 test on the same kernel kit completed its workload, but the return to the saved fleet89 boot failed verification. The independent host check also lost reachability. The connection loss alone cannot distinguish a failed boot from a network failure. Verify the saved kernel and boot entry, clear the pending one-shot, and record system health before merge.
Checked: The earlier 24 GL and eight Vulkan loop results and its successful restore remain valid for that boot. The missing return is from a separate sustained-compute run on the exact same kit.

@RyanTheTide RyanTheTide added the hold Held on purpose; skipped by the PR digest label Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

On the HOLD at b56f3d39: the J473 is restored and verified, and the failed return came from the test harness, not from this kernel.

  • The clk1 trial on kit 7.3.0-aurora-m2p3 finished its phase cleanly, with 0 GPU timeouts and 0 faults. Its journal ends in an orderly systemctl reboot.
  • Because the harness's return check failed, its restore block never ran. The Stage 2 trial marker (/boot/efi/aura-try, m1n1/m2gpu-trial.bin) and the armed dead-man stayed in place, so the next boots never settled: one long dark boot with no journal, then a fleet89 boot that reset after about 55 s.
  • Recovery:
    • a VDM reboot from the J616s;
    • then the harness's own restore steps by hand: restore.sh, dead-man disarm, trial marker and trial Stage 2 removed, trial modules removed, /boot unparked.
  • System health now, after 330 s of uptime and then a plain reboot:
    • 7.3.0-aurora-fleet89, saved entry fleet89, next_entry empty, the default boot is Aurora;
    • Enforcing, 0 failed units, 0 AVCs, the sink muted;
    • no aura-try, no trial Stage 2, no m2p3 modules.

The FINISH items (ten short-lived Vulkan clients, and the highest GPU state under a sustained Vulkan load) come next as one guarded row on the same kit.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Row: J473 b56f3d39 pass (FINISH items; same kit 7.3.0-aurora-m2p3, guarded one-shot, default cmdline):

  • Ten short-lived Vulkan clients in sequence (vkcube 300 frames + vulkaninfo each): 10/10 rc=0, 0 timeouts, 0 device loss.
  • Sustained Vulkan compute, gpubench compute.heavy (alu + bw, depths 1-64) for 3.5 min: 84/84 ok, 0 faults.
  • Highest observed GPU state:
    • GPU rail max 824 mV, which is the 1110 MHz operating point (830 mV in the DT table). This is observed residency, not the enabled ceiling.
    • The firmware governs up to there. GPU power was 3.0 W mean and 5.8 W max in this load (GB6 peaked at 8.97 W at the same rail maximum).
    • For reference, macOS 27.2 on this Mac reaches 1398 MHz under a sustained Metal FMA load. Top-state residency stays a follow-up (Not yet).
  • Restore: harness restore OK. fleet89, Enforcing, 0 failed units, next_entry empty, no trial files on the ESP.

Evidence: traces/gpu/20261125-m2gpu-next/20261126-021359-j473-fin1-m2p3.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at b56f3d399f8643d1f39886c85dea24bc2f3d205e.
Blockers: Wait for hosted CI. The failed-restore hold is cleared by the clean exact-kit rerun.
Checked: J473 completed 10/10 fresh Vulkan clients and 84/84 sustained compute cases with no device loss, timeouts or GPU faults. The guarded run removed the trial files and returned to saved fleet89 with SELinux Enforcing, zero failed units and an empty next entry.

Evidence

The final J473 row used the same exact-tree build and default command line. Its 824 mV rail peak corresponds to the 1110 MHz operating point. The highest supported point was not observed in that workload and remains a performance follow-up. The previous restore receipt accounts for the repeated resets after the watchdog and trial marker were left armed. The first dark boot did not leave a journal. The rerun and independent stock readback verify the return with cleanup.

@RyanTheTide RyanTheTide removed the hold Held on purpose; skipped by the PR digest label Nov 25, 2026
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at b56f3d39: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at b56f3d39
Conflicts ok none
PR text ok Risk: two-way · G14G Macs on firmware 27.2 only (gpu/v272.rs, g14v272abi.rs). The 13.5 path and other GPU generations are untouched. The J413 (M2 Air) runs 13.5, so it does not exercise this code.

Areas: area:gpu

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m2 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants