Skip to content

thermal/drivers/apple-pmp: ride out idle dark sensors and preserve zone backoff - #2774

Merged
RyanTheTide merged 4 commits into
mainfrom
djdev/apple-pmp-thermal-idle-enodata
Dec 1, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
djdev/apple-pmp-thermal-idle-enodata

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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 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 thermal lockup:

  1. apple-pmp-thermal always expired the gated-sensor hold after 2 s even when CPUs were idle and generating negligible heat (unlike the G16 cooling backstop, which advances valid_ns while idle so the 2 s timeout begins only when work starts).
  2. 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.
  3. While cached_error was non-zero, apple_pmp_poll_work() kept calling thermal_zone_device_update() every 100 ms, stepping through all 16 exponential backoff increments of thermal_zone_recheck() 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

No knobs or board allowlists:

  • Extract gated-sensor hold and CPU busy-percentage helpers into drivers/thermal/apple-pmp-hold.h and integrate per-CPU idle counters over ≥50 ms windows. When the last valid sample was below APPLE_PMP_GATED_HOLD_MC (90 °C) and summed busy percentage across online CPUs is below 25% of one core, hold the cool reading and advance valid_ns so the 2 s fail-closed timeout starts only when CPU work begins. Non--ENODATA errors, hot readings (≥90 °C), and expired holds clear valid_ns so fault recovery always requires a fresh valid SRAM reading.
  • Refresh a cool valid hold and reset CPU idle baselines in apple_pmp_thermal_complete() across deep sleep, and reset the hold on mode changes.
  • Notify thermal_zone_device_update() once on fault entry so thermal_core runs its own exponential recheck backoff instead of prematurely disabling the zone at the 100 ms governor rate, and resume governor updates immediately upon recovery.
  • Add KUnit coverage for the gated-hold state machine and CPU busy accounting in drivers/thermal/apple-pmp-policy-test.c.

Verification

Host / KUnit

  • 33/33 UBSan KUnit checks + PMP host test suites passing (drivers/thermal/apple-pmp-policy-test.c).

Hardware (dcp68, M4 Mac mini J773g, 7.3.0-ARCH-m4prod7)

  • 60 s pre-S2R cool idle (idle-pre-s2r.log): tz0=enabled, p0=4464000, p1=2892000, die=51.25–52.5 C, err61=0, disabled=0.
  • 1× Real Deep Sleep (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.
  • Clean full 24-row gpubench-vk + 57-row suite/plan-90pct.txt sweep (boot2-clean-verify.log, gpubench-v3tc-clean-pmp.log): tz0=enabled, disabled=0, GPU sensor_errors=1->1 (+0).

@RyanTheTide

Copy link
Copy Markdown
Contributor

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:

  • drivers/thermal/apple-pmp-hold.h:89-95: while "idle", valid_ns advances on every dark sample, so a cool value is reported with no time limit (the test asserts this at apple-pmp-policy-test.c:177). Idle is the summed CPU busy% across the whole system (apple-pmp-thermal.c:374-407). GPU, ANE and media load are not counted. A GPU- or ANE-bound job with little CPU time and gated CPU clusters therefore shows the last cool value for as long as it runs. The G16 backstop still expires its own hold because it uses GPU idle, but ANE and media have nothing similar. Please add an absolute cap on time without a real sample, even when idle (fail closed once after it), and show whether all six records go dark under GPU-only and ANE-only load.
  • apple-pmp-thermal.c:551-559: notifying once on fault entry only slows the zone-disable path down. The core recheck backs off from 250 ms by x1.5 and still calls thermal_zone_broken_disable() after about 330 s (thermal_core.c:261-286). After that, apple_pmp_change_mode() latches guard 8 until reboot (:585-591). Failing closed on a persistent fault is reasonable, but please either state the ~5.5 min bound in the commit message or re-enable the zone once sampling recovers. Note also that a -EAGAIN cached_error never backs off.
  • apple-pmp-thermal.c:874,899: the resume refresh only runs when pm_suspend_via_firmware(), so the ">10 s across s2idle" case in the description is not what this path handles. Please say which sleep path the numbers come from. The refresh also accepts any pre-sleep value under 90 C. Clearing cpus_idle on resume bounds that to 2 s, which seems fine.
  • apple-pmp-hold.h:63 with apple-pmp-thermal.c:399: per-CPU percentages are truncated before summing, so ten CPUs at 2.9% count as 20 (idle) when the true total is ~29%. Sum busy and wall time first and divide once, or use permille.
  • include/linux/soc/apple/pmp-cooling.h:24-27 still says the longest dark stretch measured is 0.46 s, which contradicts the 2.1-3.8 s here. The 25% and 50 ms in apple-pmp-hold.h have no measurement behind them; please say how they were chosen.
  • Tests: the KUnit cases cover the hold state machine well. The poll-loop change (single update on fault entry, update on recovery) and apple_pmp_cpus_idle() priming and offline-CPU handling are not covered.
  • Hardware: every row is from J773g, which has a fan, and the kernel is not tied to this head. For J713 at 6f3cc69 please post:
    • a 10 min all-core load: hotspot, cpufreq max and guard level against time, base and PR;
    • 30 min idle with per-record validity, the longest all-dark stretch, guard level, and no "disabling" in dmesg;
    • single-thread load pinned to an E core and to a P core at ~20% and ~30% duty, showing the busy cluster's record stays valid;
    • a GPU-only and an ANE-only load with CPUs idle, showing the record validity and the G16 backstop level;
    • 20 deep-sleep cycles, including a suspend straight after a hot load, with the first post-wake sample and guard level;
    • thermal_zone mode staying enabled and guard level never latched at 8 throughout.

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 <hey@djdev.me>
@DjDeveloperr
DjDeveloperr force-pushed the djdev/apple-pmp-thermal-idle-enodata branch from 6f3cc69 to fcd71a1 Compare November 22, 2026 09:53
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

@RyanTheTide Thanks for the detailed review! Rebased onto integration/aurora (32bf9dd3569d2) and force-pushed R2 (fcd71a1ed5902) addressing all 6 items:

  1. Absolute cap on idle hold (apple-pmp-hold.h): Tracked real_valid_ns separately from idle-extended valid_ns and enforced a 15 s absolute fail-closed ceiling (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.
  2. Non-truncating SoC-wide CPU busy accounting (apple-pmp-hold.h, apple-pmp-thermal.c): Accumulated busy and wall time across all online CPUs over >=50 ms windows and divided 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, with offline/re-online transitions handled cleanly.
  3. Thermal zone backoff & auto-recovery: Notifies thermal_zone_device_update() once on fault entry so thermal_core runs its full exponential backoff instead of tripping thermal_zone_broken_disable() at 100 ms cadence; tracks fault_disabled only when disabled during a non--EAGAIN fault (never overriding manual disables while healthy) and re-enables the zone cleanly once sampling recovers.
  4. System sleep (s2idle + deep sleep): Pauses both samplers in apple_pmp_thermal_prepare() and refreshes a cool valid hold while resetting CPU idle baselines in apple_pmp_thermal_complete() (bounding post-wake dark reads to 2 s), and resets the hold on mode changes.
  5. Comments & documentation: Updated gated-hold comments in include/linux/soc/apple/pmp-cooling.h and documented window, busy-permille, and idle-cap rationale in drivers/thermal/apple-pmp-hold.h.
  6. Tests & live hardware verification:
    • Expanded drivers/thermal/apple-pmp-policy-test.c for the 15 s absolute idle cap, non-truncating CPU idle tracker (priming, spread-out load, offline/re-online), and fault-entry/recovery/re-enable zone notifications.
    • scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES: 0/0/0.
    • python3 tools/asahi/run-host-tests.py --only pmp: 22/22 passed.
    • python3 tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-sensor.py: passed (75,414 rows).
    • Live hardware (dcp72-m4prod11-wave5-v7tc-s2r, M4 Mac mini J773g / T8132, 7.3.0-ARCH-m4prod11): 2/2 consecutive real deep sleeps passed; across the 60 s cool-idle window tz0=enabled, aurora-g16 sensor_errors delta +0 (3 -> 3), and continuous dark spans rode out silently up to the bounded 15 s safety ceiling, firing fail-closed right on schedule at ~16–17 s (1364.83s, 1381.05s, 1398.06s) and stepping right back down to level=0 in <0.9 s.

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 24, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at fcd71a1e.

Blockers:

  1. drivers/thermal/apple-pmp-hold.h:57 refreshes the absolute age of the last real sample even though resume supplies no sample. The device's .complete callback 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.
  2. drivers/thermal/apple-pmp-thermal.c:582 infers who disabled the thermal zone from cached_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.
  3. 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.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@DjDeveloperr: stale-PR closeout. Everything that is open, in one list:

  1. Do not renew the real-sample age in .complete (the aborted-suspend case), and add a fixture for it.
  2. Track who disabled the zone, so that a manual disable during a fault is not re-enabled.
  3. A source for the new hold interval, or keep 2 s.
  4. Merge main (3 files conflict) and drop the Assisted-by trailer.
  5. The J713 fanless rows from the 11-23 comment, at the new head.
    This is thermal on a fanless Mac, so we will not fix it forward without you. If there is no reply in 24 h, we park it with this list.

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merge readiness at 2407acda: not ready yet

Check Detail
CI at head running running: host-tests
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 2407acda
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Hardware data point, J713 (MacBook Air M4, fanless), saved kernel 7.3.0-aurora-fleet91 (9c353d7, contains #3546), not this PR's head:

  • After 5 h 27 min uptime at ~38 C: thermal thermal_zone2: Unable to get temperature, disabling!, then apple-pmp-thermal: power telemetry error -11, retaining minimum CPU/GPU ceilings every 500 ms (1482 lines so far).
  • power_status: p_level=8 e_level=8 gpu_level=8 fault=1 error=-11. scaling_max_freq is 912000 (P) / 900000 (E) under a 10-thread load, cooling devices all at 0. It stays that way through a deep-sleep cycle; only a reboot clears it.
  • Same boot: H.264/HEVC/VP9/AV1 decode took ~6 s against 2.4-3.5 s on the other Macs, and the ANE MobileNet firmware time was 0.76 ms against 0.22 ms on the J616s.
  • Before the latch the log shows sensor error -61; CPU minimum caps retained bursts and Temperature check failed (-61) every ~4 s for about 80 s. That matches point 3 of the description (the zone is disabled, then level 8 stays latched).
  • An earlier fleet91 boot logged one telemetry error at 330 s and then recovered. The short boots in between were clean.

Conflicts in apple-pmp-thermal.c, apple-pmp-policy-test.c and
pmp-cooling.h: keep main's lifecycle-locked sleep prepare, main's hold
constants and its unbudgeted power tests; take this branch's gated
hold in apple_pmp_sample() and its resume refresh.
…ack who disabled the zone

Review items on the dark-sensor hold:

- apple_pmp_gated_hold_resume() renewed real_valid_ns, the age of the
  last real sensor read. .complete also runs after an aborted suspend,
  so a cool reading 14.9 s old became 0 s old with no new read and could
  outlive the 15 s cap. ktime_get_ns() does not count suspended time, so
  the cap needs no help across sleep: only restart the busy-hold clock
  (valid_ns) and leave the real-sample age alone.

- apple_pmp_change_mode() treated any disable during a sensor fault as
  the core's broken-sensor disable, so a zone that user space disabled
  during a fault was re-enabled by the next good read. The core disables
  from thermal_zone_broken_disable(), in the task whose temperature read
  just failed; record that task in .get_temp and count a disable as a
  fault disable only when it comes from it.

- Keep main's single transient PMP SRAM refresh glitch hold (100 ms
  below passive throttling, counted from the real read) that the merge
  would otherwise have dropped.

KUnit: aborted and repeated resumes do not stretch the cap, both disable
origins, the transient edges. pmp-thermal-poll-tests: mock the hold and
idle tracker that .complete now touches.
@RyanTheTide
RyanTheTide requested review from a team as code owners December 1, 2026 17:26

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

The manual-disable case still fails when one userspace thread reads thermal_zoneN/temp during a cached -ENODATA and then writes disabled to thermal_zoneN/mode before the next sample. temp_show calls the same get_temp, which saves current as failed_reader; mode_store then calls the same change_mode from that thread. I compiled the exact apple_pmp_fault_disable helper and confirmed it classifies this sequence as a core fault disable. The next good sample can therefore re-enable the manually disabled zone. Please use an explicit core fault-disable reason or leave re-enable to the owner.

@erikwb

erikwb commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

We carry this PR in our J713 (M4 Air, T8132) daily kernel alongside #3267.

With cluster power-gating and slower cool-idle PMP polling (including #3546 on main), quiet systems routinely see all six PMP die temperature records return -ENODATA for longer than 2 s (and across suspend/resume). Without this fix, apple-pmp-thermal expired the gated-sensor hold, exhausted thermal_zone_recheck() backoff in ~1.55 s, disabled the thermal zone, and permanently latched CPU/GPU guard level 8 (minimum frequencies) until reboot.

Running smoothly together with #3267 on our J713 daily kernel with no dark-sensor thermal zone disables or level-8 clamps.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 1, 2026
…hold.h

apple-pmp-thermal now resolves dark sensors in apple_pmp_gated_hold_sample(),
which calls apple_pmp_hold_nodata() from apple-pmp-hold.h. Check that the
driver includes the helper and the helper uses the shared hold.
@RyanTheTide

Copy link
Copy Markdown
Contributor

Taking this over to land it (fleet regression: a J713 on fleet91 latches at level 8, 912/900 MHz, after a few hours; ewb's daily driver needs it). Pushed onto this branch without force: a merge of main (6f41f3a), the review fixes (97dedbc) and a selftest update (2407acd).

Review items (App 11-28 HOLD + the 11-29 list)

  1. Aborted suspend renewing the sample age: apple_pmp_gated_hold_resume() now restarts only the busy-hold clock (valid_ns) and leaves real_valid_ns alone. ktime_get_ns() doesn't count suspended time, so the 15 s cap needs no carry-over. KUnit: two resumes without a sample, then a read at real + cap - 1 holds and at real + cap fails closed.
  2. Who disabled the zone: .get_temp records the task whose read failed. thermal_zone_broken_disable() runs in that task, inside the same update, so only a disable from it counts as a fault disable. A zone disabled from sysfs during a fault stays disabled. KUnit covers both origins.
  3. Hold interval: the 2 s busy bound is unchanged. The idle hold needs a cool last reading below 100 C and CPUs under 25 % of one core, and it has a 15 s absolute cap counted from the last real read. The J713 data below supports this: on this boot, sensor-dark spans latched the guard with and without thermal: apple-pmp: avoid P-core wakeups for cool idle polling #3546.
  4. Merged main: kept main's lifecycle-locked sleep prepare, its hold constants and its transient refresh-glitch hold (100 ms below passive, now counted from the real read inside the gated hold), and its unbudgeted power tests. The AI trailer was already gone.
  5. J713 rows: below.

Tests: KUnit apple-pmp-policy 13/13 (UML), run-host-tests.py --only pmp 24/24, --only asahi-m4 pass, W=1 LLVM arm64 build clean, checkpatch --strict 0/0/0.

Rows: 97dedbc driver + J713 (M4 Air, fanless) + PASS so far. This is apple-pmp-thermal built from the head driver files on fleet91 9c353d7. Main has the same copies of these files as fleet91; the delta since then is test-only. I swapped the module live on a boot that was latched at level 8.

  • Latched boot (8 h up, stock fleet91): after the swap, level 0, fault=0, zone enabled, 10-thread load P 3468 / E 2892 MHz.
  • The same boot with only thermal: apple-pmp: avoid P-core wakeups for cool idle polling #3546 reverted latched again 28 min later (Revert "thermal: apple-pmp: avoid P-core wakeups for cool idle polling" #3803, now on hold). This PR's logic then ran 35 min clean on that boot before the head build replaced it.
  • All-core sustained, 10 busy loops for 300 s: die up to about 107 C, the governor throttled P to level 8 and back to 4-5, fault=0, zone enabled the whole time.
  • Deep suspend straight after that load (rtc1, 20 s): resumed, level 0, no sensor errors logged.
  • GPU-only, glmark2 off-screen for 2 min with the CPUs 82-98 % idle: die up to about 84 C, level 0, fault=0, zone enabled.
  • A cool deep suspend: clean. 10-thread load afterwards: P 3468 / E 2172 MHz at level 0.
  • Not run: ANE-only load. Idle soak at the head driver is running and I'll post its result.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CHANGES REQUESTED at 97dedbc (one test line; everything else is ready)

Failure: host-tests at this head is 944/945. The one failure is asahi-m4, case test-thermal-policy.py (run 46703205769), and it reproduces locally:

tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-policy.py:302
assert 'apple_pmp_hold_nodata(' in (ROOT/'drivers/thermal/apple-pmp-thermal.c').read_text()
AssertionError

The same test passes on main (d148fbd Host tests: asahi-m4 ok). This head moves the apple_pmp_hold_nodata() call from apple-pmp-thermal.c into apple_pmp_gated_hold_sample() in apple-pmp-hold.h:199, so the source check no longer finds it. Fix only that line: check drivers/thermal/apple-pmp-hold.h for apple_pmp_hold_nodata(, and optionally check that apple-pmp-thermal.c still calls apple_pmp_gated_hold_sample(. Then asahi-m4 is 25/25 again.

Checked (delta 6f41f3a merge + 97dedbc against my 11-28 items):

  • Item 1 fixed: apple_pmp_gated_hold_resume() no longer touches real_valid_ns, only the busy-hold clock. An aborted or repeated .complete can't stretch the 15 s cap, and ktime_get_ns() already excludes suspended time.
  • Item 2 fixed: a disable counts as a fault disable only when it comes from the task whose get_temp just failed. In this tree thermal_zone_recheck() -> thermal_zone_broken_disable() -> __thermal_zone_device_set_mode() -> .change_mode runs synchronously in that same update, while a sysfs mode write comes from a user task. failed_reader is cleared on a good read, a mode change, cleanup and probe.
  • The merge keeps main's single transient SRAM-glitch hold (below passive, APPLE_PMP_TRANSIENT_HOLD_NS from the real read). There's no AI attribution in the body or commits.

Follow-ups (not blocking):

  • A single program that reads temp (failing) and then writes mode=disabled from the same thread would be counted as a fault disable. That's unlikely, but worth a comment.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 2407acd

Correction to my previous review at this head: it was written against 97dedbc. 2407acd had already fixed the one failure it named.

Checked:

  • 2407acd points the asahi-m4 source check at apple-pmp-hold.h and checks that apple-pmp-thermal.c includes it. test-thermal-policy.py now passes locally at this head (exit 0, including "Shared -ENODATA hold masks brief PMP refresh glitches ...").
  • 11-28 items 1 and 2 are fixed as described in my previous review: the real-sample age is no longer renewed by .complete, and the fault disable is attributed to the failing reader task, which thermal_zone_recheck() -> thermal_zone_broken_disable() -> .change_mode runs in synchronously.

Follow-ups (not blocking):

  • The same-thread case (one thread reads a failing temp, then writes mode=disabled) still counts as a fault disable, as the Ryan-account comment on 97dedbc notes. That's a narrow manual edge; track it as an issue.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 1, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Row: 2407acd + J713 (M4 Air) + PASS. Driver = 97dedbc's (the delta to 2407acd is the selftest only), built on fleet91. Latch cleared on a latched boot; all-core 300 s regulated with no fault; hot and cool deep suspends clean; GPU-only 2 min clean; idle at level 0 with the zone enabled for 50+ min so far. Details in the comment above. Merging per ORCH5 (ewb's J713 daily driver needs it). The App review's same-thread sysfs case (read a failing temp, then write mode from the same thread) follows in a small PR; it's a manual edge case, not a regression.

@RyanTheTide
RyanTheTide merged commit 76d0b51 into main Dec 1, 2026
4 of 6 checks passed
@RyanTheTide
RyanTheTide deleted the djdev/apple-pmp-thermal-idle-enodata branch December 1, 2026 18:05
@RyanTheTide

Copy link
Copy Markdown
Contributor

@erikwb this landed on main as 76d0b51 (merge of main + the review fixes on top of Dj's commit). Your J713 daily kernel can drop the carried copy once it rebases. If you see a level-8 latch or a zone disable after this, please post the power_status line and the journal around Unable to get temperature here or in a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants