Skip to content

J700: CPU thermal policy on the thermal framework (power allocator, measured energy model) — v2 - #43

Merged
RyanTheTide merged 12 commits into
aurora-wipfrom
feat/j700-thermal-framework-v2
Oct 8, 2026
Merged

RyanTheTide merged 12 commits into
aurora-wipfrom
feat/j700-thermal-framework-v2

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Replaces #41. The code is the same; the J700 zone parameters and the commit message change, because heavier-load testing after #41 was opened disproved two of its claims.

What changed from #41

#41 used a 33/95 C switch-on/control gap with 2.5 W sustainable power, giving gains of 40/80/8. Further testing found two problems:

  • Windup. The power allocator resets its integral only below the switch-on temperature, which this machine never reaches at 33 C. A heavy floating-point run lowered the sustained integer P clock from 2196 to 1944 MHz, and it stayed there until reboot. The integral is bounded only by total maximum power (about 7.8 W), so repeated heavy loads could drive it much further.
  • Workload sensitivity. A floating-point loop draws 2.7 times the P-core power of an integer loop at the same clock, so the loop gain varies by that factor. Gains of 68/135/14 oscillated on the FP load.

This PR uses 58/95 C with 1.5 W, giving gains of 40/81/8:

  • The machine idles at 48–53 C, so the controller, and any windup, resets whenever it rests.
  • It is stable on both loads.
  • 1.5 W is inside the sustainable range measured at about 93 C: 1.1 W for FP and 2.5 W for integer.

Results on the J700, from this device tree

Load Result
1 P core, burst from idle 4044 MHz for 1 s, then 3504; 83 C
2 P cores, burst from idle 4044 MHz for 1 s, then 1944–2688; 95.6 C peak
1 P core, integer, 75 s mostly 3336 MHz at 84–88 C
All cores, integer, 75 s P 1944 / E 2424 MHz, 85 C, no changes
All cores, integer, 10 min P 1620–1944 / E 2424 MHz, 86.5 C mean
1 P core, FP, 60 s 1944–2916 MHz, 92.6 C mean
All cores, FP, 90 s P 979 / E 2424 MHz, 92.5 C
All cores, integer, after the FP runs and 60 s idle unchanged: no windup

Trade-off, for the maintainer's decision

Compared with #41's gains and the removed walk, sustained P clocks are 5–20% lower, because the loop settles near 86 C rather than 95 C. In exchange it stays stable on every workload tried and never carries windup from one load to the next.

The documented sysfs parameters can trade some of that back. For example, integral_cutoff = 10000 measured P 2101 all-core at 89 C and 3487 single-core at 95.5 C, with the same idle reset. Positive windup within one busy session is the risk.

Checks

Build, W=1 on the touched drivers, checkpatch --strict, dt_binding_check and dtbs_check are all clean, apart from pre-existing items listed in #41. Raw data is in validation/overnight-20260927/thermal/.

🤖 Generated with Claude Code

RyanTheTide and others added 10 commits September 27, 2026 04:57
The hwmon core registers every temperature channel of the SMC hwmon
device as a thermal sensor (the driver sets HWMON_C_REGISTER_TZ), so a
board can back thermal zones with SMC temperatures.  The binding does
not allow the property that makes the node a sensor provider, though.

Allow #thermal-sensor-cells with one cell, the index of the temperature
channel in child-node order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Give the thermal framework what it needs to manage the A18 Pro (T8140)
CPUs:

- opp-microwatt for every OPP of both clusters, so the OPP core
  registers an energy model for the power allocator governor and the
  cpufreq cooling devices;
- #cooling-cells on every CPU, so the cpufreq cooling devices are
  registered;
- #thermal-sensor-cells on the SMC hwmon node, whose temperature
  channels the hwmon core already registers as thermal sensors.

The power values were measured on a MacBook Neo (J700) following the
method used for T8103/T600x and T8112: one busy core per cluster at
each operating point, pinned with scaling_min/max_freq, read from the
SMC's core-rail power meters.  The P cluster's core rail was identified
as the one whose voltage steps with the P-state (PP0b, 573 to 967 mV);
from 3144 MHz up, the rise of the rail shared with the E cluster (PPab)
is added.  The E cluster's meter (PPbb) does not register a single busy
core below 1788 MHz, so the E values are the cluster's idle reading
plus a quarter of the rise with all four cores busy.  The top P
operating points were measured from a cold die in 2 s windows so that
no thermal limit applied during the sample.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The MacBook Neo is fanless, so CPU frequency is its only cooling.
Describe a thermal zone for each of the six CPU die sensors the SMC
reports (E cluster Te05/Te0S, P cluster Tp01/Tp05/Tp09/Tp0D), each
throttling both clusters: they share one die and one heat spreader.
The power allocator splits each zone's budget by the CPUs' energy
models, with the E cluster weighted three to one because its cores do
several times more work per watt.

Two properties of this machine decide the parameters.  The SMC
refreshes the readings about once a second and the die settles within
that time after a power change, so the loop carries a full sample of
delay.  And the power a core draws per energy-model watt varies with
the workload: a floating-point loop drew 2.7 times the P-core power of
an integer loop at the same clock.  The governor derives its gains from
sustainable-power and the gap between the switch-on and control trips:

- 80/95 C with 2.5 W (gains 170/341/34 mW per C) swung the P cluster
  between its lowest and highest P-state every two seconds;
- 58/95 C with 2.5 W (68/135/14) oscillated on the floating-point load;
- 33/95 C with 2.5 W (40/80/8) was stable, but the governor only resets
  its integral term below the switch-on temperature, which this machine
  never reaches, so time spent above 95 C lowered the budget until the
  next reboot (measured: -11% sustained P clock after one heavy run);
- 58/95 C with 1.5 W (40/81/8) is stable on both loads and resets
  whenever the machine rests (it idles at 48-53 C).

This uses the last.  1.5 W lies inside the sustainable range measured
at about 93 C: 1.1 W for the floating-point and 2.5 W for the integer
load.  The critical trip is 110 C; the zones poll every 500 ms.

Measured on a J700 with this device tree (schedutil):

  1 P core, burst from idle     4044 MHz for 1 s, then 3504; 83 C
  2 P cores, burst from idle    4044 MHz for 1 s, then 1944-2688; 95.6 C
  1 P core, integer, 75 s       mostly 3336 MHz at 84-88 C
  all cores, integer, 75 s      P 1944 / E 2424 MHz, 85 C, no changes
  all cores, integer, 10 min    P 1620-1944 / E 2424 MHz, 86.5 C mean
  1 P core, float, 60 s         1944-2916 MHz, 92.6 C mean
  all cores, float, 90 s        P 979 / E 2424 MHz, 92.5 C
  all cores, integer, after the float runs and 60 s idle: unchanged

The removed walk ran one integer P core at 3504 MHz and all cores at
P 2688 / E 1464 MHz, but touched 103.9 C at the start of all-core
loads.  Sustained P clocks here are 5-20% lower in exchange for a loop
that stays stable on every workload tried and never carries wind-up
from one load to the next; the power allocator's sysfs parameters
(k_po, k_pu, k_i, integral_cutoff) can trade some of that back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
…it is used

power_allocator_bind() warns that sustainable power will be estimated
for every zone that does not provide it, including zones without any
passive or active trip point.  The governor never controls such a zone:
power_allocator_manage() returns early when there is no trip_max, and
the estimate is never computed.

With power_allocator as the default governor every trip-less zone, such
as the one each power supply registers for its battery, logs this
warning at boot.  Warn only when the zone has a trip the governor
controls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Device-tree thermal zones cannot name their governor, and the step_wise
default moves a cooling device by one state per temperature change.
The T8140 SMC reports die temperatures about once a second while the
die can heat by tens of degrees in that time, so step_wise needs many
seconds to reach a safe frequency and then oscillates around the trip.

The power allocator moves the cooling devices straight to the state
that fits the power budget and splits the budget between clusters by
their energy models.  Zones without a controlled trip are unaffected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The T8140 CPUs are now managed by the thermal framework: the SMC die
sensors back device-tree thermal zones and the cpufreq cooling devices
throttle both clusters.  The driver no longer has to register every
policy with the private SMC thermal controller, report DVFS faults to
it, or refuse the P-states above 2 without it.

A DVFS transition failure still stops further requests, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
This reverts commit cbbb866 ("hwmon: (macsmc-hwmon) Expose the CPU
sensors to the SMC thermal policy").

The J700 CPU die temperatures now reach the thermal framework the
standard way: the hwmon core registers each temperature channel as a
thermal sensor (HWMON_C_REGISTER_TZ) and the device tree's thermal
zones reference them.  The private sampler, its read cache and the
positional six-channel contract it imposed are no longer used.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The J700 CPU thermal policy was a controller outside the thermal
framework: it registered a zone with the step_wise governor but did its
own control through a frequency QoS request on each cluster, walking the
OPP tables from the hottest of six SMC readings.

The same machine is now described the standard way: device-tree thermal
zones on the SMC die sensors, the cpufreq cooling devices, and the power
allocator with an energy model measured on the hardware.  Nothing uses
the private controller any more, so remove it, its header and its
configuration.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The SMC hwmon node no longer selects a driver-internal thermal policy;
the J700's CPU die temperatures feed its device-tree thermal zones.
Remove apple,cpu-thermal-policy and reword the comments that described
the old positional contract.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
The property selected a CPU thermal controller inside the SMC hwmon
driver, which has been removed.  Boards now describe standard thermal
zones that refer to the SMC temperature channels through the node's
thermal sensor cells.  The property described Linux policy rather than
hardware, and no device tree uses it any more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Removing the private thermal-policy prerequisite for T8140 must not
admit high P-state tables on other SoCs without qualified protection.
Keep the T8152 ceiling at state 3 while T8140 uses thermal zones.

Carry the existing public T8152 metadata and per-SoC timeout convention
into this older thermal branch, so the ceiling applies when the branch
is integrated with the current Apple CPU frequency support. The T8152
metadata follows Acelogic's public implementation; no contributor
certification is added on their behalf. Other SoCs retain the default
transition timeout and their existing admission behavior.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
cpufreq: apple: retain the unmanaged T8152 P-state ceiling
@RyanTheTide
RyanTheTide merged commit 026b413 into aurora-wip Oct 8, 2026
RyanTheTide added a commit that referenced this pull request Oct 8, 2026
Preserve the original review commits and retain subsequent published repairs where superseded.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide deleted the feat/j700-thermal-framework-v2 branch October 8, 2026 10:22
DjDeveloperr pushed a commit that referenced this pull request Oct 16, 2026
…k-v2

J700: CPU thermal policy on the thermal framework (power allocator, measured energy model) — v2

Original contributor commits are preserved. Conflict resolutions retain the audited shared driver APIs and their integrated review fixes.

Contributor credit; Signed-off-by outstanding:
- 89ef1ce: Ryan <[email protected]>
Ryan integrates these contributions under DCO (b); no author signature is forged.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[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.

1 participant