Skip to content

thermal: apple-pmp: end an idle dark hold early only for GPU work - #3766

Open
IronsideXXVI wants to merge 4 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604-pmp-dark-hold
Open

IronsideXXVI wants to merge 4 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604-pmp-dark-hold

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What: End apple-pmp-thermal's cool dark-sensor (-ENODATA) idle hold early when GPU work is active on PP1b, while preserving main's 15 s idle cap (APPLE_PMP_GATED_IDLE_CAP_NS) when idle:

  • Add APPLE_PMP_GPU_BUSY_MW (250 mW, between J773g idle 0–43 mW and light GPU load 1630 mW) and apple_pmp_die_idle(cpus_idle, rail_error, gpu_mw) in drivers/thermal/apple-pmp-hold.h, and pass it to apple_pmp_gated_hold_sample() in drivers/thermal/apple-pmp-thermal.c.
  • Only a valid GPU rail read >= 250 mW ends an idle dark hold at 2 s (APPLE_PMP_GATED_HOLD_NS); a failed/missing rail read leaves main's behavior intact (since the power policy already holds CPUs and GPU at their floor on rail faults).
  • Add KUnit (apple_pmp_test_die_idle and apple_pmp_test_dark_idle_rate) and host-test (tools/asahi/pmp-thermal-poll-tests.py dark_sensor_tests() + mutation checks) coverage.

Tested:

  • At exact head 52e3af5dd8ac:
    • apple-pmp-policy KUnit: 15/15 PASSED (including 10-minute 14 s dark-spell rate test: 0 errors, 6000 slow polls).
    • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.
    • Clang arm64 W=1: drivers/thermal/apple-pmp-thermal.o and drivers/thermal/apple-pmp-policy-test.o clean (0 warnings).
    • Host tests (tools/asahi/pmp-thermal-poll-tests.py with mutation checks + test-thermal-policy.py): PASS.

Risk: two-way door · M4 (T8132) apple-pmp-thermal. Preserves main's exact 15 s idle hold whenever PP1b < 250 mW or on rail read errors; only ends an idle dark hold at 2 s (starting the normal busy-hold clock) when a valid PP1b read reports >= 250 mW so GPU work cannot heat a dark die unseen for 15 s. Revertible cleanly with no changes to thermal trips, fast-poll thresholds, or rail-fault policy.

Not yet:

  • J604 (M4, T8132) A/B at exact head 52e3af5dd8ac against current main (10-minute idle sensor error -61 / arch_timer / PP1b, plus GPU load while CPUs idle).
  • J773g row at 52e3af5dd8ac (pending J604 A/B vs main).
  • Fresh approving review at 52e3af5dd8ac.
History and relation to #2774
  • main (#2774, apple-pmp-hold.h) holds a cool dark die while CPUs are idle for up to 15 s (APPLE_PMP_GATED_IDLE_CAP_NS) regardless of GPU rail power.
  • Earlier head e49cdb436757 tightened the cap to 2–10 s at 8 C/s with a 50 mW fresh-rail gate, which regressed idle desktop hold expiries on J773g (+371 vs +78 sensor error -61 over 10 min at 43.5–46.5 C).
  • Commit 52e3af5dd8ac restores main's 15 s cap, drops the headroom formula and rail_ns, raises the GPU busy threshold to 250 mW, and leaves failed rail reads on main's path, keeping only the active-GPU 2 s fail-closed gate over main.

…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>
@IronsideXXVI
IronsideXXVI requested review from a team as code owners December 1, 2026 08:40
@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) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at 5d1e0cf9: not ready yet

Check Detail
CI at head ok 1 check passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 5d1e0cf9, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · M4 (T8132) apple-pmp-thermal. Preserves main's exact 15 s idle hold whenever PP1b < 250 mW or on rail read errors; only ends an idle dark hold at 2 s (starting the normal busy-hold clock) when a valid PP1b read reports >= 250 mW so GPU work cannot heat a dark die unseen for 15 s. Revertible cleanly with no changes to thermal trips, fast-poll thresholds, or rail-fault policy.

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 blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (bot) and removed needs-template PR body lacks Tested or Risk (bot) labels Dec 1, 2026
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>
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Merged main (65c41b72a) into j604-pmp-dark-hold (e49cdb436, no force-push) and integrated the dark-sensor hold with apple-pmp-hold.h:

  • Preserved main's CPU idle tracker (apple_pmp_cpus_idle()), sleep/resume real-sample-age tracking (apple_pmp_gated_hold_resume()), transient refresh-glitch hold, and PF_KTHREAD-scoped thermal-zone fault-disable handling.
  • Gated 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; rail_ns cleared in probe, cleanup, and across sleep).
  • Replaced the flat 15 s idle cap in apple_pmp_gated_hold_sample() with apple_pmp_gated_hold_ns(valid_mc) (8 C/s headroom below APPLE_PMP_PASSIVE_MC, clamped to [2 s, 10 s]).
  • Updated apple_pmp_test_gated_hold() and tools/asahi/pmp-thermal-poll-tests.py for the headroom-scaled cap and rail_ns sleep-resume reset.

Verified locally on e49cdb436:

  • scripts/checkpatch.pl: 0 errors, 0 warnings
  • make ARCH=arm64 LLVM=1 W=1 drivers/thermal/apple-pmp-thermal.o drivers/thermal/apple-pmp-policy-test.o: 0 warnings, 0 errors
  • ARM64 QEMU KUnit apple-pmp-policy (KASAN + UBSAN): 14/14 PASSED
  • python3 tools/asahi/pmp-thermal-poll-tests.py: PASS

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Dec 2, 2026

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

Correct, and after the merge with main it's a tightening. Main already holds a cool, dark die while the CPUs are idle, for up to 15 s (APPLE_PMP_GATED_IDLE_CAP_NS). This lowers that to a headroom-scaled 2-10 s, and holds past 2 s only while the GPU rail reads idle (< 50 mW, fresh). So a GPU load during a CPU-dark spell no longer goes unseen for 15 s. The rail age check fits the 500 ms power poll, and clearing rail_ns across sleep is right, since monotonic time stops.

Two notes, no code change needed:

  • The body's A/B was against the old 2 s hold, not today's main. Please restate Risk and Tested against main: the change versus main is the shorter cap plus the GPU gate. The thing to watch is more hold expiries (sensor-error CPU caps) on an idle desktop.
  • Hardware gates. PMP thermal is shared code, so it needs a row at this head on the M4 it targets plus one other generation. I've queued our J773g (idle desktop for 10 minutes: arch_timer rate and sensor-error lines vs main; a GPU load while the CPUs idle ends the hold) and the J700 (no regression). Your J604 run used your own tree, not this head.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Hardware A/B on J773g (M4 Mac mini, T8132, CONFIG_HZ=1000) at exact head e49cdb436757ec2e485042c9e0c111653b27dc56 vs stock 7.3.0-ARCH-m4main-6c83a2a6 — regression on idle desktop hold expiries / arch_timer wakeups (GPU-load path clean):

  • Trial (7.3.0-j773g-comp6a, boot_id=57875cbc-9f1a-4e72-94aa-866d4d596113, includes #3766 @ e49cdb436757):
    • 10-minute idle desktop (DP-3 active, PP1b = 0 uW every minute, die 43.5–46.5 C):
      • apple-pmp-thermal: sensor error -61; CPU minimum caps retained: +371 over 10 min (37.1/min, 168 -> 539), firing in 10/10 consecutive minutes (+40, +33, +32, +40, +40, +22, +50, +22, +52, +40), entering reason=sensor hard=1 level=8 recovery bursts on cool die (46.5 C) as the tightened headroom-scaled hold expires.
      • arch_timer rate: 330.63/s (198,380 / 600 s; min 291.23/s, max 364.05/s).
    • GPU load while CPUs idle (gpubench-vk compute.light, PP1b = 1.654 W): 75,312 submits (39.83 us/submit), se61_delta = 0, 0 kernel faults/warnings.
  • Stock baseline (7.3.0-ARCH-m4main-6c83a2a6, boot_id=bc9fa24e-37f4-4fa0-b91d-31ed138b3356, CONFIG_HZ=1000, main's 15 s CPU-idle hold):
    • 2-minute quiet idle desktop (dt=120 s): 0 sensor error -61 (0.00/min), arch_timer = 249.12/s (29,894 / 120 s).
    • Whole-boot profile (3,279 s / 54.6 min uptime): 432 sensor error -61 lines across 48 bursts = 7.9/min average (6–10 lines per 5 ms burst).

Summary: Compared to stock main's 15 s hold on J773g, #3766's tighter [2 s, 10 s] headroom-scaled cap (~7.5 s at 46 C) increases idle sensor error -61 recovery bursts ~4.7× vs stock's whole-boot average (37.1/min vs 7.9/min, and vs 0.00/min during the 2-min stock idle sample) and raises idle arch_timer interrupts by +81.5/s (+32.7%, 330.63/s vs 249.12/s). That matches the exact idle hold-expiry regression risk noted in the PR description.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Matched 10-minute stock idle baseline addendum on J773g (7.3.0-ARCH-m4main-6c83a2a6, boot_id=bc9fa24e-37f4-4fa0-b91d-31ed138b3356, CONFIG_HZ=1000, DP-3 connected/enabled/On, identical 60 s hwmon/interrupt/dmesg loop as the comp6a run):

  • Stock 10-min idle (dt=600 s):
    • sensor error -61: +78 over 10 min (7.8/min, 452 -> 530; per-minute deltas +0, +12, +0, +10, +20, +0, +16, +0, +0, +20 — 5/10 minutes clean).
    • arch_timer: 304.58/s (182,746 / 600 s; min 277.60/s, max 325.32/s).
    • PP1b: 13–43 mW, Total System Power: 5.5–12.6 W.
  • Matched 10-min comparison (#3766 @ e49cdb436757 in comp6a vs stock 6c83a2a6):
    • sensor error -61: 37.1/min (+371, 10/10 min) vs 7.8/min (+78, 5/10 min) -> 4.76× higher under #3766.
    • arch_timer: 330.63/s vs 304.58/s -> +26.05/s (+8.6%) under #3766.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed ready-to-merge Meets the merge policy: merge it (bot) labels Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Matched 10-minute stock idle baseline on J773g (Mac16,10, T8132), same DP-3 state (connected/enabled/On), same counters and 60 s cadence as the comp6a 10-minute idle window:

  • Stock kernel: 7.3.0-ARCH-m4main-6c83a2a6 (boot_id=bc9fa24e-37f4-4fa0-b91d-31ed138b3356, uptime 3691 s -> 4291 s)
  • sensor error -61 delta over 600 s: +78 (452 -> 530, 7.8/min, firing in 5/10 minutes) vs comp6a (#3766 @ e49cdb436757ec2e485042c9e0c111653b27dc56) +371 (37.1/min, firing in 10/10 minutes) — 4.76x higher burst rate on comp6a
  • arch_timer over 600 s: 182,746 (304.58/s) on stock vs 330.63/s on comp6a (+26.05/s)
  • Power rail snapshot (start -> end): Total System Power 5.46 W -> 5.50 W, CPU/GPU rail sum 64 mW -> 58 mW

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>
@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) and removed ready-to-merge Meets the merge policy: merge it (bot) labels Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Pushed 52e3af5dd8ac on top of e49cdb436757 (a plain commit, no rebase) to fix the J773g idle regression.

Why it got worse. The change could only end a hold sooner than main, never later:

  • Main holds a cool dark die for 15 s while the CPUs are idle. The headroom cap is about 7.5 s at 46 C.
  • Past 2 s it also wanted a fresh GPU rail read under 50 mW, so a failed or late read cut the hold to 2 s.
  • Each expired hold logs sensor errors, caps the CPUs and polls every 5 ms until the sensors read again and the guard steps back down.

Measured on J773g: 78 against 371 error lines, 304.6 against 330.6 arch_timer/s, and in the one recovery logged in full, 2.8 s from the first error to level 0. Not measured: which limit ended each hold. I think it was mostly the cap, because the rail read fine at 0 mW in all ten minute samples. That run was the comp6a composite kernel, so the other PRs in it are not ruled out.

What changed.

  • Main's 15 s cap is back. The 8 C/s headroom formula, its 10 s limit and the rail timestamp are gone.
  • The GPU gate stays: GPU work still ends the hold at 2 s. Only a rail that reads busy does that now. After a failed read main's rule applies, and the power policy already keeps the CPUs and GPU at their floor then.
  • The GPU threshold is 250 mW, between what J773g reads idle (0-43 mW) and under gpubench compute.light (1630 mW). 50 mW was within one rail step (about 15 mW) of idle.

With the GPU rail under 250 mW the holds are now exactly main's, so J604 keeps the long idle hold (its earlier A/B was against the old 2 s hold, which main has since replaced). What is left over main is the GPU gate: with GPU work and dark sensors it still errors sooner than main, on purpose.

Tested at 52e3af5dd8ac: apple-pmp-policy KUnit 15/15 on UML, W=1 clean (clang arm64, both touched objects), checkpatch --strict 0/0/0, pmp host tests 24/24 in the pinned Ubuntu 24.04 image, test-thermal-policy.py passes. The new rate test (10 idle minutes, a reading every 14 s, simulated) gives 0 errors and 6000 polls here, and fails on e49cdb43 with 54703 errors and 72291 polls. The host test also catches a 7.5 s cap, a failed rail read that counts as GPU work, and no GPU gate.

Rows owed at 52e3af5dd8ac:

  • J773g (T8132): 10 minutes idle with DP-3 on, against stock: sensor error -61 lines, arch_timer rate and PP1b, then a GPU load while the CPUs idle. The row at e49cdb43 no longer counts.
  • J604 (author): the same idle count at this head.
  • This driver binds only on T8132, so no J700 row.

The title and the What, Tested, Risk and Not yet lines still describe the 2-10 s cap, so they need an update. The push dismissed the approval, so it needs a new one from someone who did not push.

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

Copy link
Copy Markdown
Contributor

At 52e3af5dd8ac the holds match main except that GPU work on a dark die ends the hold at 2 s instead of 15 s, so it can only add sensor errors there. The J604 gain in the PR text was measured against the old 2 s hold, which #2774 already replaced on main. We won't spend a J773g row on it until there is a gain against current main: please post a J604 A/B (10 minutes idle, plus a GPU load with the CPUs idle) of this head against main, or close it as superseded by #2774.

@IronsideXXVI IronsideXXVI changed the title thermal: apple-pmp: hold a cool die through a long dark spell while the GPU is idle thermal: apple-pmp: end an idle dark hold early only for GPU work Dec 3, 2026
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks for pushing 52e3af5dd8ac and catching the J773g idle regression cleanly, @DjDeveloperr — dropping the 2–10 s headroom cap and raising the GPU-busy threshold to 250 mW (apple_pmp_die_idle()) is much cleaner.

  • Updated the PR title and the What, Tested, Risk, and Not yet lines to describe 52e3af5dd8ac accurately against current main.
  • Leaving the J604 A/B at 52e3af5dd8ac against current main (10-minute idle sensor error -61 / arch_timer / PP1b, plus GPU load with CPUs idle) tracked under Not yet; I will post those numbers once run on J604.
  • Reworking #3994 cleanly on top of #3949 and #3766 @ 52e3af5dd8ac now.

IronsideXXVI added a commit to IronsideXXVI/linux that referenced this pull request Dec 3, 2026
…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>

@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: REQUEST CHANGES at 52e3af5

Failure: The new apple_pmp_test_dark_idle_rate() overflows signed long on 32-bit KUnit builds. APPLE_PMP_POLICY_KUNIT_TEST depends only on KUNIT, so it can be selected on a 32-bit target. NSEC_PER_SEC is 1000000000L and all three products (10, 14, and 600 times that constant) are calculated before conversion to u64. I compiled the exact expressions with gcc -m32 -Werror=overflow -fsyntax-only and all three failed. The 14-second product became 1115098112 and the 600-second product became -1295421440. Give those multiplications an unsigned 64-bit operand, for example 14ULL * NSEC_PER_SEC. The same 32-bit compile passed with that change. Test source

Checked: I ran the exact host polling suite. It passed the 15-second idle and 2-second active holds, rail-error fallback, and sleep and s2idle transitions. It rejected all three mutations. The power worker publishes power_error and the rail values under the mutex that the thermal sampler holds when it reads both. The GPU threshold applies to the rail reading across supported boards.

Follow-ups: The author’s current-main J604 comparison remains tracked separately from this build finding.

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>
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks for catching the 32-bit signed long overflow. Pushed forward-only fix 5d1e0cf98d21 updating 10 * NSEC_PER_SEC, 14 * NSEC_PER_SEC, and 600 * NSEC_PER_SEC in apple_pmp_test_dark_idle_rate() to 10ULL, 14ULL, and 600ULL.

Verified offline at 5d1e0cf98d21:

  • clang --target=i386-linux-gnu -Werror=integer-overflow -Wall -Wextra -fsyntax-only with 64-bit _Static_assert checks: PASS (negative control on 14 * NSEC_PER_SEC reproduces the 1115098112 signed long overflow).
  • tools/asahi/pmp-thermal-poll-tests.py: PASS (1 positive suite + 3/3 mutation checks).
  • scripts/checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.

@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Dec 3, 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: MERGE at 5d1e0cf

Checked: The only delta from 52e3af5d widens the three KUnit duration literals to 10ULL, 14ULL, and 600ULL. I compiled the exact changed expressions with gcc -m32 and gcc -m64, both with -Wall -Werror=overflow -fsyntax-only. Both passed. The unchanged host thermal polling suite also passed and rejected all three mutations. The earlier 32-bit KUnit finding is resolved.

Follow-ups: The current-main J604 comparison is tracked by the author. Author verification

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

Code is fine at 5d1e0cf98d21. Not an approval: 52e3af5d was our push. What is missing is hardware, not code.

The bot's point is right and fixed. At 52e3af5d an ARCH=i386 build of apple-pmp-policy-test.o with WERROR fails with three overflow errors (lines 391 and 400). At 5d1e0cf9 it builds clean. The push changes only those two lines.

Its other statements hold, except one to read narrowly:

  • rail_mw and power_error are written and read under pmp_thermal.lock: yes.
  • "The GPU threshold applies to the rail reading across supported boards": true for the code, not measured. The driver binds only on T8132 (apple,t8132-pmp-v2, rails from apple,t8132-smc), so J604, J623, J624, J713, J715 and J773g. The 250 mW comes from J773g alone (0-43 mW idle, 1630 mW in compute.light). I found no posted idle PP1b for any of the others. The ones with a panel of their own may idle higher, for example a 120 Hz desktop on J604. Idle above 250 mW with dark sensors means sensor error -61, full CPU and GPU protection and 5 ms polling after 2 s instead of 15 s, which is the J773g regression of e49cdb43 again.

Behaviour next to main: below 250 mW, or with a failed rail read, holds are the same as main. A stale rail value can't hold longer than main's 15 s cap. After resume a busy value from before sleep is replaced by the first power poll, before the 2 s run out. None of the six PMP records is labelled as a GPU sensor, so the gate has a purpose.

Owed before merge:

  1. J604 at this head against current main, 10 minutes idle, panel on at its normal refresh rate: PP1b min, median and max (one sample per second), count of sensor error -61 lines, arch_timer rate. Then a GPU load with the CPUs idle: PP1b and the same count. Pass: idle PP1b well under 250 mW, idle error count not above main, and the GPU-load run shows what the gate changes. If idle PP1b reaches 250 mW, the threshold needs to move before anything else.
  2. J773g at this head, the same two parts with DP-3 on, once 1 shows a gain. The earlier J773g rows were at e49cdb43.
  3. A fanless Air (J713 or J715) idle PP1b reading would settle the third form factor. Not required if 1 and 2 pass.

No J700 or other second-generation row: nothing but T8132 runs this code.

If 1 shows no gain over main, close this as superseded by #2774, as said on 12-03.

Small: Tested: and Not yet: still say 52e3af5dd8ac. The readiness bot takes that Tested: line for a hardware row; it is not one.

What was run

Merged with main 8ec8740a1e6f (no conflicts, #3949 is in there): apple-pmp-policy KUnit on UML 15/15, tools/asahi/pmp-thermal-poll-tests.py passes with 3/3 mutations caught, apple-pmp-thermal.o and apple-pmp-policy-test.o clang arm64 W=1 with 0 warnings. Head alone: ARCH=i386 WERROR build of the test object, clean. No hardware was used.

This branch has not been deployed

No deployments
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) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants