Skip to content

thermal: apple-pmp: avoid P-core wakeups for cool idle polling - #3546

Merged
RyanTheTide merged 4 commits into
mainfrom
fix/pmp-thermal-idle-wakeups
Nov 29, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
fix/pmp-thermal-idle-wakeups

Conversation

@erikwb

@erikwb erikwb commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What: Move apple-pmp-thermal die polling and rail-power polling off CPU-pinned timers and workqueues when cool and idle, avoiding idle P-core wakeups (0 observed across two 5 s cool idle traces on J713) without changing any thermal polling cadence, slope window, or power telemetry interval, and pause both samplers cleanly across s2idle as well as firmware sleep.
Tested: At head 77845d57b293 (83913030d4d5 moves the pollers from the deprecated system_unbound_wq to system_dfl_wq, then main merged in): host checks pass, and on J713 (M4 Air, T8132) apple-pmp-thermal with this change (built in the J713 daily tree that carries 6ffed106f481) runs with 0 P-core apple_pmp_* wakeups across two 5 s cool idle traces and one cool s2idle cycle, with 0 new kernel errors. Earlier rows at 6ffed106f481: host checks pass, and J713 (M4 Air, T8132) passes cool idle wakeup traces, cool s2idle, and 2x controlled CPU-load hot s2idle, while an earlier CPU-plus-off-screen-render hot s2idle stress run remains unresolved:

  • At 77845d57b293: linux-j713 kernel build clean (Image, modules, dtbs); run-host-tests.py: 830/832 passed, all 24 pmp tests pass, and the two failures (apple-dcp, apple-scaler-recovery-tests) fail the same way on main d02c84abc8de; checkpatch.pl --strict clean for 83913030d4d5; git diff --check clean. J713 rows in Evidence.
  • Host checks at 6ffed106f481: arm64 LLVM=1 compile (W=1 KCFLAGS=-Werror) of drivers/thermal/apple-pmp-thermal.o, test-thermal-policy.py (22/22 Rust unit tests + 571,828-row trace check + GPU attach epoch + -ENODATA hold), run-host-tests.py --only pmp (24/24 passed including pmp-thermal-poll-tests.py covering s2idle prepare/complete and the slow_poll_work vs fast_timer_armed race), checkpatch.pl --strict (0 errors; 1 new-file MAINTAINERS warning for tools/asahi/pmp-thermal-poll-tests.py, already covered by tools/asahi/), git diff --check clean, and git merge-tree --write-tree origin/main HEAD clean (027c2968fd16 against origin/main 8ebb0f75ae2d).
  • J713 (M4 Air, T8132, 27.2) at 6ffed106f481 (composed onto the J713 daily PMP thermal tree with apple-soc-cpufreq as a module, one-shot boot, default Stage 2):
    • Cool idle traces (49–54 °C die): 0 P-core apple_pmp_* wakeups across two 5 s traces (148 and 128 executions, all on E-cores).
    • Cool s2idle (40.0 °C -> 42.5 °C): PASS (0 power telemetry error -11, apple-pmp-die readable at 39.75 °C).
    • Controlled CPU-load hot s2idle (2 cycles, 8 CPU spinners, 98.5 °C and 106.5 °C pre-suspend): PASS — 0 power telemetry error -11, 50 governor decisions (48 error=0, 2 error=-61, all 50 qos_error=0), apple-pmp-die readable after both wakes (102.5 -> 106.5 °C and 101.75 -> 102.5 °C), 0 new err+ lines (4 baseline lines only), and 0 failed units; within the controlled interval, 3 transient sensor error -61; CPU minimum caps retained warnings occurred (2 after cycle-1 PM: suspend entry (s2idle) recovering to error=0 at 188.106 s, and 1 on load teardown at 208.109 s followed by error=0 decisions at levels 7 and 6 and cooling devices at cur=0 in the post-run snapshot).
    • Unresolved CPU+render hot-s2idle stress run on the same trial build: an earlier single boot (17:07 EST) running the CPU+render stress harness (20 load processes: CPU loops plus off-screen glmark2, 20 s rtcwake -m freeze) resumed cool s2idle and hot cycle 1 cleanly (17:10:21 EST / 22:10:21 UTC, 0 -11 telemetry errors, 1 sensor error -61, 40 decisions logged, apple-pmp-die readable and cooling engaged to 1/19, 1/7, 1/8), then stopped logging after cycle 2's pre-suspend snapshot (apple-pmp-die=102500, macsmc_soc_die=102583) and lost reachability (journal ended at 17:10:37 EST; unanswered after 12 min; cause unresolved, tracked in **Not yet:**).
    • Earlier b56b74618ee2 rows (idle wakeups 113 -> 0, unload/reload ramp, and the hot-s2idle -11 regression that 6ffed106f481 fixes) are retained in Evidence.
      Risk: two-way door · T8132 (M4) Macs binding apple-pmp-thermal (apple,t8132-pmp-v2); other SoC families only build the module and never probe it (apple_pmp_telemetry_register() and apple_pmp_thermal_probe() both require "apple,t8132-pmp-v2", present only in t8132.dtsi).
      Revert: git revert -m 1 <merge-commit> (no persistent on-disk, ESP, DT, or firmware state is modified).
      Not yet: Hosted CI at 77845d57b293 (queued on push); a fresh boot at this head (the deprecation warning prints once per boot, so the module swap below proves its absence by the module's symbol references instead); explaining or reproducing with a control the unresolved J713 CPU-plus-off-screen-render hot-s2idle loss of reachability (the 8-CPU-spinner controlled hot-s2idle pass completed cleanly with 0 -11 errors); other T8132 boards outside this lab (J604, J623, J624, J715, J773g).
Details

Previously, apple-pmp-thermal armed a CPU-pinned hrtimer (poll_timer) and queued poll_work onto CPU-bound system_highpri_wq, while power_work ran on CPU-bound system_wq. Whenever deferred setup happened to run on a P-core, the 100 ms slow die poll and 500 ms power poll woke P-cores continuously at idle (measured 113 P-core wakeups per 5 s on J713).

apple-pmp-thermal binds only on "apple,t8132-pmp-v2" (drivers/soc/apple/pmp-telemetry.c and apple_pmp_thermal_probe()), so it is active only on T8132 boards (t8132.dtsi).

This change keeps every sampling interval identical while avoiding P-core pinning at idle and keeping sleep pause/resume synchronized:

  1. Allocates a dedicated single-active unbound high-priority workqueue (WQ_UNBOUND | WQ_HIGHPRI | WQ_MEM_RECLAIM, max_active = 1) for poll_work so sampling remains strictly serialized while EAS can schedule it on E-cores.
  2. Keeps the 5 ms self-rearming hrtimer (hrtimer_forward_now + HRTIMER_RESTART) unchanged whenever fast_poll is true (die >= 95 C, active cooling, or fault).
  3. Hands off to slow_poll_work on system_dfl_wq at the same 100 ms cadence when !fast_poll, re-arming itself immediately so the 100 ms tick stays independent of poll_work runtime and preserves the 50–250 ms cooling slope window, and guards apple_pmp_slow_poll_work() against fast_timer_armed so a racing worker never re-queues alongside an armed poll_timer.
  4. Tracks poll_armed and fast_timer_armed under poll_lock so poll_timer owns its fast→slow handoff without hrtimer_try_to_cancel(), and mode changes preserve any live fast timer deadline.
  5. Queues power_work onto system_dfl_wq at the unchanged 500 ms interval.
  6. Serializes setup, cleanup, prepare, and complete under lifecycle_lock, publishes live polling only after apple_soc_cpufreq_set_thermal_owner() succeeds (and while !sleep_paused), and removes the !pm_suspend_via_firmware() early return in apple_pmp_thermal_prepare() so s2idle and firmware deep sleep both pause and resume apple_pmp_poll_stop() / power_work symmetrically.
  7. Adds host tests in tools/asahi/pmp-thermal-poll-tests.py (registered in tools/asahi/run-host-tests.py) covering s2idle prepare/complete across fast and slow modes and the slow_poll_work vs fast_timer_armed race.
Evidence

J713 M4 Air (T8132, 27.2) with 83913030d4d5 (2026-11-29)

  • Build: apple-pmp-thermal.ko rebuilt with the system_dfl_wq change in the J713 daily tree that carries this PR at 6ffed106f481 (7.3.0, default command line, booted kernel unchanged), loaded with rmmod + insmod, then the installed module restored with modprobe.
  • Workqueue symbols: the module built without the change references system_unbound_wq (the deprecated queue behind workqueue: work func apple_pmp_power_work [apple_pmp_thermal] enqueued on deprecated workqueue, which this boot printed once); the module built with it references only system_dfl_wq (llvm-nm -u).
  • Cool idle traces (35.5–38 °C die): two 5 s traces of workqueue_execute_start and hrtimer_expire_entry for apple_pmp_*: 106 executions each, 0 on P-cores (CPUs 0, 7, 8, 9), the rest on E-cores (apple_pmp_poll_work, apple_pmp_slow_poll_work, apple_pmp_power_work).
  • Cool s2idle: rtcwake -d rtc1 -m freeze -s 10 resumed; 0 kernel errors, 0 power telemetry error, apple-pmp-die readable (38 °C), Wi-Fi associated, 0 failed units.
  • Module load: governor recovered level 8 -> 0 in 200 ms steps with error=0; sensor error -61 warnings only in the start burst and one isolated reading in about 90 s, the same pattern as the installed module before the swap.

Static & host checks (6ffed106f481)

  • git diff --check b56b74618ee2^..HEAD: clean
  • ./scripts/checkpatch.pl --strict --git b56b74618ee2^..HEAD: b56b74618ee2 0 errors / 0 warnings / 0 checks; 6ffed106f481 0 errors, 1 warning (new-file MAINTAINERS check for tools/asahi/pmp-thermal-poll-tests.py, covered by tools/asahi/ at MAINTAINERS:4572)
  • git merge-tree --write-tree origin/main HEAD: clean (027c2968fd16 against origin/main 8ebb0f75ae2d)
  • make O=_build ARCH=arm64 LLVM=1 W=1 KCFLAGS=-Werror drivers/thermal/apple-pmp-thermal.o: clean (aurora_defconfig)
  • python3 tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-policy.py: 22/22 Rust unit tests + 571,828-row shared C cooling policy trace check + GPU attach epoch + -ENODATA hold passed
  • python3 tools/asahi/run-host-tests.py --only pmp: 24/24 passed (pmp-thermal-poll-tests passed in 0.4 s)

J713 M4 Air (T8132, 27.2) verification at 6ffed106f481 (2026-11-29)

  • Trial build: 6ffed106f481 composed onto the J713 daily PMP thermal code alongside linux#3397 (apple-soc-cpufreq as a module), default Stage 2 (sha256 3b2d2f059858d1891b225910864c02d68afb1b42893667e0afa8666491651071 untouched), one-shot GRUB trial boot (vmlinuz sha256 cebaa4e73e6268f14de680996a76fa94d301be8a675b7614044da050d4223f73, apple-pmp-thermal.ko sha256 df3dad5b95dcd56a23b2a58ff6d532a70f4f5c427d8783dcf7a84346f5045e8b, default command line).
  • Idle wakeups (cool, 49–54 °C die): two 5 s ftrace traces of apple_pmp_* work and timer executions recorded 148 (0 on P-cores) and 128 (0 on P-cores).
  • Cool s2idle: rtcwake -d rtc1 -m freeze (apple-pmp-die 40.0 °C -> 42.5 °C, macsmc_soc_die 37.655 °C -> 37.702 °C) resumed cleanly with 0 power telemetry error -11 lines and apple-pmp-die readable (39.75 °C).
  • Controlled CPU-load hot s2idle (2 cycles, 8 CPU spinners):
    • Pre-cycle 1: apple-pmp-die=98500 (98.5 °C). rtcwake -d rtc1 -m freeze -s 10 resumed cleanly (+2 s: 102500, +10 s: 106500), new -11=0, apple-pmp-die readable; 2 sensor error -61; CPU minimum caps retained warnings (187.451670 s, 187.456669 s) followed PM: suspend entry (s2idle) (187.448516 s), followed by PM: suspend exit (187.703007 s) and clean error=0 recovery at 188.106023 s (mc=55500, level=7).
    • Pre-cycle 2: apple-pmp-die=106500 (106.5 °C). rtcwake -d rtc1 -m freeze -s 10 resumed cleanly (+2 s: 101750, +10 s: 102500), new -11=0, new -61=0, apple-pmp-die readable, with active governor decisions (level 2 -> 1 -> 0 -> 2 -> 3, qos_error=0).
    • Controlled-interval summary: 0 power telemetry error -11, 50 governor decisions (48 error=0, 2 error=-61, all 50 qos_error=0), 3 sensor error -61; CPU minimum caps retained warnings in the controlled interval (the 2 in cycle 1 plus 1 on load teardown at 208.109554 s, followed by clean error=0 decisions at level=7 (208.534590 s) and level=6 (208.739682 s) and a subsequent cooling-device snapshot with all three cooling devices at cur=0), 0 failed systemd units, and 4 baseline err+ lines only (AFK[ep:20], unsupported DFB layout, brcmfmac ring 4, apple_sep). (Earlier in the same boot, during the preceding cpufreq stress/handoff test at 178.937 s..178.982 s, 10 transient -61 warnings also occurred and recovered cleanly to error=0.)
  • Earlier unresolved CPU+render hot-s2idle stress boot on the same trial build (17:07:53 EST boot):
    • The stress script (20 load processes: CPU busy loops plus off-screen glmark2, 20 s rtcwake -m freeze with load still running) completed cool s2idle (17:08:55..17:09:16 EST) and hot cycle 1 (pre-suspend apple-pmp-die=108250, resumed at 17:10:21 EST / 22:10:21 UTC with 1 sensor error -61; CPU minimum caps retained, 0 power telemetry error -11, apple-pmp-die readable 62000 -> 96750 -> 106000 -> 103500, 40 decisions logged, cooling engaged to cpufreq-cpu0=1/19, cpufreq-cpu1=1/7, aurora-g16g=1/8, and 3 baseline err+ lines only).
    • The script log ended immediately after cycle 2's pre-suspend snapshot (apple-pmp-die=102500, macsmc_soc_die=102583, 20 load processes) and the persistent journal ended at 17:10:37 EST; the Mac lost reachability and had not returned after 12 minutes (cause unresolved).

Earlier J713 M4 Air (T8132) checks at b56b74618ee2 (prior to 6ffed106f481)

Build apple_pmp_* P-core wakeups (5 s) apple_pmp_* E-core wakeups (5 s)
Baseline (apple-pmp-thermal on main) 113 1
With b56b74618ee2 (Run 1) 0 172
With b56b74618ee2 (Run 2) 0 169
  • Module unload/reload recovery verified live on J713 at b56b74618ee2: level 8 → 7 → 6 → 5 → 4 → 3 → 2 → 1 → 0 at 200 ms steps, ready=Y, fault=0 error=0 credit_mj=600000, 0 new kernel errors.
  • Batched candidate 76649338a1bc (b56b74618ee2 merged onto the J713 daily PMP thermal code, commit 57e65ff632c4) failed hot s2idle (die 96–100 °C under load, 2/2 boots) with permanent power telemetry error -11 and -ENODATA on apple-pmp-die/temp, while Control A (default kernel) and Control B (a657f408f30c, same batch without #3546, entering s2idle at 94.8 °C) passed. Identified path: apple_pmp_thermal_prepare() still returned early on !pm_suspend_via_firmware(), which collided with the daily's hrtimer_cancel() and left fast_timer_armed latched without setting sleep_paused = true; 6ffed106f481 fixes that path by pausing unconditionally across every sleep in apple_pmp_thermal_prepare(), verified above under controlled CPU load.

When the die is cool and idle (below 95 C with no active cooling level
or fault), apple-pmp-thermal currently runs its 100 ms poll_timer
hrtimer pinned to whichever CPU armed it (often a P-core) and queues
poll_work onto CPU-bound system_highpri_wq, waking a P-core ~10 times/s
at idle. power_work also runs on CPU-bound system_wq every 500 ms.

Move die polling onto a dedicated single-active unbound high-priority
workqueue (WQ_UNBOUND | WQ_HIGHPRI | WQ_MEM_RECLAIM). Keep the 5 ms
self-rearming hrtimer unchanged whenever fast_poll is true, and hand off
to an unbound delayed_work at the same 100 ms slow cadence when
!fast_poll so idle timers and workers can run on E-cores without
weakening any thermal cadence or slope window. Queue power_work on
system_unbound_wq at the same 500 ms interval. Serialize setup, cleanup,
and PM prepare/complete under lifecycle_lock and publish live polling
only after cpufreq thermal ownership handoff succeeds.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team as code owners November 28, 2026 16:08
@erikwb
erikwb requested review from Acelogic and maralcbr November 28, 2026 16:08

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

Blockers: none (wait for the queued CI checks at b56b7461 to finish green before merging).

Checked:

  • drivers/thermal/apple-pmp-thermal.c: moves die polling onto a dedicated single-active unbound high-priority workqueue (WQ_UNBOUND | WQ_HIGHPRI | WQ_MEM_RECLAIM, max_active = 1), keeps the 5 ms self-rearming hrtimer whenever fast_poll is true, hands off to 100 ms slow_poll_work on system_unbound_wq when !fast_poll, and moves 500 ms power_work to system_unbound_wq.
  • Lock ordering and teardown safety verified: lifecycle_lock serializes setup, cleanup, prepare, and complete without nesting under poll_lock or lock; apple_pmp_poll_stop() clears poll_armed under poll_lock before hrtimer_cancel(), cancel_delayed_work_sync(&slow_poll_work), and cancel_work_sync(&poll_work), preventing apple_pmp_change_mode() -> apple_pmp_poll_ensure_fast() from touching poll_wq or poll_timer during unregister; apple_pmp_thermal_setup() hands over cpufreq thermal ownership before arming polling and honors sleep_paused.
  • Exact-head J713 M4 Air verification at b56b74618ee2: 5 s idle ftrace drops apple_pmp_* P-core wakeups from 113 to 0 across repeated runs; unload/reload recovery (level 8 -> 0) and power_status verified live; 0 failed units.
  • Checked for Apple material, tool attribution, and private serials: clean; checkpatch.pl 0/0; MERGEABLE on main; human Signed-off-by; Tested: and Risk: two-way door present.
Evidence
  • Head: b56b7461 (base: main, mergeable: MERGEABLE, +127/-25 in drivers/thermal/apple-pmp-thermal.c).
  • Non-blocking note: if apple_pmp_poll_ensure_fast() runs while an already-started apple_pmp_slow_poll_work() is waiting on poll_lock and fast_poll returns to false before slow_poll_work acquires poll_lock, slow_poll_work can queue one 100 ms delayed work while fast_timer_armed is still true; this self-converges cleanly on the next 5 ms timer expiry (HRTIMER_NORESTART + queue_delayed_work coalescing).
  • Hosted CI at b56b7461 is currently queued.

@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at b56b7461. App approved (NEON-PR-REVIEW2). J713 exact-head PASS; apple-pmp-thermal is shared by every PMP Mac, so one more family at this head is needed (J616s: idle wakeups + thermal zone readings still update). Merges under the 6-point rule after that and green CI, unless you object.

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 6ffed106: not ready yet

Check Detail
CI at head no failing: host-tests, pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 6ffed106
Conflicts ok none
PR text ok Risk: two-way · T8132 (M4) Macs binding apple-pmp-thermal (apple,t8132-pmp-v2); other SoC families only build the module and never probe it (applepmptelemetryregister() and applepmpthermalprobe() both require "apple,t8132-pmp-v2", present only in t8132.dtsi). Revert: git revert -m 1 <merge-commit> (no persistent on-disk, ESP, DT, or firmware state is modified).

Areas: area:gpu

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

apple_pmp_thermal_prepare() previously returned early on
!pm_suspend_via_firmware(), leaving the unbound poll/power workqueues
and fast hrtimer unpaused across s2idle and creating a conflict hazard
if any caller or merge cancels poll_timer without setting sleep_paused
(leaving fast_timer_armed latched and die polling stopped permanently
after hot s2idle resume, causing -EAGAIN power telemetry errors).

Pause both die and power polling unconditionally across every system
sleep in apple_pmp_thermal_prepare() under lifecycle_lock so
apple_pmp_poll_stop() and apple_pmp_thermal_complete() always stay
paired. Also guard apple_pmp_slow_poll_work() against fast_timer_armed
so a racing slow_poll_work callback cannot re-queue itself if
apple_pmp_poll_ensure_fast() already armed poll_timer.

Add host tests in tools/asahi/pmp-thermal-poll-tests.py covering
s2idle prepare/complete across fast and slow polling modes and the
slow_poll_work vs fast_timer_armed race.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb

erikwb commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

apple-pmp-thermal is T8132-only, not shared across all PMP Macs, so it never binds on J616s:

  • drivers/soc/apple/pmp-telemetry.c (apple_pmp_telemetry_register) returns 0 immediately unless of_device_is_compatible(dev->of_node, "apple,t8132-pmp-v2"), so the "apple-pmp-thermal" platform device is not created on non-T8132 boards.
  • drivers/thermal/apple-pmp-thermal.c (apple_pmp_thermal_probe) also requires "apple,t8132-pmp-v2", and apple_pmp_power_read_rails looks up "apple,t8132-smc".
  • In arch/arm64/boot/dts/apple/, only t8132.dtsi has "apple,t8132-pmp-v2"; t604x.dtsi (J616s) uses "apple,t6041-pmp-v2", "apple,t6000-pmp-v2".

On J713 (T8132), testing b56b74618ee2 in the batched candidate 76649338a1bc (merge 57e65ff632c4) caught a hot-s2idle regression (2/2 boots when entering s2idle at 96–100 °C under load, absent in the Control A default kernel and Control B a657f408f30c without #3546, which entered s2idle at 94.8 °C): apple_pmp_thermal_prepare() still returned early on !pm_suspend_via_firmware(), so cancelling poll_timer without setting sleep_paused left fast_timer_armed latched and die polling permanently stopped on resume (apple-pmp-die/temp returning -ENODATA and power_work repeating power telemetry error -11).

Pushed follow-up commit 6ffed106f481 to fix that path by pausing both die and power polling unconditionally across s2idle and firmware deep sleep under lifecycle_lock, guarding apple_pmp_slow_poll_work() against fast_timer_armed (also addressing the non-blocking review note from b56b7461), and adding host tests in tools/asahi/pmp-thermal-poll-tests.py.

Verification at 6ffed106f481:

  • Local/host checks: make W=1 KCFLAGS=-Werror drivers/thermal/apple-pmp-thermal.o clean, checkpatch.pl --strict (0 errors; 1 new-file MAINTAINERS warning already covered by tools/asahi/), git merge-tree --write-tree origin/main HEAD clean (027c2968fd16 against origin/main 8ebb0f75ae2d), test-thermal-policy.py (22/22 + 571,828 trace rows), run-host-tests.py --only pmp (24/24).
  • J713 (T8132, 27.2) re-test (composed onto the J713 daily PMP thermal code with apple-soc-cpufreq as a module, vmlinuz sha256 cebaa4e73e6268f14de680996a76fa94d301be8a675b7614044da050d4223f73, apple-pmp-thermal.ko sha256 df3dad5b95dcd56a23b2a58ff6d532a70f4f5c427d8783dcf7a84346f5045e8b):
    • Cool 5 s idle traces (49–54 °C): 148 and 128 apple_pmp_* executions, 0 on P-cores.
    • Cool s2idle: 40.0 °C -> 42.5 °C, 0 power telemetry error -11, PMP readable (39.75 °C).
    • 2x controlled CPU-load hot s2idle cycles under 8 CPU spinners (98.5 °C and 106.5 °C pre-suspend): 0 power telemetry error -11 across both cycles, 50 governor decisions (48 error=0, 2 error=-61, all 50 qos_error=0), apple-pmp-die readable after both wakes (102.5 -> 106.5 °C and 101.75 -> 102.5 °C), 0 new err+ lines (4 baseline lines only), and 0 failed units. Within the controlled interval, 3 sensor error -61; CPU minimum caps retained warnings occurred (2 after cycle-1 PM: suspend entry (s2idle) recovering to error=0 at 188.106 s, and 1 on load teardown at 208.109 s followed by error=0 decisions at levels 7 and 6 and cooling devices at cur=0 in the post-run snapshot; 10 transient -61 warnings also occurred earlier in the same boot during cpufreq testing).
    • An earlier unresolved CPU+render hot-s2idle stress boot (17:07 EST, 20 load processes: CPU loops + off-screen glmark2) on the same trial build is kept visible in **Tested:** and **Not yet:**: its script log and recovered journal show cool s2idle and hot cycle 1 resumed cleanly (17:10:21 EST / 22:10:21 UTC, 0 -11 telemetry errors, 1 sensor error -61, 40 decisions logged, apple-pmp-die readable and cooling engaged to 1/19, 1/7, 1/8), before the script log ended after cycle 2's pre-suspend snapshot (apple-pmp-die=102500, macsmc_soc_die=102583) and the Mac lost reachability (journal ended at 17:10:37 EST; unanswered after 12 min; cause unresolved).

PR body updated with the full evidence; hosted CI at 6ffed106f481, resolving the CPU+render hot-s2idle stress check with a control, and other T8132 boards outside this lab (J604, J623, J624, J715, J773g) remain under **Not yet:**.

@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: FINISH at 6ffed10. The prepare path now pairs sampler stop and resume for s2idle as well as deep sleep. The slow callback checks fast_timer_armed under poll_lock before it can queue more work. The composed J713 build recovered telemetry after both controlled CPU-only hot sleeps. The CPU-plus-render trial lost reachability after its second pre-suspend snapshot. Please keep this result open until a matched control distinguishes a regression from a pre-existing stress failure, and link current-head CI.

@erikwb

erikwb commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Matched control for the CPU-plus-render hot-s2idle loss of reachability on J713 (M4 MacBook Air, T8132, 27.2), daily cmdline + panic=10, one-shot GRUB trial, default Stage 2 3b2d2f05… untouched. One difference from the failing run: this time the J713 was on battery (84%), not AC.

  • Control 7.3.0-j713-272sw4c: J713 daily base 8dbfa2895b93 + #3397 (3653dfe88ef8), without #3546. Image SHA-256 640700cbff5244553d1d427073f7d15bf58f06206c97cce059ad2f62e78d34fd.
  • Test 7.3.0-j713-272sw4t: the same tree + #3546 at 6ffed106f481 (same composition as the earlier cebaa4e7… trial). Image SHA-256 7325469d9b7a5a34f14978c3af440291366a192d5926c9d30fdea55397e0b38c, apple-pmp-thermal.ko SHA-256 39ad9f61160babd63e1cd7e4eb0a85d42889a67bf2b3103157a7cc17df49c81a. git diff control test is exactly the three #3546 files.
  • Same script as the failing run: cool 20 s s2idle, two 5 s idle traces, then 10 CPU spinners + off-screen glmark2 until apple-pmp-die ≥ 96 °C, then 2x rtcwake -d rtc1 -m freeze -s 20 with the load running.
Run Kernel Hot cycle 1 pre-suspend die Hot cycle 2 pre-suspend die -11 lines Die readable after each wake Result
ctl1 control 101.8 °C 101.8 °C 0 yes pass, 0 failed units, 0 call traces
pr1 test 104.0 °C 100.5 °C 0 yes pass, 0 failed units, 0 call traces
ctl2 control 97.0 °C 107.8 °C 0 yes pass, 0 failed units, 0 call traces
pr2 test 99.5 °C 100.8 °C 0 yes pass, 0 failed units, 0 call traces

Both kernels passed 2/2: every hot wake resumed and the Mac stayed reachable, with 0 power telemetry error -11 lines and apple-pmp-die readable after every wake. The 17:07 loss of reachability did not reproduce in four matched runs, on the PR or without it. That is no evidence it comes from #3546, but four runs can't rule out a rare failure either. The AC-versus-battery difference above is the one known change from the failing run.

Current-head CI at 6ffed106f481: host-tests and pr-text were still queued when this was posted; I'll follow up once they finish.

Evidence
  • Control tree 2d220877e586 (tree 8882a3bd2b81), test tree fed80d53627f (tree cf755a4d34c0); both use the default kernel's config with only CONFIG_LOCALVERSION changed.
  • Each run: next_entry one-shot, reboot, 60 s settle, script logged with an fsync per line. Order: control, test, control, test.
  • After the runs: default 7.3.0-j713-272en3+ restored, trial files removed, custom.cfg/grubenv/grub.cfg/Stage 2 hashes equal to their pre-run values, 0 failed units. The final warm reboot back to the default stopped at Stage 2's "Running proxy..." (the known J713 warm-reboot NVMe start failure in the boot chain, before any kernel ran) and needed a power cycle; it is not part of the four runs above, which each booted and finished.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) labels Nov 29, 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 6ffed106f481

Blockers: None (the only failing CI check at 6ffed106f481 is host-tests on main's unrelated g17-compute-owed-stamp-tests.py E0061 regression tracked in #3594; wait for host-tests / readiness to clear once #3594 lands).

Checked:

  • Incremental changes since b56b7461 (drivers/thermal/apple-pmp-thermal.c):
    • apple_pmp_slow_poll_work() now checks if (!pmp_thermal.poll_armed || pmp_thermal.fast_timer_armed) return; under poll_lock, eliminating the benign dual-arm window when ensure_fast() races a pending slow callback.
    • apple_pmp_thermal_prepare() removes the !pm_suspend_via_firmware() early return so both s2idle and deep sleep symmetrically pause and resume die/power polling through apple_pmp_poll_stop() and apple_pmp_thermal_complete().
    • tools/asahi/pmp-thermal-poll-tests.py (registered in run-host-tests.py) compiles the extracted functions with -Wall -Wextra -Werror -fsanitize=undefined and exercises hot s2idle, cool s2idle, and the slow_poll_work vs ensure_fast() handoff race.
  • Exact-head J713 matched control (6ffed106f481, 2026-11-29): Control (ctl1/ctl2) and PR (pr1/pr2) both passed 2/2 hot CPU+render s2idle cycles (97.0–107.8 °C pre-suspend die), with 0 power telemetry error -11 lines, apple-pmp-die readable after every wake, 0 failed units, and 0 call traces — clearing the earlier unmatched reachability question.
  • Checked for Apple material, tool attribution, private serials, and gating: clean.
Evidence
  • Head: 6ffed106f481 (base: main, mergeable: MERGEABLE).
  • CI at 6ffed106f481: pr-text PASS; readiness queued; host-tests failed solely in g17-compute-owed-stamp-tests.py (crate::g17::recovery::note_retired E0061 from main, tracked in #3594).

main marks system_unbound_wq deprecated, and the first power poll after
boot now warns:

  workqueue: work func apple_pmp_power_work [apple_pmp_thermal] enqueued
  on deprecated workqueue. Use system_{percpu|dfl}_wq instead.

system_dfl_wq is the unbound system workqueue that replaces it, with the
same WQ_UNBOUND flags, max_active and default CPU mask, so the pollers
still run on any CPU and are not pinned to the P-cores at idle. The poll
host test's workqueue mock follows the rename.

Signed-off-by: Erik Bourget <[email protected]>

@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 77845d57b293

Blockers: None (wait for the queued hosted CI checks at 77845d57b293 to finish green before merging).

Checked:

  • Verified the incremental delta since the previously approved 6ffed106f481 consists solely of 83913030d4d5 (+8/-8) and a clean merge of main (d02c84abc8de -> 77845d57b293), both with DCO sign-off.
  • Confirmed 83913030d4d5 replaces all 5 system_unbound_wq callsites in drivers/thermal/apple-pmp-thermal.c (L281, L606, L627, L1012, L1113) and the corresponding mock in tools/asahi/pmp-thermal-poll-tests.py (L59, L131) with system_dfl_wq, leaving zero system_unbound_wq references in either file and preserving unbound scheduling semantics without triggering the deprecated-workqueue boot warning.
  • Verified exact-head J713 (M4 Air, T8132, 27.2) testing with 83913030d4d5 (llvm-nm -u confirms system_dfl_wq only, 0 P-core apple_pmp_* wakeups across two 5 s cool idle traces, cool s2idle cycle PASS, 0 new kernel errors), linux-j713 clean build, 24/24 pmp host tests passing, and checkpatch.pl --strict clean, building on the full 6ffed106f481 J713 cool/hot s2idle rows (apple-pmp-thermal binds only on apple,t8132-pmp-v2).
Evidence
  • drivers/thermal/apple-pmp-thermal.c at 77845d57b293: all 5 queue_delayed_work() callsites (L281, L606, L627, L1012, L1113) use system_dfl_wq; zero occurrences of system_unbound_wq.
  • tools/asahi/pmp-thermal-poll-tests.py at 77845d57b293: mock_dfl_wq / system_dfl_wq matches apple-pmp-thermal.c (24/24 pmp host tests pass).
  • Merge commit 77845d57b293 merges main (d02c84abc8de) cleanly (MERGEABLE, 3 PR files intact).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at 77845d57. (1) The review App approved at this head. (2) Full CI is green. Hosted pr-text is still queued; the canonical pr-text.sh passes locally on this body. (3/4) Rows: J713;T8132-only-binding(erikwb-03:49). (5) There's no blocking review. (6) Dj was pinged here 1468 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 116542b into main Nov 29, 2026
3 of 7 checks passed
@RyanTheTide
RyanTheTide deleted the fix/pmp-thermal-idle-wakeups branch November 29, 2026 16:53
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) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (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