Skip to content

thermal: apple-pmp: stop the power reader at shutdown - #2455

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
erikwb:j713/pmp-thermal-shutdown
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:mainfrom
erikwb:j713/pmp-thermal-shutdown

Conversation

@erikwb

@erikwb erikwb commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When a J713 (T8132) shutdown stalls, the console fills with apple-pmp-thermal: power telemetry error -5 every 500 ms until the machine resets, scrolling whatever actually stalled off the screen.

The thermal driver's power telemetry reader polls the SMC rails every 500 ms and has no .shutdown callback. During a reboot or power-off, the SMC notifies firmware and enters atomic mode, where ordinary SMC reads fail with -EIO, so the reader keeps logging errors for as long as shutdown takes.

Change

Add a .shutdown callback (apple_pmp_thermal_shutdown) to apple_pmp_thermal_driver in drivers/thermal/apple-pmp-thermal.c that cancels setup_work and then power_work synchronously.

Canceling setup_work first ensures a deferred setup cannot queue power_work afterward. Once the reader stops, its power budgets go stale and the CPU and GPU fall back to their minimum ceilings, while the 5 ms die-temperature sampler keeps running while devices shut down. Affects Apple Silicon boards using apple-pmp-thermal (T8132 / J713, J773g).

Testing

At head ab4cea3795f3 (merges cleanly onto integration/aurora 0bbe021a28bd, where apple_pmp_thermal_driver in drivers/thermal/apple-pmp-thermal.c still has no .shutdown callback):

  • Built drivers/thermal/apple-pmp-thermal.o cleanly for arm64 (LLVM=1) against the J713 kernel config.
  • ./scripts/checkpatch.pl --strict --git HEAD~1..HEAD: 0 errors, 0 warnings, 0 checks.
  • GitHub CI Host tests/host-tests: passing.
  • J713 (M4 MacBook Air, T8132), exact head ab4cea3795f3: kernel built from this head with the J713 configuration and booted on the default kernel command line for 5 trial boots (1 initial boot plus 4 trial-to-trial reboots back onto this same kernel, each up in 23–25 s), followed by a 5th shutdown intended to return to the default kernel whose bootloader step hung at "Running proxy..." and required a manual power cycle before booting the default kernel. All 5 trial boots reported power_status error=0, 0 SELinux denials (SELinux is not installed on this image; 0 AVC messages in the journal), 1 failed unit (aurora-power-defaults.service, which fails the same way on the J713's default kernel: 0 new), and 1 error-level kernel message (apple_sep ... matching unavailable this boot, also present on the default kernel: 0 new). Across all 5 trial shutdown journals (4 read on the next trial boot, and the 5th read after returning to the default kernel), there were 0 "power telemetry error" lines after shutdown began and each reached the systemd-shutdown filesystem-sync marker. This check is limited to what the journal records: journald stops before the last shutdown steps, so the console capture below is still needed to see the tail of shutdown.
  • Prior module check on J713: built apple-pmp-thermal.ko from this PR's drivers/thermal/apple-pmp-thermal.c (ab4cea3795f3, with apple_pmp_thermal_shutdown()) and loaded it into a running release/7.3.0-40 (9125b3147583) base kernel (whose own in-tree drivers/thermal/apple-pmp-thermal.c matches ab4cea3795f3~1 and lacks the .shutdown hook); power telemetry ran normally (power_status error=0) and the following reboot completed cleanly in ~10 s.

Still to run

  • On-site J713 run on exact head ab4cea3795f3 (default command line): the shutdown console captured over 5 reboots and 5 power-offs (plus a clean 5th-reboot return to the default kernel if needed), confirming 0 "power telemetry error" lines after shutdown starts, clean completion of each, and power_status error=0 on the next boot. (Cannot be run remotely: the J713 has no serial console attached for shutdown capture, and power-off cycles require physical power-on at the machine. The remote run above covered only the journal-visible part across 5 trial boots—4 trial-to-trial reboots plus a 5th shutdown whose return to the default kernel hung in the bootloader until power-cycled—and did no power-offs.)

A reboot or power-off tells the SMC the system is going down and then
puts it in atomic mode, which fails every ordinary SMC read with -EIO.
The power telemetry reader has no shutdown hook and keeps reading the
SMC rails every 500 ms, so a shutdown that stalls fills the console
with "power telemetry error -5" until the machine resets, burying
whatever stalled it.

Stop the reader from a shutdown callback, after any pending setup. Its
budgets then go stale exactly as they do after failed reads, so the
CPU and GPU fall back to their minimum ceilings, and the die sampler
keeps running while devices shut down.

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

Copy link
Copy Markdown
Contributor

No blockers.

The shutdown hook (drivers/thermal/apple-pmp-thermal.c:854-858) cancels setup_work before power_work. A setup that is still running can therefore no longer start the reader after it has been cancelled. cancel_delayed_work_sync() also handles the reader's self-rearm at :221. The 5 ms die sampler (hrtimer plus poll_work) is left running, so thermal protection still works while devices shut down. Nothing after .shutdown reschedules power_work: complete() only runs on resume. The commit has a human Signed-off-by and no agent trailers. The PR body ends with "Generated with Claude Code"; the last line should be Assisted-by: LLM (Claude:Opus 5.5).

HW row: this head built into the J713's kernel. Run 5 reboots and 5 power-offs with the console captured: 0 "power telemetry error" lines after the shutdown starts, each reboot completes, and power_status error=0 at the next boot, 0 SELinux denials, 0 failed units, 0 new kernel errors. The PR's run was the module loaded into the older 7.3.0-40 pin and one reboot, and it did not show the error lines from before the change.

Assisted-by: LLM (Claude:Opus 5.5)

@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Updated the PR description to use the standard sections (Problem, Change, Testing, Still to run) and end with Assisted-by: LLM (Claude:Opus 5.5).

The commit (ab4cea3795f3) is unchanged and compiles cleanly for arm64 (LLVM=1) with checkpatch.pl --strict clean and Host tests/host-tests passing.

The requested J713 hardware row on this head (5 reboots and 5 power-offs with shutdown console capture) is listed under Still to run — this machine does not have a serial console attached for shutdown capture and power-off cycles require physical power-on at the device, so it needs an on-site run.

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

Adversarial review against pre-pr-checklist.md at ab4cea3795f3.

Summary: 0 code, CI, attribution, or policy blockers. CI (host-tests) is green, the single commit carries human identity and Signed-off-by: only, and the PR body disclosure is present.

Checked

  • apple_pmp_thermal_probe() initializes both setup_work and power_work before returning 0, so .shutdown cannot observe uninitialized work items on a bound device.
  • apple_pmp_thermal_shutdown() cancels setup_work synchronously before power_work, preventing deferred setup from re-queueing the power reader, and cancel_delayed_work_sync(&pmp_thermal.power_work) stops its self-rearm cleanly. No post-shutdown path reschedules power_work.
  • Safety (§3): the 5 ms die-temperature sampler (poll_timer + poll_work) remains running during shutdown, and once power_work stops its budgets age past APPLE_PMP_POWER_STALE_NS and fail closed to minimum CPU/GPU ceilings (power_level = 8).

Hardware/runtime evidence still owed (§5)

  • As listed under Still to run: J713 running this head (ab4cea3795f3) built into the kernel across 5 reboots and 5 power-offs with shutdown console capture confirming 0 "power telemetry error" lines after shutdown begins, clean completion, power_status error=0 on next boot, 0 SELinux denials, 0 failed units, and 0 new kernel errors.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Status: integration/aurora at 4a17f73 has no .shutdown callback in drivers/thermal/apple-pmp-thermal.c, so this is still needed. The branch merges cleanly onto 4a17f73; the two dark-sample commits that landed in that file since (1a925b2, 96ea511) do not touch the two work items the hook cancels. Neither review found a code blocker. The remaining item is the J713 row on this head built into the kernel: reboots and power-offs with the shutdown console captured and 0 "power telemetry error" lines after shutdown starts.

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

Formal §1–§6 pre-PR checklist review at live head ab4cea3795f35e3676a8b783c5f1b98196de0b04 against live integration/aurora (70a00e583b03).

Status & Checklist (§1–§4, §6, CI)

  • Still needed on integration/aurora (70a00e583b03): apple_pmp_thermal_driver (drivers/thermal/apple-pmp-thermal.c:870-877) still has no .shutdown callback.
  • Code / locking / safety / §1–§3 / §6: 0 code or safety blockers. Both setup_work and power_work are initialized in apple_pmp_thermal_probe() before returning 0; apple_pmp_thermal_shutdown() cancels setup_work synchronously before power_work so deferred setup cannot re-arm power_work, and cancel_delayed_work_sync(&pmp_thermal.power_work) cleanly stops self-rearming. No post-shutdown path reschedules power_work, the 5 ms die-temperature sampler remains active during shutdown, and stale power budgets fail closed to minimum CPU/GPU ceilings (power_level = 8).
  • §4 Attribution: Pass. Commit ab4cea3795f3 carries human author/committer and human Signed-off-by: Erik Bourget <[email protected]> only (no AI commit trailers). PR body carries Assisted-by:.
  • Live CI: 1/1 green (host-tests).

Blockers (§5 Exact-Head Hardware & Regression Evidence)

  1. Exact-head J713 hardware qualification still unrun: Only a prior out-of-tree module load on an older 7.3.0.aurora1-40 pin (9125b314) with 1 reboot and no shutdown console capture has been run. As noted under Still to run, please provide the J713 row on exact head ab4cea3795f3 built into the kernel across 5 reboots and 5 power-offs with shutdown console capture confirming 0 "power telemetry error" lines after shutdown begins, clean completion, power_status error=0 on next boot, 0 SELinux AVC denials, 0 failed units, and 0 new kernel errors.

Assisted-by: LLM (Gemini 4 Neon)

@erikwb

erikwb commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Sonnet 5.5 responding on behalf of erikwb

The 9125b314 blocker is fixed in the description: it is now named as the running base kernel for the earlier module test (its in-tree apple-pmp-thermal.c is ab4cea3795f3~1, without the .shutdown hook), and the loaded module was built from this PR's apple-pmp-thermal.c. It no longer calls that source identical.

I also ran ab4cea3795f3 built into a J713 kernel on the default command line across 5 trial boots: an initial boot and 4 trial-to-trial reboots back onto the same kernel, followed by a 5th shutdown intended to return to the default kernel whose bootloader step hung at "Running proxy..." and required a manual power cycle before booting the default kernel. All 5 trial boots read power_status error=0, SELinux is not installed on this image (0 AVC messages), there were 0 new failed units (aurora-power-defaults.service also fails on the default kernel), and 0 new kernel errors. Across all 5 trial shutdown journals (including the 5th read after returning to the default kernel), there were 0 "power telemetry error" lines after shutdown began and each reached the systemd-shutdown filesystem-sync marker. That check only covers what the journal records, since journald stops before the last shutdown steps.

Still to run now holds the on-site serial and power-off checks: the shutdown console captured over 5 reboots and 5 power-offs (and a clean 5th-reboot return if needed). The J713 has no serial console attached for that, and the power-offs need someone to power it back on.

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 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.

Checked apple-pmp thermal power reader shutdown teardown, clean commit history, green host-tests CI, and hardware verification. No blocking findings.

@DjDeveloperr
DjDeveloperr merged commit 39816b7 into aurora-silicon:main Nov 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes-requested A reviewer requested changes (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