Repository navigation
thermal: apple-pmp: 200 ms cool slow poll on #3949 + #3766 - #3994
IronsideXXVI wants to merge 10 commits into
Conversation
…he GPU is idle The PMP firmware publishes a die record only while its CPU cluster has power. When every record is dark (`-ENODATA`), the driver reuses the last reading for a fixed 2 s (`APPLE_PMP_GATED_HOLD_NS`). On J604 (T8132), with cool polling slowed to 50-100 ms, an idle desktop routinely stays dark past 2 s, expiring the hold, logging repeated sensor errors, and clamping both CPU clusters at their floor while polling recovers. For a cool last reading (`< APPLE_PMP_GATED_HOLD_MC`), extend the dark hold past 2 s at 8 C/s of headroom below `APPLE_PMP_PASSIVE_MC` (clamped to [2 s, 10 s]: 8.25 s at 40 C, 6.5 s at 54 C, 2 s at >= 90 C), gated on the GPU rail (`PP1b`, sampled by the power worker every 500 ms) reading idle (`< 50 mW`, no error, timestamp <= 1 s old). Because every die record is a CPU record, the GPU rail gate prevents a busy GPU from heating the die unseen while CPU clusters are power-gated. Clear `rail_ns` on probe and across sleep (`apple_pmp_thermal_complete`) since `CLOCK_MONOTONIC` pauses during sleep. Non-`-ENODATA` errors, hot readings (`>= APPLE_PMP_GATED_HOLD_MC`), missing/stale/errored rail reads, GPU load (`>= 50 mW`), and dark spells past the scaled cap (10 s maximum) continue to take the stock fail-closed path immediately. Add KUnit coverage in `apple_pmp_test_dark_hold_gate`. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
Integrate the dark-sensor hold with upstream main's apple-pmp-hold.h gated-hold helper, CPU idle tracker, sleep/resume real-sample-age tracking, and thermal-zone fault-disable handling: - Gate extended dark holds in apple_pmp_sample() on both cpus_idle and apple_pmp_gated_gpu_idle() (PP1b < 50 mW, error-free, <= 1 s fresh, with rail_ns cleared on probe, cleanup, and across sleep). - Bound apple_pmp_gated_hold_sample() by apple_pmp_gated_hold_ns(valid_mc) (8 C/s headroom below APPLE_PMP_PASSIVE_MC, clamped to [2 s, 10 s]) instead of a flat 15 s cap. - Update apple_pmp_test_gated_hold() and tools/asahi/pmp-thermal-poll-tests.py for the headroom-scaled cap and rail_ns sleep-resume reset. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…P1b debounce On quiet idle Apple T8132 desktops, two idle-efficiency issues remain in apple-pmp-thermal: 1. Cool idle dark spells with both CPU clusters power-gated and the GPU idle can cross the 15 s hold ceiling or observe a single transient compositor PP1b >= 50 mW sample, collapsing the hold to 2 s and triggering a -ENODATA sensor error with a 1.8 s 5 ms fast-poll recovery storm. 2. Cool polling (< 90 C) wakes every 100 ms even though apple_pmp_cooling_sample() accepts slope intervals up to 250 ms and Level-0 timer wheel slack at HZ=250 keeps 200 ms polling strictly within 204 ms. Make three bounded adjustments while keeping all hot/load fail-closed guards intact: - Add headroom-scaled GPU-gated dark holds via apple_pmp_gated_hold_ns() and apple_pmp_gated_hold_sample_capped(): a 2 C/s budget below 75 C capped at 30 s (<= 46 C) while CPU clusters and the GPU rail are idle, a 4 C/s budget at 75..90 C (7.75 s at 75 C, 5.25 s at 85 C), and immediate 2 s fail-closed at >= 90 C or on CPU/GPU load. - Track rail_ns on successful SMC power polls (cleared across sleep, cleanup, and probe) and add apple_pmp_gpu_gate_idle() to require two consecutive fresh PP1b >= 50 mW samples before collapsing an active cool (< 75 C) dark hold back to 2 s, failing closed immediately on warm dies (>= 75 C), sustained GPU load, non-dark reads, or missing/stale/errored SMC reads. - Add apple_pmp_poll_interval_ms() to poll at 200 ms below 90 C when not in fast poll, keeping 100 ms at 90..94.9 C (preserving the 100 ms transient SRAM glitch hold) and 5 ms at >= 95 C or during fault, cooling, or recovery. Extend apple-pmp-policy KUnit tests and pmp-thermal-poll-tests.py to cover 200 ms vs 100 ms vs 5 ms poll cadence, headroom-scaled 30 s cool holds, and 1-sample PP1b debounce vs 2-sample fail-closed. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Review at ca69b4b55906. The GPU gate is an improvement on main, which holds a dark die for 15 s whatever the GPU does. At 75 C and above every hold is shorter than main's, and 95 C, faults and cooling still poll at 5 ms. Two paths are looser than the text says, and it overlaps two open PRs, so please take another round.
Must change
- The 90-95 C band gets the 200 ms poll on entry.
apple_pmp_slow_poll_work()queues the sample and re-arms with the oldslow_poll_msbefore that sample runs. I added that case to your poll harness: after a 92 C sample the next poll is still 200 ms away. From 94.9 C that is 200 ms unseen where main has 100 ms. #3949 fixes the cause, because it re-arms after the sample, so this should land on top of it and readslow_poll_msinapple_pmp_poll_reschedule(). - The first dark read after a wake now fails at once. With
rail_nscleared, the cap is 2 s from the last real read, not from the wake, soapple_pmp_gated_hold_resume()no longer does what its comment says. Replayed on the headers (40 C, 2 s dark, sleep, 1 s of suspend/resume time, dark read): main returns 0, #3766 returns 0, this returns -ENODATA, which caps the CPUs. Keepapple_pmp_gated_hold_ns(valid_mc)as the cap and let "GPU not idle" only start the 2 s clock, as #3766 does. - The longer hold needs a basis. Below 75 C the hold goes from 15 s to as much as 30 s at "2 C/s"; #3766 uses 8 C/s and 10 s. Neither number is measured. ANE, ISP and ProRes can heat a die whose CPU clusters are gated and whose PP1b reads under 50 mW. Please post the fastest rise measured in that state (ANE-only and ProRes-only, fanless and fan) and derive the budget from it.
Order: #3949, then #3766 (approved, J773g row queued), then this as a delta on both. Right now it conflicts with #3766 in 4 files, and in pmp-cooling.h the two merge without a conflict but both define apple_pmp_gated_hold_ns(), so it wouldn't build. It conflicts with #3949 in 2 files. If you'd rather this replaces #3766, say so on #3766 now, before its rows run.
Also: a board whose idle PP1b stays at or above 50 mW (an external display, for example) drops from a 15 s hold to 2 s. The J773g row has to show that doesn't bring the sensor-error caps back. The "100 ms at 90-95 C protects the transient hold" reason doesn't apply: below 100 C the 2 s hold covers it, and from 95 C the poll is 5 ms.
Checked on main 2c667a4b + this head: apple-pmp-thermal.o and apple-pmp-policy-test.o W=1 clean, apple-pmp-policy KUnit 17/17 (UML), pmp host tests 24/24, thermal 1/1, checkpatch --strict clean. Hosted CI shows as skipped at this head.
Rows at the next head: J773g (T8132): 30 min idle desktop on its display with PP1b logged and 0 sensor errors; idle to all-core and idle to GPU ramps vs base (peak C, time to first 5 ms poll); GPU load while the CPUs are dark; ANE-only and ProRes-only load from cool; 3 s2idle and 3 deep-sleep cycles with 0 sensor errors after wake. A fanless T8132 (J713 or J715) for the same ramps. Your J604 at the head. Other SoCs don't bind this driver.
Main already holds a cool dark die for up to 15 s while the CPUs are idle. Scaling that cap down to 2-10 s by headroom, and requiring a fresh idle GPU rail past 2 s, can only end a hold sooner. At 46 C the cap is 7.5 s, and each expiry costs sensor errors, capped CPUs and 5 ms polling until the sensors read again and the guard has stepped down. Over 10 idle minutes a J773g went from 78 to 371 "sensor error -61" lines and from 304.6 to 330.6 arch_timer interrupts per second. Go back to main's 15 s cap and keep the GPU gate, but let only a rail that reads busy start the 2 s clock. A failed or missing rail read leaves main's behaviour: the power policy already keeps the CPUs and the GPU at their floor for it. That also removes the rail timestamp: a stale reading can't hold the die longer than main does. Set the GPU threshold between what a J773g reads idle (0-43 mW) and under a light GPU load (1630 mW). 50 mW was within one 15 mW rail step of idle. The KUnit and host tests check that 10 idle minutes of 14 s dark spells cost no error and no fast poll. The host test also checks that mutations (a 7.5 s cap, a failed rail read that counts as GPU work, no GPU gate) are caught. Signed-off-by: DjDeveloperr <hey@djdev.me>
…urora-silicon#3994 Land slow_poll_ms on top of aurora-silicon#3949's single-hop delayed_work poll_work so apple_pmp_poll_reschedule() reads slow_poll_ms after apple_pmp_sample() updates it. Entering the 90-95 C warm band now switches the very next poll to 100 ms instead of waiting one stale 200 ms interval. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…to cool 200 ms slow poll Merge aurora-silicon#3766 (52e3af5, 250 mW GPU-busy dark-hold gate on top of main's 15 s APPLE_PMP_GATED_IDLE_CAP_NS) cleanly so aurora-silicon#3994 is a minimal delta on aurora-silicon#3949 + aurora-silicon#3766: - Drop the unmeasured 15 s -> 30 s dark-hold cap expansion (deferring any > 15 s extension until ANE-only and ProRes-only die ramp measurements are collected on fan and fanless T8132). - Drop the 50 mW rail_ns / apple_pmp_gpu_gate / apple_pmp_gated_hold_sample_capped() path, inheriting aurora-silicon#3766's apple_pmp_die_idle() (250 mW busy threshold, failed rail reads left on main's path) and apple_pmp_gated_hold_sample(), which also fixes the post-wake first dark read failure. - Keep cool-only 200 ms slow polling (< 90 C, 100 ms in 90-94.9 C on immediate entry via aurora-silicon#3949's apple_pmp_poll_reschedule(), 5 ms at >= 95 C, cooling, or fault) and clean up the inaccurate transient-hold comment. - Extend KUnit (17/17: cool poll cadence, 10-min 200 ms dark-idle rate = 3000 polls / 0 errors, post-wake dark-read replay) and host poll tests (including 92 C warm-band immediate 100 ms entry + mutation test). Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
|
Thanks for the thorough review, @DjDeveloperr. Addressed every point with two clean forward merges (
Offline verification at
|
Use 10ULL, 14ULL, and 600ULL when multiplying by NSEC_PER_SEC in apple_pmp_test_dark_idle_rate() so the multiplications do not overflow 32-bit signed long on 32-bit KUnit builds before converting to u64. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
…e_rate() Use 10ULL, 14ULL, and 600ULL when multiplying by NSEC_PER_SEC in apple_pmp_test_cool_dark_idle_rate() so 32-bit KUnit builds do not overflow signed long before conversion to u64. Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
|
Forward-merged Verified offline at
|
RyanTheTide
left a comment
There was a problem hiding this comment.
The worker now chooses the next interval after sampling. That puts entry into the warm band on the 100 ms path immediately and keeps errors and active cooling at 5 ms. The longer dark-hold change was dropped, and the revised test widens its duration constants before multiplication. The exact hardware row is still pending.
What: Add a cool-only
200 msslow poll cadence (< 90 C) toapple-pmp-thermalon Apple T8132, landed cleanly on top of#3949(single-hopdelayed_work poll_work) and#3766(52e3af5dd8ac,250 mWGPU-busy dark-hold gate on top ofmain's15 scap):200 msslow poll (< 90 C): Addapple_pmp_poll_interval_ms()ininclude/linux/soc/apple/pmp-cooling.handslow_poll_msindrivers/thermal/apple-pmp-thermal.cso settled cool polling (< 90 C,!fast_poll) runs at200 ms(50 jiffies atHZ=250, Level-0 timer wheel,<= 204 ms, strictly insideapple_pmp_cooling_sample()'s50-250 msslope window), while keeping100 msin90..94.9 Cfor tighter ramp tracking approaching95 Cand5 mshrtimer polling at>= 95 Cor during error, cooling, or recovery.100 msentry on90..94.9 C: Built on#3949's single-hopdelayed_work poll_worksoapple_pmp_poll_reschedule()readsslow_poll_msafterapple_pmp_sample()updates it. Entering90..94.9 Cfrom a cool200 mspoll schedules the very next poll at100 ms(never a stale200 ms).probe(),setup(),change_mode(), andprepare()initializeslow_poll_msconservatively to100 ms.#3766/main's15 sdark hold and250 mWGPU gate: Drops the earlier unmeasured30 sdark-hold cap expansion and50 mWrail_ns/debounce path; inherits#3766 @ 52e3af5dd8ac'sapple_pmp_die_idle()andapple_pmp_gated_hold_sample()verbatim so post-wake dark reads hold identically tomainand#3766.apple-pmp-policyKUnit (17/17, addingapple_pmp_test_cool_poll_intervalandapple_pmp_test_cool_dark_idle_rate:0errors and3000polls across 10 idle minutes + post-wake dark-read replay) andtools/asahi/pmp-thermal-poll-tests.py(all#3949single-hop invariants,#3766dark_sensor_tests(),92 Cimmediate100 msentry test, and4/4mutation checks).Tested:
c36b5a0d3(clean forward merges of#3949 @ 564e67a67c6band#3766 @ 52e3af5dd8acintoj604/apple-pmp-cool-poll-dark-hold, 0 merge-tree conflicts againstorigin/main):scripts/checkpatch.pl --strict:0errors,0warnings,0checks (905lines checked).LLVM=1 W=1 KCFLAGS="-Werror":drivers/thermal/apple-pmp-thermal.o(343168bytes):0warnings,0errors.drivers/thermal/apple-pmp-policy-test.o(274792bytes):0warnings,0errors.apple-pmp-policy(KASAN+UBSAN):17/17PASSED (0failed).python3 tools/asahi/pmp-thermal-poll-tests.py,-Wall -Wextra -Werror -fsanitize=undefined):PASS+4/4mutations caught (7.5 scap, failed rail read counts as GPU work, GPU work does not end hold, warm band stays at200 ms).linux-aurora 7.3.0.aurora1-1.1687(carrying200 mscool polling alongsidesched/topology,0kernel faults):pmp_scwakeup rate halved9.61 -> 4.89/s,PMPEV events=0 supp=0 serr=0, idle die33.8 C, deep-sleep wakerc=0.n=10): median114.58 -> 112.44/s(pmp_sc 4.90/sacross 11/12 windows);PHPCidle730.5 -> 681.5 mW(-49.0 mW),PMVR2071.0 -> 1979.9 mW(-91.1 mW).Risk: two-way door · M4 (T8132)
apple-pmp-thermal. Stacked cleanly on#3949+#3766 @ 52e3af5dd8ac(5files total relative tomain;#3994's own delta over#3949 + #3766is onlyapple_pmp_poll_interval_ms()+slow_poll_ms+ tests). Preserves5 msfast hrtimer polling at>= 95 C/ cooling / fault, immediate100 mspolling on entry to90..94.9 C,15 scool idle hold,2 sbusy / active-GPU (>= 250 mW) hold, and post-wake hold behavior; a plain revert restores100 mscool polling.Not yet:
#3949, then#3766, then#3994(both merged forward here so the branch builds and tests cleanly as a delta).c36b5a0d3) bare-metal hardware rows: J604, J773g (30 min idle desktop withPP1blogged and0sensor errors, idle->all-core and idle->GPU ramps vs base, GPU load while CPUs dark, 3s2idle+ 3 deep-sleep cycles), and fanless T8132 (J713/J715) ramps.> 15 sdark-hold extension is deferred to a separate PR once ANE-only and ProRes-only die ramp rates are measured on fan and fanless T8132.Details and verification
Scope (
j604/apple-pmp-cool-poll-dark-hold, headc36b5a0d3)#3949(564e67a67c6b, commit1e1c8e8f3) and#3766(52e3af5dd8ac, commitc36b5a0d3), zero force-push.drivers/thermal/apple-pmp-hold.h: identical to#3766 @ 52e3af5dd8ac.include/linux/soc/apple/pmp-cooling.h: addsAPPLE_PMP_POLL_MS(5U),APPLE_PMP_SLOW_POLL_MS(100U),APPLE_PMP_COOL_POLL_MS(200U),APPLE_PMP_COOL_POLL_MC(90000), andapple_pmp_poll_interval_ms().drivers/thermal/apple-pmp-thermal.c: setsslow_poll_msfromapple_pmp_poll_interval_ms()inapple_pmp_sample()and reads it in#3949'sapple_pmp_poll_reschedule(), resetting to100 msinprobe(),setup(),change_mode(), andprepare().drivers/thermal/apple-pmp-policy-test.c:17/17KUnit (KASAN+UBSANARM64 QEMU PASS).tools/asahi/pmp-thermal-poll-tests.py:PASS+4/4mutations caught.scripts/checkpatch.pl --strict:0 errors, 0 warnings, 0 checks(905lines checked).LLVM=1 W=1 KCFLAGS="-Werror":apple-pmp-thermal.o(343168B) andapple-pmp-policy-test.o(274792B),0warnings,0errors.