Repository navigation
drm/asahi: let T8122 thermal control use the full performance table - #317
DjDeveloperr wants to merge 1 commit into
Conversation
The omitted T8122 experiment cap resolves to state 2 and is then applied as a firmware ceiling, so the thermal governor cannot raise the runtime cap even with valid SoC temperature readings. On J613 the captured boot reports eight table states but a firmware/runtime range of 2..2. Track whether the experiment cap was explicitly supplied. With thermal control enabled, let omission use the table ceiling while retaining state 2 for startup and sensor/critical-temperature fallback. Keep the fixed state-2 policy with thermal control off, and preserve all explicit caps 1..5 and other SoCs' policy. Hold mode exposes the table but keeps the runtime cap at state 2 for qualification. Exercise the production parser and thermal decisions in the existing host suite, including sensor failures, heat, pacing and cap enforcement. Correct the experiment help and update its installer checksum together. Native affected-driver compilation and host tests pass. Higher-state hardware correctness, thermal behavior and performance remain untested. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Claude Code wrote this up from my tests. I've been running states 6 to 8 on a J615 (15-inch M3 Air) and opened #500 with what came out of it. Where this PR lifts the ceiling when the cap is omitted, #500 keeps today's default. An explicit #500's second commit applies here too. When the ceiling is above the safe cap, one client that keeps the pipeline full can stop the after-job thermal check from running, so the cap stays high while the die heats up. The commit makes the pipeline drain once the last check is 500 ms old, so the check runs again. It would fit on top of this PR as well. If you'd rather keep this approach, I can rebase it onto your branch. On the J615, short GPU runs went from 218 fps at the default 80 C limit to 289 fps at 90 C with a 3 C gap. A 600 s load went from 80 to 88 fps, with the hottest key at 93.8 C. With the default 80 C and gap of 10, a long load never got above state 2 again after the first seconds. The full table is in #500. |
… 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 aurora-silicon#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/linux-aurora#317 Link: omacom/linux-aurora#410 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 aurora-silicon#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/linux-aurora#317 Link: omacom/linux-aurora#410 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 aurora-silicon#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. aurora-silicon#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 aurora-silicon#410 on bed544b (the 7.2 line), 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/linux-aurora#317 Link: omacom/linux-aurora#410 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/linux-aurora#317 Link: omacom/linux-aurora#410 Signed-off-by: Fredrik Silfver <1684291+freber@users.noreply.github.com>
The J613 boot log reports an eight-state GPU table but clamps both the firmware ceiling and runtime range to state 2 (table label 618 MHz), even while valid SoC die temperatures change. The omitted T8122 experiment cap currently prevents the existing thermal governor from using higher states.
This candidate lets thermal control use the published table when that experiment cap is omitted, retaining state 2 at startup and on critical temperature or sensor failure. Thermal-off boots retain fixed state 2; explicit caps 1–5, hold behavior, global maximum/boot limits and other SoCs retain their policy. Scheduling, batching, Mesa and the firmware ABI are unchanged.
Validation: native ARM64 affected Asahi Rust/C linked object builds; all 27 checked dependency/driver artifacts match buffered/O_DIRECT hashes. The production-policy host suite passes 32 tests, and a temporary restoration of the old ceiling fails the regression test. The Air tool suite passes 86 tests with four skips; checkpatch reports no findings.
Draft pending hardware qualification. State-8 clock/throughput, correctness, sustained thermal response and recovery have not been tested. The full local kernel build did not complete: recurring build-VM cache corruption affected Rust metadata and tools. Evidence was preserved, the idle VM shut down gracefully, and its disk cloned before restart; the affected-driver compile passed afterward. This does not establish a fix for that VM fault. Full CI is requested separately. No candidate is installed on the laptop; auto-unlock and native Limine one-shot recovery must be verified before testing.