Skip to content

drm/asahi: g17: M5: apply the controller defaults on every part - #2080

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:integration/aurorafrom
Isaac-Duarte:j714s/gpu-controller-defaults
Nov 16, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:integration/aurorafrom
Isaac-Duarte:j714s/gpu-controller-defaults

Conversation

@Isaac-Duarte

@Isaac-Duarte Isaac-Duarte commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

On every M5 Pro and M5 Max except one reference part each, the GPU never gets its power-controller configuration. The M5 builder (g17/initdata/m5.rs) installs a board's controller_defaults (the relative power curves, the policy words, M5_POLICY_MAXIMUM_POWER of 98884 mW, and from there region C's maximum power) only when the GPU node's apple,leakage-calibration-words equal the board's calibration. J714 and J716C hard-code the words of the one part their configuration was read from (J714: 0xd2035701 0xac3a1280 0x0a281d81). Any other part keeps the firmware's default budget, and its GPU stays near its lowest performance state under any load. On my J714s (words 0xe703b401 0xea3e1410 0x8af41f61) a compute job took 4.8 times as long on the GPU as it does under macOS. 6d8d401 (J716c) already says so for J714: "a unit whose calibration words differ keeps the default budget".

This drops the gate: the calibration field and its check are gone, and a board's controller configuration applies on every part. DjDeveloperr confirmed the gate was not intended. The leakage inputs in each configuration stay the reference part's (see "Not done" for why). The firmware holds its power estimate to the maximum, not the actual draw, and the estimate uses those leakage inputs, so a part that leaks more than the reference draws more than the firmware believes. Mine does: its leakage fields are 8-15% above J714's reference (table below). The firmware's temperature-based emergency clamp still applies; g17/thermal.rs documents that J714 at this maximum can reach it under sustained load, and the governor that avoids it is opt-in (m5_thermal_governor, default off). On this part, the soak below matched macOS for power and temperature.

Machines. Every T6050 machine whose board has a controller configuration now gets it on every part:

  • M5 Pro (J714 board, hw/t6050.rs CONFIG): J714s, J716s, J873s, K114s and K116s. Only the J714s has run it.
  • M5 Max (J716C board, CONFIG_MAX): every M5 Max but the reference part had the same problem and now gets J716c's configuration (196098 mW maximum). I have no M5 Max; this is untested.

Unchanged: M5 Ultra (J775D: synthetic leakage, never gated) and T8142 / J813 (no controller configuration; t8142::PROBE names J714 but is only the base of t8142::CONFIG, which uses J813).

Measured on J714s (gpubench compute.heavy, the same test as a macOS 27.2 M5 Pro record; lily is the Vulkan LLM engine):

before after macOS 27.2
ALU job, GPU time 1291 us 272 us 267 us
bandwidth job, GPU time 844 us 486-490 us 485 us
ALU throughput (depth 4) 1349 GFLOPS 7886 GFLOPS 8238 GFLOPS
lily, Gemma 4 26B-A4B UD-Q5_K_M decode 15 tok/s 55.7 tok/s
lily prefill, 1K prompt ~360 tok/s ~1750 tok/s

The "after" column is a module with only this change, built for the running kernel. lily's output was bit-identical before and after (same digest).

Sustained load, firmware fan control: 10 minutes of back-to-back compute.heavy ALU runs (depth 4), started at TCMb < 50 C, no userspace fan tool. The fans stayed off until about 100 s (TCMb 92 C), ramped slowly and reached their ceiling (about 4950/5350 rpm) only at about 500 s. TCMb peaked at 102.7 C at about 230 s, with the hottest GPU die sensor at 96 C, and settled near 90 C. The emergency clamp (the GPU pinned to its base state, which would cut a sample to about a fifth) never engaged: throughput had a median of 7879 GFLOPS, with short dips of 3-6% (7411-7655 GFLOPS) at the 101-103 C peak and two more at about 91 C at the end. dmesg showed no GPU or thermal messages. For comparison, a run where a more aggressive userspace fan curve took over after 70 s held TCMb at 81 C with no dips. This is one ALU-bound load on one part in a 14-inch chassis; a part that leaks more than this one will run hotter.

Against macOS on the same part. macOS 27.0.1 computes this part's configuration from its own fuses, so running the same soak there shows whether the reference leakage makes Linux drive this part harder. Same machine, same gpubench test (the Metal executor), started at TCMb < 50 C, firmware fan control, SMC keys read the same way on both:

10-minute ALU soak macOS 27.0.1 Linux, this PR
per-job GPU time, ALU / bandwidth 267 / 487 us 272 / 488 us
system power (PSTR), median 46.5 W 46.6 W
package power (PHPC), median 34.4 W 34.3 W
TCMb peak / at 10 min 103.5 / 91.5 C 103.1 / 89.8 C
hottest GPU die sensor, peak 96.6 C 96.6 C
fans start ramping / reach ceiling 175 s / 351 s 217 s / 454 s
throughput median / min 8120 / 7360 GFLOPS 7885 / 7715 GFLOPS

On this part, Linux with the reference leakage draws the same power and reaches the same temperatures as macOS with the part's own. macOS throttled a little deeper (to -11%, Linux -6%), and its unthrottled throughput is about 3-4% higher at the same per-job GPU time, the difference in how queued jobs overlap. That is one part; a part whose leakage differs from the reference in the other direction, or by more, is not covered by this.

Not done: per-part leakage. I tried to derive each part's leakage from its own words. The fields can be located: read as one 96-bit little-endian value, the words reproduce both boards' hard-coded leakage exactly.

bits J714 reference J716c reference this J714s
[0:8) 1 2 1
[8:22) 855 (cluster 0: 1710) 2633 (clusters 0, 3: 2633) 948
[22:36) 840 (cluster 1: 1680) 2553 (clusters 1, 2: 2553) 924
[36] 0 0 1
[37:46) 148 (SRAM: 148) 411 (SRAM: 205.5) 160
[56:68) 428 (AFR: 428) 1420 (AFR: 1420) 490

So cluster leakage = 2 × field / byte 0, SRAM = field / byte 0, and AFR = field. I did not implement this, for three reasons:

  • Two reference parts cannot decide whether bit 36 belongs to the SRAM field, and this part has it set (160 or 160.5).
  • The maximum power differs between J714 and J716c (98884 and 196098 mW). On earlier Apple GPUs, the boot loader models power from the same leakage (aura's calc_power_t600x). A part's own leakage probably needs its own maximum power, and the M5 model is not in the tree.
  • Derived leakage has not run on any part.

A follow-up needs a second M5 Pro's policy as macOS writes it, read under aura. T6040 already has the shape for it: g17/calibration.rs takes the per-chip leakage[56] and max_power_mw from the boot loader's handoff.

Testing:

  • The J714s ran this configuration as a local module whose T6050 board was Board { calibration: None, ..J714 }: on the M5 Pro, the same behaviour as this commit, which removes the gate instead. The measurements above are from that module, built for the running kernel (integration/aurora c33c5fd plus unrelated USB-C, HID and Wi-Fi patches; none touch the GPU); the change applies unchanged on the current integration/aurora.
  • tools/ci-local.sh (host tests and DT checks, merged onto the current integration/aurora): all host tests passed. The DT checks were skipped because nothing in the DT changed. The host tests do not build the asahi module, so I built it from this change (aurora.o, with the running J714s config and rustc 1.100): no errors, no warnings in the touched files.
  • Not tested: any M5 Max, the other M5 Pro machines (including the Mac mini, J873s), parts with fewer enabled GPU cores if any exist (they also select CONFIG and get the 20-core model), idle and battery power with the configuration applied, soaks longer than 10 minutes, other loads (render, mixed CPU+GPU), and suspend/resume.

@Isaac-Duarte
Isaac-Duarte marked this pull request as ready for review November 16, 2026 15:52
The M5 power-controller configuration of a board (the relative power
curves, the policy words, the maximum power and from there region C's
maximum power) is applied only when the GPU's leakage calibration words
equal those of the one part it was read from: on J714 (M5 Pro) and
J716c (M5 Max). Every other part keeps the firmware's default budget,
and its GPU stays near its lowest performance state under any load. The
gate was not intended.

Drop it: a board's controller configuration now applies on every part.
The leakage inputs stay the reference part's: the driver does not decode
a part's own leakage from its words, and the maximum power that would go
with it is not known. The firmware holds its power estimate, not the
actual draw, to the maximum, so a part that leaks more than the
reference draws more than the estimate says; the firmware's
temperature-based emergency clamp still applies. J775D's configuration
was never gated, and J813 has none.

On a J714s whose words differ (0xe703b401 0xea3e1410 0x8af41f61), the
GPU time of a gpubench compute.heavy job, against macOS on the same
machine:

                       before   after   macOS
  ALU job, us            1291     272     267
  bandwidth job, us       844     488     487

and in a 10-minute ALU soak on firmware fan control, the same power and
temperatures as macOS: system power 46.6 W (macOS 46.5 W), TCMb peak
103.1 C (macOS 103.5 C).

Signed-off-by: Isaac Duarte <[email protected]>
@Isaac-Duarte Isaac-Duarte changed the title drm/asahi: g17: M5 Pro: apply the controller defaults on every part drm/asahi: g17: M5: apply the controller defaults on every part Nov 16, 2026
@Isaac-Duarte
Isaac-Duarte force-pushed the j714s/gpu-controller-defaults branch from 2b7ef42 to a250d9c Compare November 16, 2026 16:17
@DjDeveloperr
DjDeveloperr merged commit bf423bf into aurora-silicon:integration/aurora Nov 16, 2026
1 check passed
rolotrealanis98 added a commit to rolotrealanis98/linux that referenced this pull request Nov 17, 2026
…t's leakage

aurora.m5_controller_defaults=1 gave the J716s J714's GPU power-controller
configuration as it stands, leakage inputs included: those of the one
J714 part it was read from. The leakage is a per-part fuse value the boot
loader already hands over (apple,leakage-calibration-words, which aura
reads on the J716s too), and aurora-silicon#2080 located its fields: read as one 96-bit
little-endian value, a divisor in bits [0:8), the clusters' fields in
[8:22) and [22:36), SRAM in [37:46) and AFR in [56:68) reproduce the
hard-coded leakage of both J714's and J716c's reference parts exactly.

Give the J716s its own configuration, encode_m5_policy_controller_defaults_j716s:
J714's, with this part's leakage decoded at every boot. M5Leakage decodes
the words with integer arithmetic only (values in half units, written as
IEEE singles without the FPU) and refuses any value outside half and twice
J714's reference; compile-time checks pin the decode and the encoding to
both reference parts' hard-coded words. Without valid words the switch
changes nothing and says so.

What stays J714's, and why:
- The relative power curves and the 98884 mW maximum: macOS computes them
  per part from the perf-state voltages and the leakage with a power model
  that is not known (one model of the aura calc_power_t600x form does not
  fit J714's and J775D's together). On the J716s's higher voltages and
  leakage the firmware's top-state estimate comes out some 3-9 % above
  this maximum, so it may hold the GPU just below the top state under a
  sustained full load: on the safe side.
- The controllers' gains, thresholds and timings: the kext's configuration
  for the core type, 0x18 on both. The J716s ADT GPU node has no power
  tunables, and 143 of its PMP node's 146 equal J714s's.
- The AON temperature records and sensor channel masks: the J716s ADT
  aon-ptd rows are J714's.

The perf-state voltages were already the J716s's own (J716S_GPU_PERF_STATES,
from its ADT). Still boot only, default 0 (unchanged).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants