Skip to content

drm/asahi: add hotspot fan assistance without host power budgeting - #2210

Open
erikwb wants to merge 3 commits into
j716c/macsmc-fan-auto-retryfrom
j716c/hotspot-fan-assist
Open

erikwb wants to merge 3 commits into
j716c/macsmc-fan-auto-retryfrom
j716c/hotspot-fan-assist

Conversation

@erikwb

@erikwb erikwb commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Under sustained GPU activity on the J716c, the SMC's automatic cooling held the fans around 3,350–3,730 RPM while the SoC hotspot exceeded 109 °C.

Change

Add machine-configured hotspot fan assistance across macsmc-hwmon and drivers/gpu/drm/asahi/g17/ that leaves the firmware's GPU power budget and CPU frequency limits alone:

  • DT binding (Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml): add optional apple,soc-die-fan-trip-millicelsius, apple,soc-die-fan-hysteresis-millicelsius, and apple,soc-die-fan-hold-ms properties (required together alongside apple,soc-die-keys), documenting that they are intended to be populated by the boot loader (Aura) rather than hardcoded in static board .dts files. Boards that omit them leave hotspot fan assistance off.
  • SMC hwmon ownership (drivers/hwmon/macsmc-hwmon.c, include/linux/mfd/macsmc.h, Documentation/hwmon/macsmc-hwmon.rst):
    • Add macsmc_hwmon_fans_request_manual(), which behaves like macsmc_hwmon_fans_request() but only drives fans whose device tree node carries apple,fan-manual-control, leaving non-manual fans untouched.
    • Parse the three DT properties when apple,soc-die-keys lists a single die sensor (without naming any SMC key in the GPU driver), register the corresponding THERMAL_TRIP_ACTIVE trip on the macsmc_soc_die thermal zone, and export macsmc_hwmon_hotspot_assist_available() and macsmc_hwmon_hotspot_assist_policy().
    • Add KUnit test macsmc_fan_test_manual_only_request in drivers/hwmon/macsmc-hwmon-test.c covering macsmc_hwmon_fans_request_manual() (including verifying that a manual-only release leaves a non-manual fan held by macsmc_hwmon_fans_request() untouched) and macsmc_hwmon_hotspot_assist_policy().
  • GPU thermal governor (drivers/gpu/drm/asahi/g17/fans.{c,h}, thermal.rs, mod.rs):
    • Delegate all DT selection, policy lookup, and manual-only fan requests to macsmc-hwmon — g17/fans.c no longer walks macsmc-hwmon DT bindings or names any SMC key.
    • Read trigger_mc, release_mc (trip - hysteresis), and hold_ms from the bound macsmc-hwmon provider (macsmc_hwmon_hotspot_assist_policy()). Without a DT-supplied policy or a single-sensor macsmc_soc_die provider with a controllable apple,fan-manual-control fan, assistance stays off and releases any active boost.
    • While the GPU is busy and the SoC hotspot reaches the DT trigger threshold, request rated speed on manual-control fans via request_fans_described(). Return them to automatic control via the manual-only release path after the DT hold duration in which the GPU was idle or the hotspot stayed below the DT release threshold, or at once when the hotspot cannot be read.
    • Track budget-governor (request_fans) and hotspot-assistance (request_fans_described) ownership explicitly in FanBoost: a partial hotspot request rolls back via request_fans_described(0, 0) (never via the unrestricted request_fans(0, 0)), a failed budget boost or first curve request drops any partial unrestricted request and keeps budget_release_pending set until unrestricted cleanup succeeds, and mode transitions on m5_thermal_governor bit 0 explicitly finish releasing the outgoing owner via its own release path before starting the incoming owner. While boosted, the request is repeated on each busy hot step, restoring rated speed after a hwmon unbind/rebind. Whenever the host power budget controller (m5_thermal_governor bit 0) is enabled, it owns the fans with its own curve and hotspot assistance stays off.
  • Host tests (tools/asahi/m5-hotspot-fans-dt-tests.py, tools/asahi/run-host-tests.py): compile the real macsmc-hwmon DT helpers and g17/fans.c wrappers against libfdt, verify no SMC key names or macsmc-hwmon DT binding strings appear in g17/fans.c, test synthetic trees (any single die key, missing/invalid trips, partial manual-control fan subsets) and T6050 board trees (confirming J716c without the trip properties stays off and a tree with them governs with the supplied tuple), compile FanBoost from g17/thermal.rs with rustc to verify partial budget boost, first curve, and hotspot request failures keep release pending until cleanup succeeds before handoff, and verify all 7 mutations are caught.

Stacked on #2209 (j716c/macsmc-fan-auto-retry, c50540c8ef05). Because no static board .dts sets the three trip properties, hotspot fan assistance stays off everywhere until a machine-supplied source is established and wired up.

Testing

Verification on 16bd9275b6d4 (e2c950da0de1..16bd9275b6d4, stacked on #2209 c50540c8ef05 over origin/integration/aurora 9540f807f5ab):

  • DT binding validation: make ARCH=arm64 LLVM=1 dt_binding_check DT_SCHEMA_FILES=hwmon/apple,smc-hwmon.yaml passed with 0 errors and 0 schema warnings (yamllint not installed on build host, skipped).
  • Host tests: python3 tools/asahi/run-host-tests.py --only m5-hotspot-fans --jobs 8 passed 8/8 (base + all 7 mutations); python3 tools/asahi/run-host-tests.py --only asahi- --jobs 8 passed 3/3 (asahi-g15, asahi-m4, asahi-stats-raw-tests).
  • Static & checkpatch: scripts/kernel-doc -Werror -none drivers/hwmon/macsmc-hwmon.c passed (0 warnings); scripts/checkpatch.pl --git c50540c8ef05..HEAD reported 0 errors (0 warnings on commits 1–2; 1 standard new-file MAINTAINERS warning on tools/asahi/m5-hotspot-fans-dt-tests.py; spdxcheck.py skipped due to missing ply).
  • Compile, KUnit & DTB validation:
    • arm64 (LLVM=1, Rust 1.99.0, W=1) build of drivers/hwmon/macsmc-hwmon.o, drivers/gpu/drm/asahi/g17/fans.o, and drivers/gpu/drm/asahi/built-in.a passed with 0 errors and 0 new warnings.
    • KUnit (arm64 QEMU): macsmc* passed 39/39 (macsmc-parser 16/16, macsmc-hwmon 4/4, macsmc-hwmon-fan 19/19 including macsmc_fan_test_manual_only_request).
    • CHECK_DTBS=y on apple/t6050-{j714s,j716c,j716s,j775d}.dtb built 4/4 DTBs with 0 hwmon/smc schema warnings (only pre-existing pcie/dart/opp-v2 warnings on j714s and j716c).
  • Earlier hardware check on J716c (earlier head with 98 °C / 82 °C / 30 s curve, default command line, Borealis):
    • Two Cyberpunk T2 passes at 2560x1600 rendered 30.07 and 30.01 FPS. The hotspot crossed 98 °C with the GPU busy three times; each time both fan targets reached 5,349 and 5,777 RPM by the next 1 s sample with tachs following, and returned to SMC automatic (1,350 and 1,458 RPM) 30–32 s after dropping below 82 °C or going idle. Peak hotspot was 104.5 °C, with 0 refused fan requests in dmesg and the GPU staying at its top performance state.
    • Earlier interleaved 4K Cyberpunk runs on J716c: automatic cooling 23.59 / 25.25 FPS (p95 49.23 / 45.63 ms) vs rated fan speeds 26.44 / 26.61 FPS (+8.6% mean; p95 43.02 / 42.25 ms); fan-only policy trials 26.79 / 27.16 / 27.09 FPS with GPU budget held at 196,098 mW.

Still to run

  • Machine-derived policy & loader wiring: Identify the machine/firmware source for apple,soc-die-fan-trip-millicelsius, apple,soc-die-fan-hysteresis-millicelsius, and apple,soc-die-fan-hold-ms (neither the J716c ADT nor currently known SMC keys expose those three values yet) and wire Aura / loader population before merge.
  • Off-case hardware check on 16bd9275b6d4: Run J716c on this commit under sustained GPU load on the default command line (without the DT trip properties set), confirming 0 kernel fan requests and fans remaining in SMC automatic mode, plus off-case regression checks on J714s, J716s, and J775D.
  • On-case hardware check (after loader/source work): Verify J716c with the machine-derived DT trip properties active, confirming the THERMAL_TRIP_ACTIVE trip on macsmc_soc_die, fan boost/release under GPU load, 0 failed units, 0 SELinux denials, and 0 new kernel errors.
  • Merge arm64: dts: apple: enable J716c fan and hotspot monitoring #2208 and hwmon: macsmc: retain fan ownership until automatic mode is restored #2209, retarget base to integration/aurora, and run full CI (host-tests and dt-checks).

Assisted-by: LLM (Anthropic:Claude, OpenAI:GPT-6.2 Sol, Google:Gemini 4 Neon, Google:Gemini 4 Hydrogen)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for measuring this; a 109 C hotspot under automatic cooling is worth fixing.

Our convention is that a fix needed for the machine to behave well is on by default and selected by what the hardware describes, not by a module parameter. Here the fan assistance only runs with aurora.m5_thermal_governor=2 (drivers/gpu/drm/asahi/g17/thermal.rs:117, documented at drivers/gpu/drm/asahi/asahi_core.rs:141), and the default stays off, so no user gets it.

Could the fan-only mode be the default wherever the board's DT describes writable fans (apple,fan-manual-control) and the hotspot input, as #2208 does for the J716c? The parameter could stay as an opt-out while it settles. If there is a reason it must stay off on some M5 boards, a comment naming it would help. We are happy to run rows on other machines once it is the default. A CI run on this head would also be needed.

@RyanTheTide

Copy link
Copy Markdown
Contributor

hotspot_fans_only() in drivers/gpu/drm/asahi/g17/thermal.rs is true only when the m5_thermal_governor module parameter is exactly 2, and its default stays 0, so the fan assistance described in this PR never runs on a stock boot. If requesting rated fan speed at a 98 C hotspot under GPU load is the right policy, enable it by default on devices whose DT describes the fans and the hotspot zone, and keep the existing flags out of the decision. Until then this should stay a draft.

@RyanTheTide
RyanTheTide marked this pull request as draft November 20, 2026 23:53
@erikwb
erikwb force-pushed the j716c/hotspot-fan-assist branch from 66455a4 to 700e8df Compare November 21, 2026 15:50
@erikwb

erikwb commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of erikwb

Thanks, done in cde97c9.

  • On by default, selected by the DT. The assistance runs wherever the device tree's SMC hwmon node, if available, describes:

    • the hotspot: TCMb as the only key of the SoC die zone, which is also the only input the assistance reads;
    • at least one fan a policy may set (apple,fan-manual-control) that names its mode, target, minimum and maximum keys.

    The kernel fan request writes every fan that names a mode key, so the check requires the property on each of them. One opened fan doesn't open its siblings. Every boost request goes through asahi_fans_request_described() in g17/fans.c, which checks the device tree node of the bound provider it writes to, under the provider lock, so a replaced provider is checked again. When the board is selected, asahi_fans_hotspot_described() scans for such a node with every parent available, so a disabled or missing hwmon node never arms the governor. No board or chip list is involved.

  • Existing flags out of the decision. Bit 1 and the & 3 == 2 mode are gone, and the opt-out is a separate parameter, aurora.m5_hotspot_fans=0. One interaction is left: whenever the host power budget controller (m5_thermal_governor bit 0, off by default) is enabled, it owns the fans with its own curve, and the assistance does not run.

  • Boards that stay off, and why (all from their device trees):

    • The J714s deletes the SoC die zone to use temperature discovery, so it doesn't describe the hotspot zone. Giving it back a TCMb die zone, which is a separate DT change, would turn it on.
    • The J716s and the J775D don't open their fans to a policy. The J775D's fans stay writable by the kernel budget controller when that is enabled, as before.
  • Hotspot and hold behaviour. Without a hotspot reading the boost ends at once rather than after the 30 s hold, so the fans go back to the SMC's policy. While boosted, the request is repeated on each step on which the GPU is busy and the hotspot is at or above 82 °C, so a hwmon driver rebound between two such steps gets the fans set again. During the hold it is not repeated: fans the SMC took back then stay automatic until such a step comes or the hold ends. A step that finds no provider reads no hotspot and ends the boost, and a new one starts at 98 °C.

  • Test. tools/asahi/m5-hotspot-fans-dt-tests.py compiles these checks unchanged against libfdt, with a recording stand-in for the fan request. It runs them on synthetic trees (mixed fans, fans without keys, an opted-in node under a disabled SMC beside a live unopted one) and on the J714s, J716s, J775D and J716c trees, the J716c with arm64: dts: apple: enable J716c fan and hotspot monitoring #2208's full description. For each provider it checks the exact set of fans an accepted request writes. It has five mutations and is registered in the host-test runner.

CI. This PR's base is #2209's branch, and host-tests only runs for PRs into integration/aurora/aurora-wip, which is why no checks were reported. Locally, tools/asahi/run-host-tests.py passes 432 of 433 runs on this head. The apple-dcp selftest run fails with the same 15 subtests on #2209's head. host-tests on this branch (workflow dispatch): https://github.com/aurora-silicon/linux/actions/runs/44921360153 passed (run on 700e8df, the same tree with an earlier commit message).

J716c, this head, no module parameter set. Two Cyberpunk T2 passes at 2560x1600: 30.07 and 30.01 FPS. The hotspot crossed 98 °C with the GPU busy three times, and each time both targets were at 5,349 and 5,777 RPM by the next 1 s sample, with the tachs following. They returned to the SMC (1,350 and 1,458 RPM) 30–32 s after the hotspot fell below 82 °C or the GPU went idle. Hotspot peak 104.5 °C. No refused fan requests in the kernel log.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, 700e8df covers the earlier review: the assistance is on by default, selected from the hwmon node (apple,fan-manual-control on every writable fan plus the TCMb die zone), the old flag bits are out of the decision, and the J716c run on this head shows it working with no parameter set.

One change of mind on our side. We suggested keeping a parameter as an opt-out, but we'd now rather not add m5_hotspot_fans (drivers/gpu/drm/asahi/asahi_core.rs:143). A board that shouldn't get the assistance already stays off by not describing writable fans in its device tree. Could you drop it? It still needs #2208 and #2209 and a CI run before it leaves draft.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Dropped m5_hotspot_fans and rebased onto updated #2209 (e9f4be3ea237) in d399c0dda9fc.

  • No module parameter: removed m5_hotspot_fans from drivers/gpu/drm/asahi/asahi_core.rs; hotspot_fans_only() in drivers/gpu/drm/asahi/g17/thermal.rs now checks !enabled() && HOTSPOT_FANS_DESCRIBED. Boards without apple,fan-manual-control on writable fans (or without apple,soc-die-keys = "TCMb") stay idle at probe, are refused (-EPERM) by asahi_fans_request_described(), and boards without writable fan keys also return -ENODEV from macsmc_hwmon_fans_request().
  • DT test fixture: updated J716C_2208 in tools/asahi/m5-hotspot-fans-dt-tests.py to match current arm64: dts: apple: enable J716c fan and hotspot monitoring #2208 (keeping inherited apple,discover-temperatures).
  • Verification: arm64 (LLVM=1, Rust 1.99.0) build of drivers/hwmon/macsmc-hwmon.o and drivers/gpu/drm/asahi/ (g17/fans.o + built-in.a) passed with 0 errors; tools/asahi/run-host-tests.py passed m5-hotspot-fans-dt-tests (6/6 incl. 5 mutations) and asahi-g15/asahi-m4/asahi-stats-raw-tests (3/3).

Keeping this PR in draft until #2208 and #2209 land and CI runs against integration/aurora.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, d399c0d drops m5_hotspot_fans; the assistance is now selected only by the hwmon node (thermal.rs:130-132, fans.c:110-116) and no parameter is involved. I also rechecked the release paths: the fan-only mode only ever asks for the SMC's rated maximum or hands the fans back, and a hold expiry, a lost hotspot reading, a missing provider, a partial request and GPU shutdown all release, so the worst case is fans at rated speed, never slower than the SMC's own curve.

Points on the new default-on path:

  • drivers/gpu/drm/asahi/g17/thermal.rs:232-245: the 98 C trigger, 82 C release and 30 s hold were only reachable with a module parameter before. Now they decide, by default, when the kernel takes the fans on every board whose DT opts in. The direction is safe (fans only go up), but thermal thresholds in a default-on path need to come from the machine: a trip on the macsmc_soc_die zone in the board's device tree (or an SMC/ADT value), with the assistance off where the tree gives none. As constants in the driver they would apply unchanged to a future board with a different die limit. This is the one point that blocks leaving draft.
  • drivers/gpu/drm/asahi/g17/fans.c:52-55 requires the die zone's only key to be the literal "TCMb". The assistance reads the macsmc_soc_die zone whatever its key (thermal.rs:217-221), so "exactly one die key" says the same thing without naming a SMC key in the GPU driver.
  • drivers/gpu/drm/asahi/g17/fans.c:28-64 walks the macsmc-hwmon binding (fan-* children, the fan keys, apple,fan-manual-control) from the GPU driver because macsmc_hwmon_fans_request() does not look at manual_control (drivers/hwmon/macsmc-hwmon.c:636-641). An option on the hwmon request to take only fans with apple,fan-manual-control, or a helper exported by macsmc-hwmon, would keep that knowledge in the driver that owns the binding.
  • Nit: the module doc at thermal.rs:3 still describes only the J714 budget governor.

Rows still needed before this leaves draft, as you list: CI on the rebased head, J716c on that head with #2208 and #2209 on the default command line, and J714s, J716s and J775D showing the assistance stays off (no kernel fan requests, fans in system mode under GPU load).

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb
erikwb force-pushed the j716c/hotspot-fan-assist branch from d399c0d to f1fe43d Compare November 22, 2026 07:52
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Addressed all four review points across three clean commits (d05aa5c618df..f1fe43deeeec): thresholds now come strictly from the machine's device tree (assistance stays off when omitted), no SMC key names or macsmc-hwmon DT schema walks remain in the GPU driver, and macsmc-hwmon owns manual-only fan filtering.

  • Blocker (§3 hardcoded 98 °C / 82 °C / 30 s): Removed all hardcoded thresholds and hold constants from drivers/gpu/drm/asahi/g17/thermal.rs. Added apple,soc-die-fan-trip-millicelsius, apple,soc-die-fan-hysteresis-millicelsius, and apple,soc-die-fan-hold-ms to Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml (required together alongside apple,soc-die-keys), wired macsmc-hwmon to parse them and register the matching THERMAL_TRIP_ACTIVE trip on macsmc_soc_die, and made thermal.rs read (trigger_mc, release_mc, hold_ms) from the bound macsmc-hwmon provider—staying off (and releasing any active boost) when the tree supplies none. Companion DT PR arm64: dts: apple: enable J716c fan and hotspot monitoring #2208 (t6050-j716c.dts) does not yet set those three properties, so J716c stays off until arm64: dts: apple: enable J716c fan and hotspot monitoring #2208 or a follow-up J716c DT commit adds them; keeping this PR draft until the DT properties and hardware re-test land.
  • No literal "TCMb" in the GPU driver: Replaced the "TCMb" check with checking that apple,soc-die-keys lists a single die key (of_property_count_strings(np, "apple,soc-die-keys") == 1 and die_listed == 1 && die_count == 1 at probe) inside macsmc-hwmon.c. tools/asahi/m5-hotspot-fans-dt-tests.py now asserts no "TCMb" or DT binding strings appear in g17/fans.c and verifies non-TCMb single die keys work.
  • macsmc-hwmon owns its DT binding and manual-only filtering: Added macsmc_hwmon_fans_request_manual(), macsmc_hwmon_hotspot_assist_available(), and macsmc_hwmon_hotspot_assist_policy() in drivers/hwmon/macsmc-hwmon.c + include/linux/mfd/macsmc.h. macsmc_hwmon_fans_request_manual() skips fans without apple,fan-manual-control, so g17/fans.c is now thin wrappers over those helpers with zero of_* / fan-* / apple,fan-manual-control parsing.
  • Nit (thermal.rs:3 module doc): Updated the module doc comment to reflect that hotspot fan assistance runs on boards whose device tree supplies SoC die fan-assistance trips and manual-control fans.
  • Verification: arm64 LLVM=1 Rust 1.99.0 build of drivers/hwmon/macsmc-hwmon.o and drivers/gpu/drm/asahi/ passed (0 errors, 0 new warnings); arm64 QEMU KUnit macsmc* passed 34/34 (including new macsmc_fan_test_manual_only_request); tools/asahi/run-host-tests.py --only m5-hotspot-fans passed 7/7 (base + all 6 mutations) and --only asahi- passed 3/3; dt_binding_check (hwmon/apple,smc-hwmon.yaml) and CHECK_DTBS=y (t6050-{j714s,j716c,j716s,j775d}.dtb) passed with 0 errors and 0 warnings (including synthetic dt-validate checks for valid and partial trip properties).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at f1fe43d: the hardcoded 98 °C / 82 °C / 30 s are gone, the assistance registers a real active trip on macsmc_soc_die only when all three new properties are present, and with none of them in any tree today it stays off everywhere. That's the fail-closed shape asked for, and moving the manual-only fan filtering into macsmc-hwmon keeps the binding knowledge where it belongs.

One thing for the follow-up that sets these values: they need to come from the machine as well, filled by aura from the ADT (or read from the SMC), not typed into a board .dts, or the magic numbers just move from the driver to the tree. Please note the intended source in the binding's description. Rows when a tree turns it on: J716c with the values filled, plus a Mac without them showing no kernel fan requests.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb
erikwb force-pushed the j716c/hotspot-fan-assist branch from f1fe43d to 4428791 Compare November 22, 2026 17:05
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Updated Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml in commit 1 (da4a7e383637, restacked unchanged driver/test commits as 5c7dce6aa665 and 4428791069e8) to state explicitly on all three properties (apple,soc-die-fan-trip-millicelsius, apple,soc-die-fan-hysteresis-millicelsius, and apple,soc-die-fan-hold-ms) that they are intended to be populated by the boot loader (Aura) from the machine's ADT or SMC rather than hardcoded in static board .dts files.

Also updated the PR body's Change and Still to run sections to reflect Aura/ADT/SMC population instead of static t6050-j716c.dts values. Re-verified make ARCH=arm64 LLVM=1 dt_binding_check DT_SCHEMA_FILES=hwmon/apple,smc-hwmon.yaml (0 errors, 0 warnings), run-host-tests.py --only m5-hotspot-fans --jobs 8 (7/7 PASS), and scripts/checkpatch.pl (0 errors). Keeping Draft until the Aura/ADT/SMC population and hardware rows land.

@erikwb
erikwb marked this pull request as ready for review November 22, 2026 21:26
@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 4428791: against f1fe43d only the binding text and the first commit message changed (the loader-populated note on all three properties); the hwmon and GPU commits are identical. Thanks, that covers the point from the last pass.

Two things left:

  • "ADT or SMC" is still open-ended. Which ADT node/property or SMC key will the loader read these three values from? If neither carries them, there is nothing for the loader to fill and the assistance stays off for good, so it would help to name the source now, before the binding lands.
  • The PR is now marked ready, but the description still lists the loader work and both hardware rows as to-run, and the earlier reply said it would stay draft. Since no tree sets the properties, the row that can be run at this head is the off case: the J716c at 4428791 under sustained GPU load, showing no kernel fan requests and the fans staying in SMC automatic mode. The on case needs the loader change.

Assisted-by: LLM (Claude:Opus 5.5)

…properties

Allow an SMC hwmon node that exposes a single SoC die sensor key to
declare the machine-specific active fan-assistance trigger temperature,
release hysteresis, and minimum hold time in the device tree. These
properties are intended to be populated by the boot loader (Aura) from the
machine's ADT or SMC rather than hardcoded in static board .dts files. All
three properties must appear together alongside apple,soc-die-keys; boards
that omit them leave kernel hotspot fan assistance disabled.

Signed-off-by: Erik Bourget <erik@ebourget.net>
Keep apple,smc-hwmon device-tree binding knowledge inside macsmc-hwmon
instead of making consumer drivers parse its DT schema:

- Add macsmc_hwmon_fans_request_manual(), which behaves like
  macsmc_hwmon_fans_request() but only drives fans whose device-tree
  node carries apple,fan-manual-control (leaving other fans untouched).
- Parse apple,soc-die-fan-trip-millicelsius,
  apple,soc-die-fan-hysteresis-millicelsius, and
  apple,soc-die-fan-hold-ms when a single key is listed in
  apple,soc-die-keys, and register the matching THERMAL_TRIP_ACTIVE trip
  on the macsmc_soc_die thermal zone.
- Export macsmc_hwmon_hotspot_assist_available() and
  macsmc_hwmon_hotspot_assist_policy() so thermal consumers can query
  whether the board enables hotspot fan assistance and read its
  machine-supplied thresholds and hold duration without hardcoding
  limits or SMC key names.
- Add KUnit coverage for macsmc_hwmon_fans_request_manual() and
  macsmc_hwmon_hotspot_assist_policy().

Signed-off-by: Erik Bourget <erik@ebourget.net>
Under sustained GPU load on boards whose SMC automatic curve lets the
SoC hotspot climb high, add hotspot fan assistance in
drivers/gpu/drm/asahi/g17/ that leaves the firmware's GPU power budget
and CPU frequency limits alone:

- Read the trigger temperature, release temperature (trip minus
  hysteresis), and hold duration from the bound macsmc-hwmon provider
  via macsmc_hwmon_hotspot_assist_policy(). When the board's device tree
  supplies no thresholds, or when no single-sensor macsmc_soc_die
  provider with a settable apple,fan-manual-control fan is bound, the
  assistance stays off and releases any active boost.
- While the GPU is busy and the SoC hotspot reaches the DT trigger
  threshold, request rated speed on manual-control fans via
  macsmc_hwmon_fans_request_manual(). Return them to automatic control
  after the DT hold duration in which the GPU was idle or the hotspot
  stayed below the DT release threshold, or at once when the hotspot
  cannot be read.
- A partial request (a later fan refusing after an earlier one accepted)
  is released before the next attempt, and failed budget boost or first
  curve requests are tracked as release-pending until unrestricted cleanup
  succeeds. While boosted, the request is repeated on each step on which
  the GPU is busy and the hotspot is at or above the release threshold,
  restoring rated speed if the hwmon provider was unbound and rebound in
  between. Whenever the host power budget controller (m5_thermal_governor
  bit 0) is enabled, it owns the fans with its own curve and hotspot
  assistance stays off.
- No SMC key names, chip/board lists, or macsmc-hwmon DT schema walks
  live in the GPU driver: all DT selection, threshold parsing, and
  manual-control fan filtering are delegated to macsmc-hwmon helpers.

tools/asahi/m5-hotspot-fans-dt-tests.py compiles the macsmc-hwmon DT
checks and GPU fan wrappers against libfdt with a recording stand-in for
macsmc_hwmon_fans_request_manual(), runs them across synthetic trees and
the T6050 board trees (confirming J716c stays off without DT trips and
governs with DT trips), compiles FanBoost from thermal.rs with rustc to
test partial budget/hotspot request failure and handoff cleanup, verifies
all 7 mutations are caught, and asserts no SMC key names or macsmc-hwmon
DT binding strings appear in drivers/gpu/drm/asahi/g17/fans.c.

Signed-off-by: Erik Bourget <erik@ebourget.net>

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

Formal adversarial pre-PR checklist review (§1–§6) at 4428791069e8ba0815227baad21bd5e8b3ff6e10.

Code & Architecture Verification

  • Moving DT parsing and manual-only fan filtering (macsmc_hwmon_fans_request_manual(), macsmc_hwmon_hotspot_assist_available(), macsmc_hwmon_hotspot_assist_policy()) into drivers/hwmon/macsmc-hwmon.c and removing the hardcoded 98 °C / 82 °C / 30 s constants and "TCMb" literal from drivers/gpu/drm/asahi/g17/ is structurally clean and fail-closed.
  • Verified FanBoost::release() -> request_fans(0, 0) only touches fan->kernel fans (macsmc_hwmon_fan_auto checks fan->manual after skipping fan->manual && !fan->kernel), and verified hold_ms * 1_000_000 / trigger_mc / release_mc validation cannot overflow or invert.

Blockers

  1. §1 Chicken-and-egg / §3 Undefined machine source for the new DT binding (Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml):
    • The three new properties (apple,soc-die-fan-trip-millicelsius, apple,soc-die-fan-hysteresis-millicelsius, apple,soc-die-fan-hold-ms) state they are "intended to be populated by the boot loader (Aura) from the machine's ADT or SMC", without naming which concrete ADT node/property or SMC key supplies them and without a companion/landed Aura loader producer.
    • Per §1 ("Chicken and egg: if the property must first come from the boot loader or DT, land that side first") and §3 ("Safety values come from the machine, never from hardcoding"), identify the exact ADT property or SMC key that carries these thresholds before landing a new kernel DT ABI that currently stays inert on every Mac.
  2. Unmerged stacked base (#2209) and 0 live CI checks:
    • Base branch is j716c/macsmc-fan-auto-retry (#2209, still open; #2208 is also still open). Because this PR does not target integration/aurora, 0 CI checks (host-tests, dt-checks) ran on 4428791069e8. Once #2209 lands, rebase and retarget onto integration/aurora and confirm CI is green.
  3. §5 Evidence incomplete on live head 4428791069e8 (PR marked Ready while "Still to run" remains open):
    • The PR left draft (draft: false), but no hardware run exists on 4428791069e8 (the cited J716c Cyberpunk numbers came from an earlier head with hardcoded driver constants).
    • Provide live hardware runs on 4428791069e8 (or the rebased head) with the §5 regression gate (0 SELinux denials / 0 failed units / 0 new kernel errors): J716c off-case (no DT trips -> 0 kernel fan requests, fans stay in SMC automatic mode), J716c on-case once loader-populated values are available, and other M5 Macs (J714s / J716s / J775D). If the loader work is still pending, return this PR to draft per checklist header policy.

Checklist Summary (§1–§6)

  • §1 No model gating: Blocked (chicken-and-egg: loader/DT producer not landed; multi-Mac proof pending).
  • §2 Production-ready, no hacks: Pass in code (no module parameters, no sleeps/hacks; fail-closed when properties are absent).
  • §3 Safety: Blocked on naming the real machine source (ADT/SMC) for the three properties; runtime fail-closed behavior itself is sound.
  • §4 Clean-room & attribution: Pass (all 3 commits da4a7e38, 5c7dce6a, 44287910 carry human author/committer and human Signed-off-by: only, 0 AI commit trailers; PR body includes Assisted-by:).
  • §5 Evidence: Incomplete (0 live CI checks on 4428791069e8; no hardware boot/regression gate rows on current head).
  • §6 Naming: Pass.

Assisted-by: LLM (Gemini 4 Neon)

@erikwb
erikwb force-pushed the j716c/macsmc-fan-auto-retry branch from e9f4be3 to c50540c Compare November 23, 2026 22:18
@erikwb
erikwb force-pushed the j716c/hotspot-fan-assist branch from 4428791 to 16bd927 Compare November 23, 2026 22:18
@erikwb

erikwb commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Hydrogen responding on behalf of erikwb

Restacked onto refreshed #2209 (c50540c8ef05 over origin/integration/aurora 9540f807f5ab) as 16bd9275b6d4 (e2c950da0de1..16bd9275b6d4), addressing all review findings:

  1. Removed stale fan_control references (drivers/hwmon/macsmc-hwmon.c, commit message, PR description): Dropped the outdated fan_control module-parameter reference left over from pre-hwmon: macsmc: Drop the fan_control module parameter #2448 code/docs.
  2. Manual-only rollback & explicit ownership handoff (drivers/gpu/drm/asahi/g17/thermal.rs, drivers/hwmon/macsmc-hwmon-test.c, tools/asahi/m5-hotspot-fans-dt-tests.py):
    • Split FanBoost tracking into explicit budget-governor (budget_boosted, budget_release_pending, curve_rpm via request_fans) and hotspot-assistance (hotspot_boosted, hotspot_release_pending via request_fans_described) ownership.
    • Failed budget boost or first curve requests (apply_curve and budget_boosted in g17/thermal.rs) now attempt immediate unrestricted cleanup (set_budget(false)) and keep budget_release_pending set until release_budget() succeeds, so partial budget failures cannot leave a fan owned with all budget ownership fields clear across handoff.
    • Partial hotspot boost failures roll back strictly via set_hotspot(false, 0) (request_fans_described(0, 0) -> macsmc_hwmon_fans_request_manual(dev, 0, 0)), and request_fans_described(0, 0) handles an unbound provider identically to request_fans(0, 0).
    • Mode transitions (enabled() toggling on/off) explicitly finish releasing the outgoing owner through its own release path and clear since_ns before starting the incoming owner.
    • Extended macsmc_fan_test_manual_only_request in drivers/hwmon/macsmc-hwmon-test.c to verify macsmc_hwmon_fans_request_manual(&dev, 0, 0) leaves a non-manual fan held by macsmc_hwmon_fans_request() untouched, and added FanBoost Rust host tests (plus mutation drop-budget-release-pending) in tools/asahi/m5-hotspot-fans-dt-tests.py covering partial budget boost, first curve, and hotspot request failures through handoff cleanup.
  3. Machine-derived policy and hardware rows: Holding drm/asahi: add hotspot fan assistance without host power budgeting #2210 before merge until the machine-derived source for the three DT properties is settled and wired in Aura/loader. Still to run keeps the machine-derived policy requirement, the runnable off-case hardware row on 16bd9275b6d4, and the post-loader on-case hardware row separate.

Verified on 16bd9275b6d4: dt_binding_check (hwmon/apple,smc-hwmon.yaml, 0 errors/schema warnings; yamllint not installed), scripts/kernel-doc -Werror -none drivers/hwmon/macsmc-hwmon.c (0 warnings), scripts/checkpatch.pl (0 errors; 0 warnings on commits 1–2; 1 new-file MAINTAINERS warning on tools/asahi/m5-hotspot-fans-dt-tests.py), arm64 LLVM=1 W=1 build of macsmc-hwmon.o + drivers/gpu/drm/asahi/ (g17/fans.o, built-in.a), CHECK_DTBS=y on apple/t6050-{j714s,j716c,j716s,j775d}.dtb (0 hwmon/smc warnings), macsmc* KUnit 39/39 (macsmc-hwmon-fan 19/19), m5-hotspot-fans 8/8, and asahi- 3/3.

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.

3 participants