Repository navigation
J700: CPU thermal policy on the thermal framework (power allocator, measured energy model) - #41
RyanTheTide wants to merge 10 commits into
Conversation
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.
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. The governor derives its gains from sustainable-power
and the gap between the switch-on and control trips; with a 15 C gap
(80/95 C) the P cluster swung between its lowest and highest P-state
every two seconds. A 62 C gap (33/95 C) gives gains of 40/80/8 mW per
degree, which held the clock within one P-state and removed the
first-second overshoot of all-core loads:
walk (removed) this
1 P core, 75 s 3504 MHz, 8 changes 3526 MHz (3504-3648)
92.6 C mean, 97.1 peak 93.9 C mean, 95.4 peak
all cores, 75 s P 2688, E 1464 MHz P 2315, E 2424 MHz
93.4 C mean, 103.9 peak 91.0 C mean, 92.6 peak
1 P core, 2 s burst - 4044 MHz, 87.7 C peak
2 P cores, 3 s, idle - 2916 MHz, 87.1 C peak
A single-core run after the sustained loads held the same clock
(3519 MHz), so the integral term, which only accumulates above the
control temperature, does not wind up in use.
The machine does not idle below about 45 C, so the governor is always
engaged, deliberately: the die can gain 40 C within one sensor period,
and dual-core bursts from idle must already be limited before the
first reading arrives. The critical trip is 110 C. sustainable-power
is the energy-model power held in a 75 s sustained load at about
93 C: 2.33 W with one P core busy, 2.58 W with all six, rounded to
2.5 W. The zones poll every 500 ms.
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]>
|
Long-soak results on the J700 with this PR, measured after the PR was opened. The stack kernel was the same; the DTB was byte-identical to the one tested.
The all-core clock steps down one OPP over the first minutes as the chassis heat-soaks, then holds. On a hot chassis the single-core case dithers over one to two P-states, where a fresh machine held one. The cause is the four P sensors taking turns as the most restrictive zone on a quantised OPP ladder. It is safe, and the mean is within 4% of the fresh result. If a flatter single-core clock matters more than response speed, the next step is a lower undershoot gain, via a wider switch-on/control gap, or a 1 s passive poll matched to the SMC update period. Both would need re-measuring. Raw series: 🤖 Generated with Claude Code |
|
Superseded by #43. Testing with a heavier floating-point load after this PR was opened disproved its "no windup" claim. With the 33 C switch-on the governor never resets its integral, so a heavy run lowered sustained clocks until reboot. #43 keeps the code and uses a 58 C switch-on with 1.5 W, which is stable across workloads and resets when the machine rests. Measurements and the trade-off are in #43. 🤖 Generated with Claude Code |
Replaces the J700's interim CPU thermal controller (
apple-smc-cpu-thermal) with the standard thermal framework, following the upstream structure and Asahi's T8103/T600x/T8112 energy-model method.What changes
#thermal-sensor-cells. The hwmon core already registers each SMC temperature channel as a thermal sensor.opp-microwattfor all 23 OPPs. The method matches Asahi's: one busy core per cluster at each OPP, read from the SMC core-rail meters. The P rail is PP0b, identified by its voltage following the P-state; the E rail is PPbb. Every CPU gets#cooling-cells.asahi.config. A small governor fix keeps zones without trips from warning about sustainable power.apple,cpu-thermal-policyDT and binding property.Why the trips look unusual
The SMC updates die temperatures once a second, and the die settles within that second. The governor's default gains, derived from an 80/95 C gap, oscillated between 744 and 4044 MHz every 2 s. A 62 C gap gives 40/80/8 mW/C, which the measured plant (about 5.7 C/W, one sample of delay) predicts to be stable, and the hardware confirmed it.
Results on the J700
A single-core run after all the loads held 3519 MHz, so there is no integral windup.
Checks
checkpatch --strict: clean.dt_binding_check: clean. The one pre-existing yamllint blank-line warning comes from the binding's original upstream commit.dtbs_check: clean apart from the pre-existing cs42l83 supply properties.Residual risks, also in the commit messages and review notes
🤖 Generated with Claude Code