Skip to content

drm/asahi: m3: T8122 GPU states 6 to 8 under the thermal limit - #500

Closed
freber wants to merge 7 commits into
omacom:integration/aurorafrom
freber:t8122-pstate-6-8
Closed

freber wants to merge 7 commits into
omacom:integration/aurorafrom
freber:t8122-pstate-6-8

Conversation

@freber

@freber freber commented Nov 17, 2026

Copy link
Copy Markdown

Claude Code prepared this series and wrote this up from my tests on a J615 (15-inch M3 MacBook Air).

Stacked on #410, so please review that first. The four commits here sit on #410's head 6fc58762cd8f.

What it does

  1. Adds host tests for the T8122 knobs and the thermal limit's range. The nine t8122_knobs.rs unit tests never ran, since no host suite included the module (drm/asahi: let T8122 thermal control use the full performance table #317 wires it in the same way). J615: expose die temperatures and preserve T8122 GPU thermal fallback #410's Policy tests stop at a ceiling of 5. These cover ceilings 1 to 8 plus the check that finds a firmware ignoring the cap. No driver code changes.
  2. Keeps the after-job check running whenever the ceiling is above the safe cap. It now runs even if asahi.m3_retire_mmio drops bit 2. A client that keeps the pipeline full now has to let it drain once the last check is 500 ms old. Without this, one client submitting short passes can keep the check from running at all, so the cap stays where it was even at 90 C. With J615: expose die temperatures and preserve T8122 GPU thermal fallback #410's safe cap of 2, caps 3 to 5 already hit this. Every hardware result below includes this commit, so its cost is in those numbers.
  3. Accepts asahi.t8122_pstate_cap 6 to 8 as the thermal limit's ceiling with asahi.m3_thermal=on. With hold or off the driver lowers 6 to 8 to 5 and says so. Boot, missing readings and critical stay at state 2, as J615: expose die temperatures and preserve T8122 GPU thermal fallback #410 has it. The default cap doesn't change.
  4. Makes the thresholds tunable. asahi.m3_thermal_hot goes from at most 85 C to at most 92 C. Critical stays 8 C above it, so at most 100 C, 10 C under the 110 C trip of the J613 and J615 CPU thermal zones. A new asahi.m3_thermal_cool_gap (3 to 10 C) sets how far below hot the die must be before the cap rises. Both can be written at runtime. The defaults stay at 80 C with a gap of 10. This one is separate so the first three can go in without it.

How it relates to #317

Both let the thermal limit use states above 5 on T8122. #317 does it by default when the cap is omitted. This series keeps today's default and admits explicit caps 6 to 8. Commit 2 matters for #317's approach as well, since #317 also puts the ceiling above the safe cap. If you'd rather go with #317, I can rebase commit 2 onto it.

Results on a J615

The kernel was bed544b with #410, the same driver code as these four commits (then as eight), #491's CPU thermal zones and the J615 display and memory floor patches. It booted with asahi.t8122_pstate_cap=8, on AC with the Performance profile and other programs idle. I used gpubench w4 for throughput (10 s runs, each from 75 C or less, mean of 3) and pace for latency, plus a 600 s w10 load at depth 2. The combined run adds yes on all 8 cores for 300 s.

With the defaults the runtime cap rose from 2 to 8 within 10 s of boot on a cool die. Under load at state 8 the die passed 80 C within about 2 s. The cap then fell back one state per 500 ms. With a gap of 10 a long load never got above state 2 again. At 80 the die stayed above hot. At 85 and 88 it settled a few degrees under hot, which is still above hot minus 10. The 80 and 85 rows ran before commit 4, with hot on the boot line. From 88 on I set both values at runtime with commit 4.

hot, gap throughput w4 sustained w10, 600 s pace p50 combined peak
80, 10 (default) 218 fps 80.0 fps 6.1 ms 95.8 C
85, 10 272 fps 79.9 fps (376 s) 5.8 ms not run
88, 10 287 fps 80.3 fps 6.3 ms 97.6 C
88, 5 270 fps 84.3 fps 6.6 ms 95.3 C
88, 3 273 fps 85.8 fps 5.4 ms 95.3 C
90, 3 289 fps 88.1 fps 4.8 ms 94.4 C
92, 3 295 fps 95.2 fps 6.5 ms 93.9 C

The test guard stopped the 85 sustained run at 376 s, likely on a background CPU burst. The throughput rows vary by up to 55 fps between runs of the same setting, so read small differences there with care. No pace run missed a frame. No run logged asahi errors, faults or timeouts. In the combined runs the GPU sat at state 2. The #491 zones kept the hottest sensor near 94 C on average by slowing the P cluster, with the peaks in the last column.

I settled on 90 with a gap of 3 for daily use. At 92 the GPU sensors are the hottest on the die (Tg0P peaked at 95.9 C, over the 94 C GPU die target in the boot firmware's device tree). The CPU zones also held the P cluster below 4 GHz in 8 of about 120 samples during a GPU-only load, against 2 at 90. At 90 the GPU sensors peaked at 93.8 C.

For comparison, my earlier kernel at a fixed cap 5 (no GPU temperature feedback) did 307 fps in the short runs. My test guard stopped its sustained load after 16 s. Tg0P climbed from 56.5 to 90.9 C in the first 15 s. The P-core keys then jumped to 102 C in the last 5 s, probably from a background CPU burst, so the 106.4 C that tripped the guard wasn't the GPU's doing alone.

Not tested

  • Booting this branch itself, which sits on J615: expose die temperatures and preserve T8122 GPU thermal fallback #410 and 39d5f88ab4e5. The hardware runs used the same driver code on bed544b. On this branch the m3 host tests pass at every commit. The asahi driver builds at the head.
  • Suspend and resume at caps above 5.
  • Any T8122 board other than the J615, the J613 included.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TqFXgsntBCgau1RkXP1KRQ

ericjuta and others added 7 commits November 16, 2026 01:06
Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
… range

Two gaps in the host tests that the rest of this series leans on.

The nine unit tests in m3/t8122_knobs.rs have never run. No file in
tools/asahi includes the module. It does not compile on its own either,
because it takes its default InitData version from m3_firmware, which
needs the kernel crate. pstate_cap_accepts_one_to_five_only, the test
that pins the range of asahi.t8122_pstate_cap, is one of them. Include
the module in tools/asahi/m3-runtime-tests.rs, the suite the kernel CI
already runs, with a stand-in for that one constant. The stand-in's
value is checked by defaults_are_the_plan_baseline, so it cannot drift
from m3_firmware without a failing test.

Policy in m3_thermal_policy.rs moves the runtime cap between the safe
cap and the ceiling. The cap_tests from omacom#410 drive it with a ceiling of
5 over a safe cap of 2. Nothing covers ceilings 6 to 8, or the check
that finds a firmware ignoring the cap. Add tests for the rules as
they are, for ceilings 6 to 8 above a safe cap of 5 and for ceilings 1
to 5:

- the cap starts at the safe cap and rises one state per 2 s on cool
  readings, never above the ceiling;
- between cool and hot it holds;
- hot lowers one state per fresh reading, at most every 500 ms, never
  below the safe cap;
- critical, no reading, a failed, stale, implausible (including the
  -2.849 C an unpowered SMC GPU key reads) or stuck reading returns to
  the safe cap at once, with the previous cap tolerated for 1 s;
- after a fallback the cap climbs again at the same pace;
- hold never leaves the safe cap;
- a ceiling equal to the safe cap never moves;
- a firmware that stays above a lowered cap is found after 20 checks
  spanning at least 3 s.

Three mutations of Policy (critical keeps the cap, the 3 s span dropped,
the raise not bounded by the ceiling) each fail one to three of the new
tests.

No driver code changes.

Link: omacom#317
Link: omacom#410
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqFXgsntBCgau1RkXP1KRQ
Signed-off-by: Fredrik Silfver <1684291+freber@users.noreply.github.com>
The thermal limit moves the runtime cap only inside
Config::check_pstate. That runs after a job only in two conditions,
which a ceiling above the safe cap makes matter.

First, the job thread runs the check only when asahi.m3_retire_mmio has
bit 2 (the performance-state register read). The parameter is
root-writable at runtime, so writing 0 to 3 stops both the thermal limit
and the check that the firmware stays within the runtime cap. Once the
ceiling is above the safe cap, the runtime cap is the only thing that
keeps the firmware below the ceiling. A frozen governor would leave it
at whatever state it last allowed. Add Policy::above_safe()
(host-testable), Governor::enforces() (the limit is on or holding and
the ceiling is above the safe cap) and Config::pstate_check_required().
Run the after-job check when bit 2 is set or the check is required. Bit
2 is the T8122 default, so this forces only what runs by default. The
first retirement of a module load at which the check runs although bit 2
is clear logs one line, so a write that leaves bit 2 out is not silently
overridden.

Second, the check runs only at a retirement with no later batch in
flight. The T8122 default pipeline depth is 2. A render batch of the
same VM is published behind the running one while its passes fit the
4000 us budget. So one client that keeps submitting short passes, with
no other client rendering (a still or blanked screen, offscreen work),
can keep the check from running at all, at 90 C too. While the ceiling
is above the safe cap, pipeline_slot() now refuses a slot behind batches
in flight once the last check is 500 ms or more old
(Policy::overlap_allowed, CHECK_EVERY_NS), so the pipeline drains and
the existing checked retirement runs. The sensor is read every 500 ms
while busy, so more frequent checks would see no newer reading. The
longest time between checks is then 500 ms plus the run time of the
batches in flight. Every firmware-visible action stays where it runs
today, after the last batch has retired and the pipes are idle. The
other way, moving the cap on a pipelined retirement, would be a Globals
store with a later batch running on the GPU, which has never been done
on this firmware.

With omacom#410 the T8122 safe cap is 2, so both already apply to boots that
set asahi.t8122_pstate_cap to 3 to 5 with the thermal limit on or
holding. Those boots now drain the pipeline once per 500 ms under
sustained pipelined load. With the ceiling at the safe cap nothing
changes, since overlap_allowed() returns true before reading the clock.

New tests in m3_thermal_policy.rs simulate a client that keeps the
pipeline full (depth 1 to 4, batches of 0.1 to 50 ms). Without the bound
it is checked once, at boot, so 90 C leaves the cap at 8. With it the
longest gap between checks is within 500 ms plus the batches in flight,
the cap falls from 8 to the safe cap within that time of a critical
reading, a firmware that ignores the cap in hold mode is found. With the
ceiling at the safe cap, the publication order is identical to today's.
Three mutations of the bound each fail two to four of them.

Link: omacom#317
Link: omacom#410
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqFXgsntBCgau1RkXP1KRQ
Signed-off-by: Fredrik Silfver <1684291+freber@users.noreply.github.com>
… limit

asahi.t8122_pstate_cap refuses anything above 5 (PSTATE_CAP_MAX in
t8122_knobs.rs). The stated reason is that J613 and J615 had no SoC die
temperature zone, so there was no temperature feedback above the
driver's no-feedback limit. Both boards have one now (macsmc_soc_die).
The rest of the path already exists. The firmware always gets the whole
eight-state table. With the thermal limit on, PstatePolicy::new already
makes the cap the ceiling, so only the knob range keeps the governor
below 6.

Accept 6 to 8, as the thermal limit's ceiling only. With omacom#410 below
this, the runtime cap of every T8122 boot starts at state 2 and falls
back to it, whatever the ceiling.

- asahi.m3_thermal=on (the default). The ceiling is the cap. The runtime
  cap starts at 2 and rises one state per 2 s only on usable, cool
  readings of the SoC die zone. No zone, or a failed, stale,
  implausible, stuck or critical reading, puts it back to 2 at once.
  These are the governor's existing rules.
- asahi.m3_thermal=hold. 6 to 8 are lowered to 5, with one boot line.
  The firmware gets 5 and the runtime cap stays at 2.
- asahi.m3_thermal=off. 6 to 8 are lowered to 5, with one boot line.
  omacom#410's fixed cap without the limit then gives the firmware 2. These
  values were refused before in every mode (ENODEV, no GPU for that
  boot). A cap left on the command line from a ranging boot while the
  thermal limit is switched off should not cost the GPU.

Values of 0, 9 and up are refused as before.

Whether the zone is usable can only be decided at runtime. On a J615 the
GPU firmware starts about 1.6 s into boot from the initramfs. The
macsmc_soc_die zone appears at about 7.6 s, when macsmc_hwmon registers
it. A probe-time zone check would refuse every boot, so the zone
condition is the governor's existing rule that only a usable reading
raises the runtime cap. The line the governor logs for a usable reading
now ends in "the runtime cap may rise above 2 up to N (MHz)" while the
ceiling is above the safe cap, so the boot log shows when the higher
states became possible. It is one line per change of the reading's
source, as before.

pstate_cap_use() in t8122_knobs.rs states the rules above in plain code
that the host tests drive. PstatePolicy::new gets the lowered ceiling
from admitted_cap(). Contents::select refuses the start if what
PstatePolicy::new computed is ever more than pstate_cap_use() allows, so
the two cannot drift apart silently. A host test checks that they are
equal for every cap and mode. Const assertions tie the no-feedback limit
(5) and the fallback (2) to the two constants of m3_thermal_policy.rs
that PstatePolicy::new uses. The boot lines name the case (lowered,
ranging or held) and the knob's value, which asahi.m3_max_pstate can
still lower later. When that parameter is given they say so and point to
the "firmware highest state" line, which has the result.
tools/aurora-sep/M3-GPU.md gets a paragraph on caps 6 to 8.

Tested on a J615 (15-inch M3 MacBook Air) with this series and omacom#410 on
bed544b, asahi.t8122_pstate_cap=8 and the thermal limit at its defaults.
On a cool die the runtime cap rose from 2 to 8 within 10 s of boot.
Under GPU load the die passed 80 C within about 2 s at state 8 and the
cap fell back to 2 one state per 500 ms. A 600 s GPU load and a 300 s
combined CPU and GPU load ran without asahi errors, faults or timeouts.

Link: omacom#317
Link: omacom#410
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqFXgsntBCgau1RkXP1KRQ
Signed-off-by: Fredrik Silfver <1684291+freber@users.noreply.github.com>
The M3 thermal limit lowers the runtime cap at asahi.m3_thermal_hot
(default 80 C, at most 85 C) and raises it again only 10 C below that.
On a J615 under a sustained GPU load the die then settles between the
two (83 to 84 C with hot at 85). The cap stays at the safe state 2 for
the whole load, since nothing ever reaches the cool point again.

Let both be set further for boards and users that want it. The defaults
do not change.

- asahi.m3_thermal_hot goes up to 92 C. Critical stays 8 C above it, so
  at most 100 C, below the 110 C critical trip of the J613 and J615 CPU
  thermal zones.
- asahi.m3_thermal_cool_gap (default 10 C, 3 to 10 C) sets how far below
  hot the die must be before the cap rises again.
- Both are writable at runtime in /sys/module/asahi/parameters. The
  governor reads them at each update, applies the clamped values from
  the next reading with the usual pacing and logs the new thresholds.

The bounds and the clamping move into m3_thermal_policy so the host
tests cover them. New tests cover the clamping, the default gap, a
narrower gap, a higher hot and thresholds changed at runtime.

Tested on a J615 with asahi.t8122_pstate_cap=8, stepping the two values
at runtime. A 600 s GPU load (gpubench w10, depth 2) ran at 80.0 fps
with the defaults, 85.8 fps with hot 88 and gap 3, 88.1 fps with hot 90
and gap 3 and 95.2 fps with hot 92 and gap 3. A 300 s combined CPU and
GPU load stayed at the safe state 2 at every setting. The CPU thermal
zones kept the hottest die sensor at 92 to 94 C on average, with peaks
of 93.9 to 97.6 C.

Link: omacom#317
Link: omacom#410
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqFXgsntBCgau1RkXP1KRQ
Signed-off-by: Fredrik Silfver <1684291+freber@users.noreply.github.com>
@freber

freber commented Nov 18, 2026

Copy link
Copy Markdown
Author

Claude Code wrote this up from my tests.

7.3 ships from aurora-silicon now, so I moved this there as aurora-silicon/linux#2203. It carries #410 and #491 as well, stacked on aurora-silicon/linux#2147. On my J615 running 7.3 the tuned thresholds (hot 90, gap 3) gave 122.5 fps sustained against 99.6 fps at the defaults, measured in the same hour. Closing this one.

@freber freber closed this Nov 18, 2026
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