Repository navigation
thermal/drivers/apple-pmp: ride out idle dark sensors and preserve zone backoff - #2774
DjDeveloperr wants to merge 1 commit into
Conversation
|
The hold only engages when all six records are dark, so CPU heat should keep a real reading. Most of the change looks right: the guard still fails closed to level 8 while in error, apple_pmp_critical() still runs every poll, and recovery triggers an update straight away. A few things to address before this is safe on a fanless T8132:
Assisted-by: LLM (Claude:Opus 5.5) |
…ne backoff With cluster power-gating enabled for deep sleep, the T8132 PMP marks a cluster's die temperature records invalid (-ENODATA) while the cluster is power-gated in WFI. After cool-idle polling was slowed from 5 ms to 100 ms, quiet runtime idle routinely keeps all six PMP die sensors dark for 2.1-3.8 s at 41-54 C (and s2idle keeps clusters parked for >10 s across system sleep), exceeding the fixed 2 s APPLE_PMP_GATED_HOLD_NS timeout. Three compounding issues turned those benign idle dark stretches into repeated CPU minimum-frequency clamps and eventually a permanent lockup: 1. apple-pmp-thermal always expired the gated-sensor hold after 2 s even when the CPUs were idle and generating negligible heat, unlike the G16 cooling backstop which advances valid_ns while idle so the 2 s timeout starts only when work begins. 2. apple_pmp_thermal_prepare() skipped s2idle via pm_suspend_via_firmware() and apple_pmp_thermal_complete() only refreshed the power policy clock across deep sleep without refreshing the gated-sensor hold, letting both s2idle and firmware deep sleep consume the hold allowance before the first wake sample. 3. While cached_error was non-zero, apple_pmp_poll_work() continued calling thermal_zone_device_update() every 100 ms, stepping through all 16 exponential backoff increments of thermal_zone_recheck() (~330 s on non-EAGAIN faults; -EAGAIN rechecks every 250 ms without backing off) in ~1.55 s and tripping thermal_zone_broken_disable(). Once disabled, apple_pmp_change_mode() cleared pmp_thermal.enabled and permanently latched guard level 8 (minimum CPU frequencies) until reboot. Fix all three without adding knobs or board allowlists: - Extract the gated-sensor hold, CPU idle tracker, and zone-notify helpers into drivers/thermal/apple-pmp-hold.h. Integrate per-CPU idle counters over >=50 ms windows by accumulating busy and wall time across all online CPUs and dividing once in permille (APPLE_PMP_IDLE_BUSY_PERMILLE = 250, i.e., 25.0% of one core across the SoC) so per-CPU truncation cannot hide spread-out load. When the last valid sample was below APPLE_PMP_GATED_HOLD_MC (90 C) and CPUs are idle, hold the cool reading and advance valid_ns so the 2 s fail-closed timeout starts when CPU work begins, while tracking real_valid_ns separately to enforce a 15 s absolute fail-closed cap (APPLE_PMP_GATED_IDLE_CAP_NS) so non-CPU loads (GPU, ANE, media with gated CPU clusters) cannot suppress thermal fault detection indefinitely. Non-ENODATA errors, hot readings (>=90 C), and expired holds clear both timestamps so recovery always requires a fresh valid SRAM reading. - Pause both samplers and refresh a cool valid hold (resetting CPU idle baselines so post-wake dark reads stay bounded to 2 s) across both firmware deep sleep and s2idle in apple_pmp_thermal_prepare() and apple_pmp_thermal_complete(), and reset the hold on mode changes. - Notify thermal_zone_device_update() once on fault entry so thermal_core runs its full ~330 s exponential backoff on non-EAGAIN faults instead of tripping thermal_zone_broken_disable() at the 100 ms governor rate. Record fault_disabled when the zone is disabled during a non-EAGAIN fault (never overriding manual disables while healthy), and automatically call thermal_zone_device_enable() once sampling recovers so the zone exits the latched fault state through the normal 200 ms cool recovery ramp from guard level 8. - Update the gated-hold comments in include/linux/soc/apple/pmp-cooling.h and document the window, busy-permille, and idle-cap rationale in drivers/thermal/apple-pmp-hold.h. - Expand drivers/thermal/apple-pmp-policy-test.c to cover the 15 s absolute idle cap, non-truncating CPU idle tracker (priming, spread-out load, offline/re-online transitions), and fault-entry/recovery/re-enable zone notifications. Signed-off-by: Diljit Singh <[email protected]>
6f3cc69 to
fcd71a1
Compare
|
@RyanTheTide Thanks for the detailed review! Rebased onto
Assisted-by: LLM (Gemini:4 Neon) |
|
Not on integration/aurora: on daa9e2d apple-pmp-thermal still expires the gated-sensor hold after a fixed 2 s whatever the CPUs are doing. The commit applies cleanly on daa9e2d, and the PMP host tests pass on that tree (run-host-tests.py --only pmp, 22/22). The R2 changes answer the code points of the review (absolute cap, non-truncating busy accounting, zone re-enable). What is still missing is the fanless side: every row so far is from the J773g, and this changes how long a cool reading is trusted on the M4 Airs too. The J713 rows listed in the review (sustained all-core load, long idle with per-record validity, GPU-only and ANE-only load with idle CPUs, deep-sleep cycles including one straight after a hot load) are needed before this merges. |
There was a problem hiding this comment.
Verdict: HOLD at fcd71a1e.
Blockers:
drivers/thermal/apple-pmp-hold.h:57refreshes the absolute age of the last real sample even though resume supplies no sample. The device's.completecallback also runs after an aborted suspend. A cool reading aged 14.9 s becomes age zero on that path and can outlive the claimed 15 s cap.ktime_get_ns()already excludes suspended time. Preserve the real-sample timestamp across completion and add an abort or repeated-resume fixture demonstrating that only a valid sensor read renews the absolute cap.drivers/thermal/apple-pmp-thermal.c:582infers who disabled the thermal zone fromcached_error. Both a user disable during a fault and the core's fault disable call the same mode callback. The next good sample then automatically re-enables a zone an operator explicitly disabled during a fault. Preserve the manual mode policy by tracking the actual disable reason or leaving re-enable to the owner. Test both disable origins.- Justify the new protective hold interval with a machine-provided limit or retain the existing bound. Remove the AI attribution from the PR body, resolve the base conflict with a forward merge, and provide the outstanding fanless J713 workload and hot-suspend evidence on the resulting commit.
Checked: Read the full patch, the thermal core mode paths, and the existing review. The idle arithmetic now divides after accumulating CPU deltas. Compiled the exact resume helper in a host harness and observed the 14.9 s sample become age zero without a new reading. No DT files changed.
|
@DjDeveloperr: stale-PR closeout. Everything that is open, in one list:
|
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Hardware data point, J713 (MacBook Air M4, fanless), saved kernel
|
Problem
With cluster power-gating enabled for deep sleep, the T8132 PMP marks a cluster's die temperature records invalid (
-ENODATA) while the cluster is power-gated in WFI. After cool-idle polling was slowed from 5 ms to 100 ms, quiet systems routinely keep all six PMP die sensors dark for 2.1–3.8 s at 41–54 °C (and >10 s across s2idle), exceeding the fixed 2 sAPPLE_PMP_GATED_HOLD_NStimeout.Three compounding issues turned those benign idle dark stretches into repeated CPU minimum-frequency clamps and eventually a permanent thermal lockup:
apple-pmp-thermalalways expired the gated-sensor hold after 2 s even when CPUs were idle and generating negligible heat (unlike the G16 cooling backstop, which advancesvalid_nswhile idle so the 2 s timeout begins only when work starts).apple_pmp_thermal_complete()refreshed the power policy clock across deep sleep, but did not refresh the gated-sensor hold timestamp, letting suspend/resume consume the hold allowance before the first wake sample.cached_errorwas non-zero,apple_pmp_poll_work()kept callingthermal_zone_device_update()every 100 ms, stepping through all 16 exponential backoff increments ofthermal_zone_recheck()in ~1.55 s and trippingthermal_zone_broken_disable(). Once disabled,apple_pmp_change_mode()clearedpmp_thermal.enabledand permanently latched guard level 8 (minimum CPU frequencies) until reboot.Fix
No knobs or board allowlists:
drivers/thermal/apple-pmp-hold.hand integrate per-CPU idle counters over ≥50 ms windows. When the last valid sample was belowAPPLE_PMP_GATED_HOLD_MC(90 °C) and summed busy percentage across online CPUs is below 25% of one core, hold the cool reading and advancevalid_nsso the 2 s fail-closed timeout starts only when CPU work begins. Non--ENODATAerrors, hot readings (≥90 °C), and expired holds clearvalid_nsso fault recovery always requires a fresh valid SRAM reading.apple_pmp_thermal_complete()across deep sleep, and reset the hold on mode changes.thermal_zone_device_update()once on fault entry sothermal_coreruns its own exponential recheck backoff instead of prematurely disabling the zone at the 100 ms governor rate, and resume governor updates immediately upon recovery.drivers/thermal/apple-pmp-policy-test.c.Verification
Host / KUnit
drivers/thermal/apple-pmp-policy-test.c).Hardware (
dcp68, M4 Mac miniJ773g,7.3.0-ARCH-m4prod7)idle-pre-s2r.log):tz0=enabled,p0=4464000,p1=2892000,die=51.25–52.5 C,err61=0,disabled=0.NUB.SPMI0.SW3,0 -> 1) + 60 s post-wake cool idle (idle-post-s2r.log):tz0=enabled,p0=4464000,p1=2892000,die=50.25–53.25 C,err61=0,disabled=0.gpubench-vk+ 57-rowsuite/plan-90pct.txtsweep (boot2-clean-verify.log,gpubench-v3tc-clean-pmp.log):tz0=enabled,disabled=0, GPUsensor_errors=1->1 (+0).