Repository navigation
thermal: apple-pmp: ride out long dark spans while the SoC is idle - #2730
RyanTheTide wants to merge 12 commits into
Conversation
The T8132 thermal driver restricts the CPU clusters and the G16 GPU through a shared budget on the measured CPU and GPU rails: 8 W sustained, a 600 J burst, and a slow climb toward a die temperature target. That is the fanless MacBook Airs' policy, and fan-cooled T8132 machines (Mac mini J773g, MacBook Pro J604, iMac J623/J624) currently inherit it too. On the M4 Mac mini (J773g), under gpubench render.heavy fill at 1080p, macOS 27.2 (26B123) holds its GPU at the top state (1578 MHz) at 100% active with 8.1-9.6 W of GPU power for the whole run. On Linux the fanless budget switched the same load between S10 and S9 every one to two seconds at a 58-61 C die, and earlier runs sat at S8. Decide whether to apply the shared rail power budget from the device tree rather than a board check: disable it when an available apple,smc-hwmon node describes one or more available fan-* children, and keep it on fanless machines. On fan-cooled Macs the rails are still read and reported through hwmon, but restrict nothing; die protection (cooling from 106 C), the thermal governor and critical shutdown are unchanged. A missing or slow SMC rail reading no longer restricts anything on fan-cooled boards either: the GPU's level is published before the read. Signed-off-by: Diljit Singh <hey@djdev.me>
The T8132 PMP telemetry reads six die temperature records at fixed SRAM offsets (0x68624..0x68958, stride 0xa4) observed on the 26.6.2 (25G83) firmware. On 27.2 (26B123), runtime SRAM scans find the same six named records 0x1140 bytes later (0x69764..0x69a98, same 0xa4 stride), while the RTKit header word at 0x234 (matching ADT segment-ranges) moves from 0x3c000 to 0x3d000. Each record starts with its NUL-terminated name. After registering, run a freezable delayed worker that checks apple_pmp_telemetry_online() (including the ASC run bit) before touching SRAM: try the 25G83 offsets first, and otherwise scan from the offset read at header word 0x234 for each record name. A candidate must have a validity word of 0 or 1; a name found more than once is taken only in step with a unique first record at the 0xa4 stride, or refused. Until the records are found, and if they never are, reads behave as before. The firmware populates the records after it starts, so the worker retries every second for a minute and logs the offsets it settles on. The host selftest covers moved records, implausible and duplicate copies, ambiguity and range bounds. Signed-off-by: Diljit Singh <hey@djdev.me>
Over a system sleep Linux keeps and restores the T8132 PMP's second ADT segment in SRAM: 0x3c000..0xa4000 (0x68000 bytes) on 26.6.2 (25G83). On 27.2 (26B123), ADT segment-ranges and the RTKit header word at 0x234 place that segment at 0x3d000..0xa5000 (still 0x68000 bytes). Keeping the fixed 0x3c000 range would overwrite the preceding 4 KiB page on wake and drop the final 4 KiB page of the segment. Prefer the DT apple,sram-keep property (offset and size supplied by the boot loader from ADT segment-ranges) whenever it is present. When apple,sram-keep is absent on T8132, take the offset from header word 0x234 with the 0x68000 fallback size, refusing any offset that is not 4 KiB-aligned or falls outside SRAM. Signed-off-by: Diljit Singh <hey@djdev.me>
…ing it Some firmware reports in by itself once its CPU runs and then acknowledges IOP power on by itself. The T8132 PMP image of macOS 27.2 does: on the M4 Mac mini (J773g), about 0.13 ms after it reports in. After that it answers no IOP power request, so a wake, which clears the acknowledgment and asks again, waits for nothing: apple_pmp 380500000.pmp: RTKit: IOP power acknowledgment failed: -62 macOS 27.2 sends that firmware no IOP power request at all: once it has started the endpoints, the firmware acknowledges IOP power on, and macOS sets the AP on. Other firmware waits to be asked. Add apple_rtkit_boot_or_wake(). It gives the firmware a bounded time to report in (its endpoint map, and CoreAnalytics where the ops need it) and again to acknowledge IOP power on. If both happen, it finishes the boot without a request, as apple_rtkit_boot() does. Otherwise it asks as apple_rtkit_wake() does. A firmware that does not report in by itself therefore gets the request no later than the given time after its CPU starts. Add its Rust wrapper, RtKit::boot_or_wake(). Signed-off-by: Diljit Singh <hey@djdev.me>
…start The PMP's start wakes the firmware: it asks for IOP power and waits for the acknowledgment. The T8132 PMP image of macOS 27.2 acknowledges IOP power on by itself once it has reported in, and answers no request after that, so on the M4 Mac mini (J773g) on 27.2 the start fails: apple_pmp 380500000.pmp: RTKit: IOP power acknowledgment failed: -62 macOS sends that image no IOP power request. Start the PMP with apple_rtkit_boot_or_wake(): take the firmware's own acknowledgment if it comes, and ask as before if it doesn't. The choice follows what the firmware does, not the OS firmware's version. On 27.2 the J773g's whole RTKit start takes 1.3 ms from its CPU starting, so the firmware gets 20 ms for each step. Signed-off-by: Diljit Singh <hey@djdev.me>
…d length The PMP firmware sends UPDATE_IOREG (endpoint 0x20, type 0x36) for some of the registry entries it registered, naming each by its own index, and waits for CONFIRM_IOREG (0x37) before it publishes their reports. The driver confirms with a zero value. On the M4 Mac mini (J773g) on macOS 27.2, the PMP image updates four entries at its start (indices 0x17c, 0x17f, 0x182 and 0x18a). macOS answers each with CONFIRM_IOREG 8 (A2I 0x0037000000000008, hv22/hv23 traces). 8 is the length the firmware registered for those entries; the index is word 0x48 of each entry's REGISTER_IOREG buffer. Keep the firmware's index with each registered entry, and answer an update with that entry's registered length. An index that names no registered entry, which macOS never sees, keeps the old zero, with a warning. Signed-off-by: Diljit Singh <hey@djdev.me>
A system sleep keeps the T8132 PMP firmware's data segment, at the offset the image's own RTKit header gives (word 0x234). The check that the header names a page-aligned segment inside the SRAM ran only when a sleep began, so a firmware image that doesn't describe itself that way ran until its first sleep, which then failed. Check it at probe, and refuse such an image there with a message. The driver then runs only a T8132 image that describes its own layout, and the M4 PMP pieces can rely on that instead of on the OS firmware's version. An offset of 0 is refused too. Signed-off-by: Diljit Singh <hey@djdev.me>
…tible
The M4 PMP session's pieces — its power-vote bridge, its telemetry and
thermal policy, and the PMP report's readiness — previously ran only on
the Airs and on macOS 26.6.2 firmware because apple_t8132_firmware_path()
compares the boot loader's os-fw-version with "26.6.2". On the M4 Mac
mini (J773g) on macOS 27.2 there is then no thermal zone, no telemetry,
and no vote bridge, so the G16 driver's apple_pmp_j713_gpu_prepare()
refuses the PMP session and the GPU cannot come up.
None of these pieces depends on the OS firmware's version or the root
SoC compatible any more. Each takes what it needs from the PMP firmware
itself:
- the data segment from the image's header, which the PMP driver now
checks at probe;
- the temperature records by name;
- the IOP power handshake the firmware starts;
- each registry entry's length as the firmware registered it.
The vote bridge still checks its soc-device record in the firmware's
tunables.
Key each piece on the PMP node's own compatible ("apple,t8132-pmp-v2")
rather than the OS firmware version gate or a root SoC compatible check:
- pmp-report.c checks supplier->of_node directly (dropping the unused
apple_t8132_firmware_path stubs from the t6030-pmp host test harnesses);
- apple-pmp-thermal.c checks sensors->dev->of_node;
- pmp-display.h and pmp-telemetry.c check for an available
apple,t8132-pmp-v2 node.
apple_t8132_firmware_path() stays for the display, DART, and other paths
that this series does not touch.
Signed-off-by: Diljit Singh <hey@djdev.me>
…ode compatible t8132_platform_handoff() previously returned early unless the boot loader reported macOS 26.6.2 firmware or the Mac was an Air. On other firmware, macOS 27.2 among them, it applied neither of its two parts: - The PMGR ownership policy. Without it Linux owns every power domain in the board tree, with auto-PM written to each one at probe, including domains that stay firmware-owned (AIC, GPIO, display) or out of Linux's reach. On the M4 Mac mini (J773g) on 27.2 that ends in an SError when the PCIe controller probes. - The memory nodes (MCC, PMC and CLPC) for a loader tree that lacks them. They depend on the PMP path, which now self-describes from the firmware image header. Key the handoff on the presence of an "apple,t8132-pmp-v2" node rather than the root SoC compatible or OS firmware version string, and reuse that node reference when populating the missing platform nodes. Signed-off-by: Diljit Singh <hey@djdev.me>
On the 27.2 firmware a cool, idle J713 keeps all six PMP sensors invalid far longer than the 2 s hold sized from 26.6.2 (0.46 s worst case there): sampled at the driver's own 100 ms, 86% of samples were all-dark and the longest span was 13.3 s. Each span past 2 s latches the minimum CPU caps again, and the recovery climbs back over seconds, so the machine spends most of its time well below its clocks. Keep going from the last cool reading for up to 30 s, but only while the SMC's measured P, E and GPU rails, read within the last 1.5 s, add up to under 500 mW. A dark cluster is powered down; the rail reading is the independent proof that nothing is drawing power while the sensors are dark. The 2 s hold and every other limit are unchanged. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Blockers: 2. (Same change as closed #2720, identical patch-id; review of that commit.)
|
The idle hold rides out a dark span of up to 30 s while the SMC rails say the SoC is idle. Those bounds were measured on a fanless M4 Air, but the rails are read on every machine, so a Mac with a fan would take the long hold too. Only take it where the shared rail budget applies (no SMC fan), and only from a reading under 70 C. A die drawing under 500 mW for 30 s cannot climb from there to the 106 C cooling start, so the held value stays a safe stand-in for the real one. Hotter readings and fan-cooled Macs keep the 2 s hold alone. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Thanks for the review. Follow-up commit 44e3094 is pushed. It is a separate commit with no force push, and can be squashed on merge. 2 (fan-cooled Macs): You're right: the rails are read on every machine. The idle hold now also requires 1 (bounds, and a stale reading treated as fresh): The long hold now also requires the last reading to be under 70 C ( J713 row on this head (#2533 d3a8923 + both commits): 0 Numbers
Assisted-by: LLM (Claude:Opus 5.5) |
…rises The long idle dark-span hold started only below a chosen 70 C. Derive that limit from the first cooling trip instead: the hold may last 30 s with the rails under the idle cap, and a load step can ride it for at most 2 s (the rails are re-read every 500 ms and go stale after 1.5 s). Subtract the largest rise measured over each of those windows on a fanless M4 (3.25 C over 30 s with the rails under 500 mW, 18.75 C over 2 s of all-core load) from APPLE_PMP_PASSIVE_MC. That gives 84 C, and a static_assert keeps it at or under the 2 s hold's own 90 C ceiling. State why 500 mW is a cap and not a tuning value (idle rail sum median 28 mW, 99% under 70 mW) and describe the selection by fan presence rather than by the machine the numbers were measured on. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Follow-up a3a2e8e is pushed as a separate commit (no force push; it can be squashed on merge). It covers the review's two open points. Hold start limit (was a chosen 70 C): the limit is now derived from the first cooling trip:
A 500 mW: the code comment now says why it is a cap, not a tuning value. After a soak, the idle rail sum had a median of 28 mW and stayed under 70 mW in 99% of 466 samples (308 mW at most). A busy cluster draws 6-8 W. The comment also states that the selection is by fan presence ( Testing: W=1 and checkpatch are clean. I ran a live module A/B on a 7.3.0-bj713t6+ boot (J713, 27.2, default cmdline): 240 s all-core load, then 150 s idle, for each head. a3a2e8e showed no regression against 44e3094. Still to run: the window where the two heads differ (a last reading between 70 and 84 C followed by a dark span longer than 2 s) never happened in this row, because the sensors came back within about 1 s of the load stop. So the row does not exercise the new limit itself. Row detail
Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed at live head a3a2e8ea60b734c5221738226364298132fb034d against all 6 sections of pre-pr-checklist.md. Requesting changes for code bugs, §3 safety/derivation concerns on a3a2e8ea, and missing CI/HW verification on the live head.
Blockers
-
Stale
idle_rail_ns/idle_rail_mwnot reset inprobe()orcleanup()(drivers/thermal/apple-pmp-thermal.c:697-742,862-886)
pmp_thermalis a file-scopestatic struct.apple_pmp_thermal_probe()resetsvalid_ns,governor_ns,cached_error,power_error, etc., andapple_pmp_thermal_cleanup()is explicitly documented as/* Leaves every field reset, so a deferred setup can be attempted again. */, yet neither resetspmp_thermal.idle_rail_ns = 0orpmp_thermal.idle_rail_mw = 0. A deferred-setup retry afterpower_workstarted (e.g.goto failat line 836) or an unbind/rebind leaves stale pre-cleanup rail state in the static struct. -
Rail timestamp captured after blocking SMC I/O and not invalidated on SMC failure (
drivers/thermal/apple-pmp-thermal.c:249-264)apple_pmp_power_work()callsapple_pmp_power_read_rails(mw)(which acquiresdevice_lock(dev)and runs 6 blocking SMC transactions) before takingpmp_thermal.lockand readingnow = ktime_get_ns(). Stampingidle_rail_ns = nowafter the blocking read hides SMC/lock latency inside the 1.5 s staleness bound; capture the sample timestamp beforeapple_pmp_power_read_rails()(keepingnowunder the lock forcooling.last_ns).- When
apple_pmp_power_read_rails()fails (ret != 0, including the!mw[0] && !mw[1]all-zero firmware-reset-ENODATAcheck at line 254),idle_rail_nsis left untouched. Althoughapple_pmp_power_fail()drops CPU/GPUpower_levelto 8 on fanless Macs,apple_pmp_rails_idle()still returnstruefor up to 1.5 s after a known SMC failure, continuing to feed a frozen temperature toapple_pmp_cooling_sample(),thermal_zone_device_update(), and hwmon instead of failing closed with-ENODATA. Clearingpmp_thermal.idle_rail_ns = 0whenret != 0avoids trusting a pre-fault rail sample.
-
§3 Safety — unverified zero-margin 84 C derivation & hardcoded single-unit bounds (
a3a2e8ea,apple-pmp-thermal.c:58-77)- Extending the fail-closed dark-sensor timeout 15x (2 s → 30 s) relies on hardcoded J713-measured constants (
30 s,500 mW,1.5 s,3.25 C,18.75 C) applied to every fanless T8132 (power_budget) without machine-provided bounds. - Specifically, commit
a3a2e8ealoosens the hold start ceiling from70 Cto84 Cby subtracting exact 1 Hz, CPU-only single-unit rises (3250 + 18750 mC) fromAPPLE_PMP_PASSIVE_MC(106000 mC) with zero safety margin. It does not account for combined CPU + GPU 20 W burst load steps (APPLE_PMP_BURST_MW), sub-second peak rises missed by 1 Hz sampling, SMC read latency (blocker #2), or non-PP0b/PPbb/PP1bSoC heat sources (pmp-power-policy.h:193-194notes those rails exclude other SoC blocks). - As the PR's own
Still to runnotes, the70–84 Cwindow added bya3a2e8eawas never exercised on hardware. Please restore conservative headroom (e.g., keep a substantially lower ceiling or prove a bounded CPU+GPU 20 W burst step with explicit margin) and clarify whether these bounds can be moved to DT or derived from hardware state per §3.
- Extending the fail-closed dark-sensor timeout 15x (2 s → 30 s) relies on hardcoded J713-measured constants (
-
CI not run & base branch still unmerged
- This PR targets
djdev/t8132-pmp-272(#2533, still open), sostatusCheckRollupis empty (0 CI checks executed). Retarget tointegration/auroraonce#2533merges sohost-testsruns on the live head, and coordinate theapple_pmp_power_work()overlap with#2699.
- This PR targets
Checked & clean
- Concurrency / wrap / overflow:
mw[0] + mw[1] + mw[2]is bounded by3 * 50000 = 150000(apple_pmp_power_decode()), so nounsigned intoverflow;snapshot.finished_ns - pmp_thermal.valid_nsandapple_pmp_rails_idle()run underpmp_thermal.lockon monotonicktime_get_ns()withnow >= idle_rail_nsguarded;static_assertevaluates84000 <= 90000. - §4 Attribution: All 3 commits (
236cbce33242,44e309469911,a3a2e8ea60b7) have human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and humanSigned-off-by:only (zero AI trailers); PR body includesAssisted-by:. - §6 Naming: Clean.
§5 Hardware rows needed once blockers are fixed
- Live-head J713 boot exercising the idle hold at the revised ceiling (including a hot-to-idle transition and combined CPU+GPU burst edge) plus full §5 regression summary (
0 SELinux denials,0 failed units,0 new kernel errors).
Assisted-by: LLM (Gemini 4 Neon)
d3a8923 to
f5610a1
Compare
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR checklist re-review at a3a2e8ea60b734c5221738226364298132fb034d (§1–§6). No new commits have been pushed to this PR since our prior review on a3a2e8ea, while its base branch djdev/t8132-pmp-272 (#2533) was rebased to f5610a14 after #2699 merged (96ea511e). Keeping REQUEST_CHANGES for the open blockers below plus the new merge conflict.
Blockers
- Merge conflict & stale base stack (
CONFLICTING/DIRTY), 0 CI checks:- Base branch
djdev/t8132-pmp-272was force-pushed tof5610a14(incorporating merged#2699).#2730still sits on old#2533d3a89232, so its diff now drags 9 stale pre-rebase#2533commits (485f153e..d3a89232), conflicts with the base branch, and has 0 CI runs (statusCheckRollupempty). - Rebase the 3
#2730commits onto#2533(f5610a14) — or ontointegration/auroraonce#2533merges — reconcilingapple_pmp_power_work()with#2699'sdarkbranch so CI runs cleanly on the live head.
- Base branch
- Stale
idle_rail_ns/idle_rail_mwnot reset inprobe()orcleanup()(drivers/thermal/apple-pmp-thermal.c):- Still unaddressed on
a3a2e8ea: neitherapple_pmp_thermal_probe()norapple_pmp_thermal_cleanup()resetspmp_thermal.idle_rail_ns = 0andpmp_thermal.idle_rail_mw = 0, leaving stale pre-cleanup rail state across deferred-setup retries or unbind/rebind.
- Still unaddressed on
- Rail timestamp captured after blocking SMC I/O and not invalidated on SMC failure (
drivers/thermal/apple-pmp-thermal.c):- Still unaddressed on
a3a2e8ea:idle_rail_nsis stamped after blockingapple_pmp_power_read_rails(mw)(hiding SMC/lock latency inside the 1.5 s staleness bound) and is not cleared whenapple_pmp_power_read_rails()fails (ret != 0, including the!mw[0] && !mw[1]all-zero check), lettingapple_pmp_rails_idle()keep returningtruefor up to 1.5 s after a known SMC fault.
- Still unaddressed on
- §3 Safety — zero-margin 84 C derivation & hardcoded single-unit bounds (
a3a2e8ea):- Still unaddressed on
a3a2e8ea: the 84 C ceiling subtracts 1 Hz CPU-only single-unit rises (3.25 C + 18.75 C) from106 Cwith zero safety margin, omits combined CPU+GPU 20 W burst load steps, sub-second spikes, SMC read latency, and non-PP0b/PPbb/PP1bheat sources, and the added70–84 Cwindow remains unexercised on hardware. Restore conservative headroom (or prove bounded CPU+GPU burst steps with explicit margin) and clarify whether bounds can come from DT or hardware state per §3.
- Still unaddressed on
Checklist & Live Status
- §4 Clean-room & attribution: Pass — human commits and
Signed-off-by:only,Assisted-by:in PR body. - §5 Evidence: Needs live-head J713 run after rebase/fixes (exercising the revised ceiling, hot-to-idle + CPU+GPU burst edge, and
0 SELinux denials/0 failed units/0 new kernel errors). - §6 Naming: Pass.
- CI (at
a3a2e8ea): Empty (0checks; PR isCONFLICTING/DIRTY).
Assisted-by: LLM (Gemini 4 Neon)
f5610a1 to
0b5979c
Compare
|
Closing: the long hold relies on fixed temperature and power bounds measured on one machine; a replacement should tell an idle SoC from the hardware state instead. |
|
Reopened and kept as a draft; the comment above lists what it still needs before review. cc @niteria |
This is the idle dark-span hold for the M4 Air (J713) on the macOS 27.2 firmware. It is three commits (the hold, plus two review follow-ups), stacked on #2533 (head d3a8923), which no longer carries it. It replaces #2720, whose base was rewritten.
With #2533 alone, an idle J713 stays on the minimum CPU caps. Its sensors go dark much longer than the 2 s hold, so every long span returns
-61and brings the caps back. The hardware row is in #2533 (comment): 462-61in 150 s, and cpu0 delivered 903 MHz.The commit holds the last cool reading for up to 30 s, but only while the SMC's measured P+E+GPU rails, read within the last 1.5 s, total under 500 mW. The 2 s hold and every other limit stay as they were. The long hold applies only where #2533's rail budget is active (no SMC fan, i.e. the fanless Airs), and only from a reading under 84 C. That limit is derived from the 106 C cooling trip minus the largest rises we measured during a 30 s idle hold (3.25 C) and during a 2 s load step (18.75 C); see the third commit. Macs with a fan keep the 2 s hold alone.
The first two commits (identical diff) are in the J713's default kernel today: 0
-61, caps 4464000/2892000, and the clocks reach every OPP. It also passed fanless all-core soaks of 10 and 30 min and 75+ warm reboots.Numbers and method
-61in 150 s, caps 912000/900000.-61, caps 4464000/2892000, cpu0 4447.8 MHz, cpu1 2883.0 MHz.-61in 300 samples.Assisted-by: LLM (Claude:Opus 5.5)