Skip to content

thermal/drivers/apple-pmp: count only kernel-thread reads as the core's failed reader - #3824

Merged
RyanTheTide merged 1 commit into
mainfrom
fix/pmp-thermal-fault-disable-kthread
Dec 1, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
fix/pmp-thermal-fault-disable-kthread

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

What

Follow-up to #2774 (the review's non-blocking same-thread case). If a user space thread read thermal_zoneN/temp while the PMP sensor was failing and then wrote disabled to thermal_zoneN/mode itself, apple-pmp-thermal took that for the core's broken-sensor disable and re-enabled the zone at the next good sample. Now a failed read is remembered only when the reader is a kernel thread (the core backs off and gives up from its workqueues), so a user task never matches and a disable it writes stays.

Tested

  • KUnit apple-pmp-policy 13/13 (UML), including the new user-reader cases in apple_pmp_test_fault_disable_origin.
  • run-host-tests.py --only pmp 24/24, --only asahi-m4 pass.
  • arm64 LLVM W=1 build of drivers/thermal clean; checkpatch --strict clean.
  • No J713 row: a manual-disable edge case with no change to sampling or the guard. The thermal/drivers/apple-pmp: ride out idle dark sensors and preserve zone backoff #2774 rows (fanless J713 load, suspend, idle) cover the paths this touches.

Risk

Risk: two-way · J713 (only the auto re-enable decision changes; a revert restores the #2774 behaviour).
If the core ever gave up from a user task, the zone would stay disabled until re-enabled by hand, which is the behaviour before #2774.

Not yet

  • Nothing.

…'s failed reader

A user space thread that read thermal_zoneN/temp while the sensor was
failing, and then wrote "disabled" to thermal_zoneN/mode, was taken for
the core's broken-sensor disable: both calls came from the same task, so
the next good sample re-enabled the zone the operator had disabled.

The core backs off and gives up from its workqueues, so remember a failed
reader only when it is a kernel thread. A user task is never recorded,
and a disable it writes stays.
@RyanTheTide
RyanTheTide requested review from a team as code owners December 1, 2026 18: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 b7ffc9b

Checked:

  • A failed read is recorded only for a kernel thread (current->flags & PF_KTHREAD). A user task that reads a failing temp and then writes mode=disabled itself now leaves failed_reader NULL, so its disable counts as manual and stays. That closes the same-thread case from the #2774 follow-up.
  • Tried to find an interleaving where a user read wipes a core failure between the core's get_temp and its thermal_zone_broken_disable(). Both the sysfs temp read (thermal_zone_get_temp) and __thermal_zone_device_update() run under tz->lock, and the core's read, recheck and broken-disable happen inside one locked update. So no user read can land between them.
  • The core gives up from its poll/recheck work items (kworkers). The first failure after a user re-enable only schedules a recheck, because the recheck delay is reset at broken-disable. If the core ever gave up from a user task, the zone would stay disabled: the pre-#2774 behaviour and the safe side, as the PR says.

Follow-ups (not blocking):

  • None.

@github-actions github-actions Bot added 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) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at b7ffc9bb: not ready yet

Check Detail
CI at head ok 3 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head no no line with the head SHA b7ffc9bb, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · J713 (only the auto re-enable decision changes; a revert restores the #2774 behaviour). If the core ever gave up from a user task, the zone would stay disabled until re-enabled by hand, which is the behaviour before #2774.

Areas: none matched in CODEOWNERS

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

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

Reviewed the failed-reader assignment, the thermal core's polling work and the mode-change path. A user read can no longer arm automatic re-enable, and the core workqueue keeps its same-task recovery path. The diff and host CI are clean. Merge still needs a J713 row on this head covering manual disable and recovery after a core-originated disable.

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

Copy link
Copy Markdown
Contributor Author

Row: b7ffc9b + J713 (M4 Air, fleet91 with this driver as a module) + PASS. The swapped module came up at level 0 with the zone enabled. echo disabled > thermal_zone2/mode from a root shell stayed disabled for 12 s of good samples (no auto re-enable). echo enabled re-enabled it with the normal ramp down from level 8. The stock module was reloaded afterwards. The same-thread failed-read case is covered by KUnit (apple_pmp_test_fault_disable_origin).

@RyanTheTide
RyanTheTide merged commit 0000aca into main Dec 1, 2026
6 checks passed
@RyanTheTide
RyanTheTide deleted the fix/pmp-thermal-fault-disable-kthread branch December 1, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants