Skip to content

M4 PMP: fan-based rail budget and self-described 27.2 PMP path - #2533

Open
DjDeveloperr wants to merge 9 commits into
integration/aurorafrom
djdev/t8132-pmp-272
Open

DjDeveloperr wants to merge 9 commits into
integration/aurorafrom
djdev/t8132-pmp-272

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

M4 (T8132) PMP session support on macOS 27.2 firmware (26B123), with no OS-version or board-name gate.

Why

On integration/aurora, the M4 PMP pieces (power-vote bridge, telemetry, thermal policy, and PMP report readiness) run only on the Airs or when the boot loader's os-fw-version is "26.6.2". On the M4 Mac mini (J773g) running 27.2 firmware, that leaves no thermal zone, telemetry, or vote bridge, so the G16 driver's apple_pmp_j713_gpu_prepare() refuses the PMP session.

Observed runtime differences on 27.2 compared to 26.6.2:

  • the ADT segment-ranges data offset and the SRAM RTKit header word at 0x234 move from 0x3c000 to 0x3d000, and runtime SRAM scans locate the six named die temperature records 0x1140 bytes later (0x69764..0x69a98, same 0xa4 stride);
  • the PMP firmware reports in and acknowledges IOP power on by itself once its CPU starts, and does not answer a subsequent IOP power request (-62);
  • macOS confirms UPDATE_IOREG messages with each entry's registered length (8).

What

  1. thermal: apple-pmp: no shared rail power budget on fan-cooled Macs. Decides the shared 8 W CPU/GPU rail budget from the device tree rather than a board check or module parameter: inspects available apple,smc-hwmon nodes for available fan-* children (covering J773g, J604, J623/J624, and future fan-cooled T8132 boards while keeping the budget on fanless Airs). Rails remain read and reported through hwmon; die cooling from 106 C, thermal governor, and critical shutdown are unchanged.
  2. soc: apple: pmp: find the T8132 temperature records by name. Checks the 26.6.2 offsets first, then scans SRAM starting from header word 0x234 for each named temperature record (0xa4 stride for duplicates, plausibility check on the validity word). Runs on system_freezable_wq and checks apple_pmp_telemetry_online() (including the ASC run bit) before and after scanning.
  3. soc: apple: pmp: keep the T8132 firmware's own data segment over a sleep. Prefers DT apple,sram-keep (exact offset and size from ADT segment-ranges) when provided by the boot loader; otherwise takes the offset from header word 0x234 (4 KiB-aligned) with the 0x68000 fallback size.
  4. soc: apple: rtkit: apple_rtkit_boot_or_wake(). Gives a co-processor a bounded window (20 ms, 15x the 1.3 ms observed J773g start) to report in and acknowledge IOP power on by itself before falling back to apple_rtkit_wake().
  5. soc: apple: pmp: start through boot_or_wake(). Matches the observed macOS 27.2 handshake on J773g without sending an unanswered IOP power request.
  6. soc: apple: pmp: confirm UPDATE_IOREG with the entry's registered length (word 0x48 of its REGISTER_IOREG buffer; 8 for the four entries updated on J773g 27.2; unknown indices keep 0 with a warning).
  7. soc: apple: pmp: refuse at probe a T8132 image whose header names no page-aligned data segment in SRAM, rather than failing at the first sleep.
  8. soc: apple: t8132: apple_t8132_pmp_path(). Replaces the 26.6.2 version gate for the PMP session pieces (vote bridge, telemetry, thermal, PMP report). apple_t8132_firmware_path() stays unchanged for display, DART, PMGR, and boot-handoff paths.
  9. soc: apple: t8132-platform-handoff: apply platform data on every M4 firmware. Applies the SoC PMGR ownership policy and missing memory nodes (MCC, PMC, CLPC) on every T8132 regardless of firmware version.

The earlier J713 dark-span hold commit (422bc70b) has been dropped from this PR to avoid hardcoded idle thresholds and to stay clear of #2699.

Testing

  • Compile (12aea2b043f2 on integration/aurora a84637dca209): asahi profile Image + modules built cleanly (rc=0, 0 warnings on all modified files).
  • Static checks: scripts/checkpatch.pl --git origin/integration/aurora..HEAD clean (0 errors, 0 warnings across all 9 commits).
  • Host selftest: tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-sensor.py passed (75,414 frozen oracle rows + moved-record, ambiguity, and range-bounds checks).
  • M4 Mac mini (J773g), macOS 27.2 (26B123) firmware, Linux 7.3.0-ARCH-m4drv8 (two boots, module-equivalent apple-pmp.ko + apple-pmp-thermal.ko):
    • PMP self-ack start (PMP firmware acknowledged IOP power on by itself, PMP firmware and endpoint ready), 0 -62 timeouts, 0 unregistered UPDATE_IOREG entries.
    • Record locator settled on 0x69764 0x69808 0x698ac 0x69950 0x699f4 0x69a98 (data from 0x3d000).
    • apple-pmp-thermal probed cleanly with rail power reported, no power budget, die thermal zone (apple-pmp-die 52.75–56.0 C), 6 apple_pmp + 4 apple_pmp_power hwmon inputs, vote bridge ready, and full GPU/display bring-up with 0 backstop trips across compute/render rows.
  • Pending before leaving draft:
    • Full-image boot on this head (12aea2b043f2) on J773g 27.2.
    • J713 (M4 Air) 26.6.2 regression row and 27.2 row.
    • Suspend/resume on 25G83 and 26B123 for the data-segment backup change.
    • Regression rows on other PMP Macs (since rtkit start and CONFIRM_IOREG touch every PMP SoC).

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Hardware row from a J713 (M4 Air) on the 27.2 (26B123) stub. The name lookup works there, but on its own it does not lift the CPU caps on an Air.

Records: with this PR the J713 logs temperature records at 0x69764 0x69808 0x698ac 0x69950 0x699f4 0x69a98 (data from 0x3d000). A separate read-only scan of the PMP SRAM on the same unit finds the same six addresses (+0x1140 from 25G83, same 0xa4 stride).

Still capped: with the records found, an idle J713 keeps all six sensors invalid much longer than the 2 s APPLE_PMP_GATED_HOLD_NS. Each longer span gives sensor error -61 and the minimum caps come back. With this PR alone I measured 165 of those in 150 s, scaling_max stuck at 912000/900000, and cpu0 at 900 MHz.

Proposed addition (patch below): hold the last cool reading for up to 30 s, but only while the SMC's measured P+E+GPU rails total under 500 mW. The rail reading must be from the last 1.5 s, and an all-zero read doesn't count. A dark cluster is powered down, and the rails show independently that nothing is drawing. The 2 s hold and every other limit are unchanged. With this PR plus the patch: 0 -61, caps 4464000/2892000, and measured clocks within 1% of every OPP (P 4443-4450 MHz, E 2872-2884 MHz with all cores loaded). Five warm reboots were clean.

Not covered by this row: the sleep-segment commit, because I ran no suspend.

Numbers and method
  • Kernel 7.3.0-bj713+ = integration/aurora 0abc2f3 + linux#2189 + linux#2205, with this PR's 3 commits cherry-picked. aura Stage 1 tip-dev 3d517e63, Stage 2 c0a50c00, macOS 27.2 26B123 stub.
  • Dark spans: a read-only poll of the six records' valid words. At 100 ms (the driver's cool cadence), over 120 s: 86% of samples all-dark, 53 spans, mean 1.9 s, max 13.3 s. At 5 ms the poller keeps a cluster awake, so the max drops to 0.75 s. Per-channel valid: ta000m/te000m 1.7%, te001m/tp000m/tp001m 13%, tp002m 0%.
  • Clock measurement: a dependent add chain pinned to each CPU, timed with CLOCK_MONOTONIC, with scaling_min = scaling_max = each OPP in turn.
  • A/B, same kernel and modules except apple-pmp-thermal.ko:
    • PR only: 165 x -61 / 150 s, caps 912000/900000, cpu0 900.6 MHz
    • PR + patch: 0 x -61, caps 4464000/2892000, cpu0 4447.8 MHz, cpu1 2883.0 MHz
  • One by-design -61 in five warm boots, 33 s into GNOME start. The last reading was 74 C and the rails were busy, so the idle hold did not apply and the caps recovered within seconds.
Patch: thermal: apple-pmp: ride out long dark spans while the SoC is idle
 drivers/thermal/apple-pmp-thermal.c | 31 +++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/apple-pmp-thermal.c b/drivers/thermal/apple-pmp-thermal.c
index 9eba514e1feda..29c8bc2b46040 100644
--- a/drivers/thermal/apple-pmp-thermal.c
+++ b/drivers/thermal/apple-pmp-thermal.c
@@ -43,6 +43,16 @@
 /* Inside the cooling slope window (50-250 ms); used while cool and idle. */
 #define APPLE_PMP_SLOW_POLL_MS		100
 #define APPLE_PMP_GOVERNOR_NS	100000000ULL
+/*
+ * On the 27.2 firmware a cool, idle J713 keeps every sensor dark much longer than
+ * APPLE_PMP_GATED_HOLD_NS (13.3 s the longest of 53 spans in 120 s sampled at
+ * 100 ms, 86% of samples dark). Dark clusters are powered down, so ride a span out
+ * this long as well, but only while the SMC's measured CPU and GPU rails, read no
+ * longer ago than the stale limit, add up to less than an idle SoC draws.
+ */
+#define APPLE_PMP_GATED_IDLE_HOLD_NS	30000000000ULL
+#define APPLE_PMP_IDLE_RAILS_MW		500
+#define APPLE_PMP_IDLE_RAILS_STALE_NS	1500000000ULL
 
 struct apple_pmp_cluster {
 	struct cpufreq_policy *policy;
@@ -61,6 +71,9 @@ static struct {
 	struct delayed_work power_work;
 	struct device *power_hwmon;
 	unsigned int rail_mw[3];
+	/* The last successful SMC rail read, whatever the sensors said, and when. */
+	unsigned int idle_rail_mw;
+	u64 idle_rail_ns;
 	int power_error;
 	u64 gpu_epoch;
 	bool power_polling;
@@ -226,6 +239,10 @@ static void apple_pmp_power_work(struct work_struct *work)
 	 */
 	mutex_lock(&pmp_thermal.lock);
 	now = ktime_get_ns();
+	if (!ret) {
+		pmp_thermal.idle_rail_mw = mw[0] + mw[1] + mw[2];
+		pmp_thermal.idle_rail_ns = now;
+	}
 	if (!ret && (!pmp_thermal.enabled || pmp_thermal.cached_error ||
 		     now - pmp_thermal.cooling.last_ns > 500000000ULL))
 		ret = -EAGAIN;
@@ -397,6 +414,14 @@ static int apple_pmp_guard(unsigned int level)
 	return err;
 }
 
+/* Called with the lock held: did the SMC just see an idle SoC? */
+static bool apple_pmp_rails_idle(u64 now)
+{
+	return pmp_thermal.idle_rail_ns && now >= pmp_thermal.idle_rail_ns &&
+	       now - pmp_thermal.idle_rail_ns < APPLE_PMP_IDLE_RAILS_STALE_NS &&
+	       pmp_thermal.idle_rail_mw < APPLE_PMP_IDLE_RAILS_MW;
+}
+
 static int apple_pmp_sample(void)
 {
 	struct apple_pmp_snapshot snapshot;
@@ -415,8 +440,10 @@ static int apple_pmp_sample(void)
 		pmp_thermal.valid_ns = snapshot.finished_ns;
 		pmp_thermal.valid_mc = value;
 	} else if (ret == -ENODATA && pmp_thermal.valid_ns &&
-		   snapshot.finished_ns - pmp_thermal.valid_ns < APPLE_PMP_GATED_HOLD_NS &&
-		   pmp_thermal.valid_mc < APPLE_PMP_GATED_HOLD_MC) {
+		   pmp_thermal.valid_mc < APPLE_PMP_GATED_HOLD_MC &&
+		   (snapshot.finished_ns - pmp_thermal.valid_ns < APPLE_PMP_GATED_HOLD_NS ||
+		    (snapshot.finished_ns - pmp_thermal.valid_ns < APPLE_PMP_GATED_IDLE_HOLD_NS &&
+		     apple_pmp_rails_idle(snapshot.finished_ns)))) {
 		value = pmp_thermal.valid_mc;
 		ret = 0;
 	}

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

apple_pmp_thermal_setup() sets pmp_thermal.power_budget = !of_machine_is_compatible("apple,j773g"), and the new power_budget module parameter (0644) can override it at run time. The budget is the policy for machines without a fan, so it should follow the hardware description rather than a board name: for example, disable it when the device tree describes fans/an active cooling device, or with a property on the PMP thermal node. The runtime override should go away with that; it changes thermal behaviour outside the driver's control. Until then this should stay a draft.

@RyanTheTide

RyanTheTide commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Hardware data for the 27.2 PMP layout half of this PR: on the 13-inch M4 MacBook Air (J713, firmware 27.2) a kernel without it (integration/aurora b4cd7b3 plus unrelated merges) boots cleanly, but the PMP die sensor read fails and apple-pmp-thermal fails safe:

apple-pmp-thermal: sensor error -5; CPU minimum caps retained
thermal thermal_zone1: Unable to get temperature, disabling!
policy0 scaling_max_freq 912000 (cpuinfo_max_freq 4464000)
policy1 scaling_max_freq 900000 (cpuinfo_max_freq 2892000)

With this whole PR (plus one local commit) in the lab kernel, the same Air runs at 3.9 GHz sustained under thermal control, so the sensor path works there; which of the two halves the sensor read needs is not separated yet. If it is the layout change, as the error suggests, splitting the 27.2 PMP layout into its own PR would let it land now, while the budget selection moves to a hardware description (my earlier comment).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Follow-up from the M4 Air (J713) on 27.2, after a day on kernels that carry this PR plus the dark-span hold from my earlier comment (#2533 (comment)):

  • The hold is what keeps an idle J713 off the minimum caps. With this PR alone the CPUs drop to 900 MHz every few seconds. With the hold, single-core and all-core clocks reach every step (4.46 GHz P / 2.89 GHz E).
  • Fanless soaks: 10 min and 30 min all-core held 3.9 GHz with no Linux cap (die plateau 92-94 C). 75+ warm reboots with no regression.
  • One residual: when a heavy load starts or stops, all six sensors can go dark with the last reading above 90 C while the rails still show load. The driver then drops to the minimum caps for 2-3 s, which is the safe direction.

Could you fold the hold into this PR (or tell me to open it as a separate PR on top)? The J713 default kernel carries both today, and getting them merged takes the J713 one step closer to running the plain integration tip.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 5.

  1. apple-pmp-thermal.c:765 picks the rail budget with of_machine_is_compatible("apple,j773g"). The budget is a fanless-machine policy, so it should come from the device tree: the presence of a fan/active cooling device, or a property on the PMP node. Otherwise the next fan-cooled T8132 board silently gets the 8 W budget.
  2. apple-pmp-thermal.c:122-124 adds a 0644 power_budget module parameter that turns power limiting on or off at run time. Please drop it and keep A/B overrides out of tree.
  3. 3be25c8, ab424b0 and 56e810b carry Co-Authored-By trailers. Please drop them and keep only the human Signed-off-by.
  4. 422bc70: the 30 s hold, the 500 mW idle threshold and the 1.5 s staleness limit (lines 53-55) are constants sized on one J713. During the hold, the cooling governor and the critical-shutdown counter see a reading that can be up to 30 s old. Please derive "the dark clusters are powered down" from a hardware state, such as the clusters' power state or the PMP's own sensor status. Failing that, take the bounds from the device tree. Note too that the idle check counts only the P, E and GPU rails.
  5. The ab424b0 message and the PR body describe the layout of the PMP firmware images (zero-fill region, "nothing in the image addresses the records", segment table, boot-argument keys). Please limit them to what is observed at run time: the SRAM scan, the ADT segment-ranges and the header word the driver reads.
    Smaller points: the sleep range keeps a constant 0x68000 size while only its offset is read (pmp.rs:941). The record locator runs on a non-freezable workqueue and scans SRAM without checking the ASC run bit (pmp-telemetry.c:80). It should use system_freezable_wq and apple_pmp_telemetry_online().
    Missing rows: anything on this head; J773g 27.2 with the budget off; suspend/resume on 25G83 and 26B123 for the data-segment change; J713 on 26.6.2 as a regression row.

@DjDeveloperr DjDeveloperr changed the title M4 PMP: no Air power budget on the Mac mini; 27.2 PMP firmware layout M4 PMP: fan-based rail budget and self-described 27.2 PMP path Nov 21, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Rebased onto integration/aurora (a84637dca209) at 12aea2b043f2 (9 commits) and addressed all 5 blockers and both smaller points from your review:

  1. DT-driven budget selection (485f153e1220): Replaced of_machine_is_compatible("apple,j773g") with apple_pmp_machine_has_fan(), checking available apple,smc-hwmon nodes for available fan-* children (matching macsmc-hwmon). Covers J773g, J604, J623/J624, and future fan-cooled T8132 boards while keeping the 8 W budget on fanless Airs.
  2. Dropped power_budget module parameter (485f153e1220): Removed the 0644 runtime override completely.
  3. Trailers: Removed all Co-Authored-By trailers; every commit carries only the human Signed-off-by.
  4. Dropped 422bc70b dark-span hold: Removed the 30 s / 500 mW / 1.5 s idle-hold commit from this PR so we neither carry hardcoded idle bounds nor conflict with thermal: apple-pmp: keep the power budget over a dark sensor sample #2699. Any follow-up hold on top of thermal: apple-pmp: keep the power budget over a dark sensor sample #2699 can derive cluster power-down from hardware state or DT.
  5. Clean-room commit messages, comments, and PR body (72ffe93a4279, efdeaff90785, PR description): Limited strictly to runtime observations (SRAM scan, ADT segment-ranges, and SRAM header word 0x234).
  6. Smaller point — sleep backup size (efdeaff90785): PmpData::new() now checks DT apple,sram-keep first (taking both exact offset and size from the boot loader when present), falling back to (header word 0x234, 0x68000) only when absent.
  7. Smaller point — record locator wq & online check (72ffe93a4279): apple_pmp_temps_locate() now runs on system_freezable_wq and checks apple_pmp_telemetry_online() (including the ASC run bit) before and after scanning SRAM.

Also folded in the version-free 27.2 PMP start (apple_rtkit_boot_or_wake()), registered-length CONFIRM_IOREG, probe-time SRAM data-segment validation, apple_t8132_pmp_path(), and t8132-platform-handoff across M4 firmwares.

Checks on 12aea2b043f2: asahi profile Image + modules build clean (rc=0, 0 warnings on modified files), checkpatch.pl 0 errors / 0 warnings across all 9 commits, and test-thermal-sensor.py passes (75,414 oracle rows + location checks). Keeping this PR in draft pending the remaining hardware rows (full-image J773g 27.2 boot on this head, J713 26.6.2 regression + 27.2, 25G83/26B123 suspend/resume, and other PMP Macs).

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the rework: the fan-based budget selection is what the hardware description supports. One remaining point: two new checks still select the path by the root SoC compatible, if (!of_machine_is_compatible("apple,t8132")) in t8132-platform-handoff.c and apple_t8132_pmp_path() returning of_machine_is_compatible("apple,t8132") in include/linux/soc/apple/t8132.h. The PMP node's own compatible (and the data segment the image header names, which this series already checks) identifies the device; keying on the node keeps the path working on the next SoC that ships the same PMP without another root check.

For the hardware side: on the J713 a kernel without this series boots with the PMP die sensor returning -EIO and the CPUs held at their minimum caps (912/900 MHz), so a J713 row of this head that shows the sensor reading and the clocks released is the result that matters.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Hardware row on a J713 (M4 Air, macOS 27.2 stub) for the current head 12aea2b, built exactly as the PR branch (on integration/aurora a84637d) and booted with the shared fleet cmdline.

The sensor part works: the records are found by name (temperature records at 0x69764 ... (data from 0x3d000)) and the die sensor reads 47 C.

At idle the CPUs still stay on the minimum caps. In 150 s I counted 462 sensor error -61 lines (88 logged plus 374 ratelimited). scaling_max never reached cpuinfo_max in 300 of 300 samples, and cpu0 delivered 903 MHz against a 4464 MHz OPP. This is the dark-span problem from my earlier comments: on 27.2 an idle J713 keeps all six sensors dark well past the 2 s hold. This head no longer carries the idle hold (422bc70, "ride out long dark spans while the SoC is idle"), which the previous head had and which the J713 default kernel runs today (0 -61, caps 4464000/2892000).

So for the J713 this head is not mergeable as is. It needs the idle hold back, either in this PR or as a PR on top. I can open that PR if you prefer.

Numbers and method
  • Kernel 7.3.0-bj713p33+ = 12aea2b, the J713 integrator's .config. Non-default boot entry, one-shot. The cmdline is the fleet one (no user4k=, panic=10 systemd.watchdog_sec=60). Stage 2 is the J713's configured image, unchanged.
  • Sampling starts at uptime 75 s. Each policy's scaling_max is read every 1 s for 150 s.
    • P: 912000-2868000
    • E: 900000-1476000
    • Never 4464000/2892000.
  • Clock: a dependent add chain pinned to the policy's first CPU, with scaling_min set to cpuinfo_max.
    • cpu0: 903.3 MHz
    • cpu1: 1068.2 MHz
  • Health: 0 failed units, SELinux enforcing, no oops.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Updated to d3a89232e6ae (force-pushed djdev/t8132-pmp-272):

  1. Root SoC compatible checks removed (65b7c03f62a2, d3a89232e6ae):

    • Dropped apple_t8132_pmp_path() from include/linux/soc/apple/t8132.h and keyed all four PMP pieces directly on the PMP node's own compatible (apple,t8132-pmp-v2): pmp-report.c checks supplier->of_node, apple-pmp-thermal.c checks sensors->dev->of_node, and pmp-display.h / pmp-telemetry.c check for an available apple,t8132-pmp-v2 node.
    • Replaced of_machine_is_compatible("apple,t8132") in drivers/soc/apple/t8132-platform-handoff.c with of_find_compatible_node(NULL, NULL, "apple,t8132-pmp-v2") and reused that node handle.
    • Removed the now-unused apple_t8132_firmware_path() stubs from t6030-pmp-graph-tests.c and t6030-pmp-supplier-tests.c. Local host tests (t6030-pmp-graph-tests + --mutations, t6030-pmp-supplier-tests + --mutations, test-thermal-sensor.py), checkpatch.pl (0 errors/warnings), and incremental kernel builds of all touched units all pass.
  2. J713 27.2 hardware row & dark-span idle hold:

    • Thank you for running and reporting the J713 27.2 hardware row! Glad to see the by-name sensor lookup working (temperature records at 0x69764 ... (data from 0x3d000), die 47 °C).
    • Yes please — happy to take your offer to open/stack the J713 dark-span idle-hold follow-up PR cleanly on top of #2533. Keeping #2533 in draft until CI goes green on d3a89232e6ae and the idle-hold follow-up is aligned.

Assisted-by: LLM (Gemini:4 Neon)

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Rebased cleanly onto integration/aurora (b0cc6dcd67be, including merged #2699) at f5610a143b3d (force-pushed djdev/t8132-pmp-272):

Assisted-by: LLM (Gemini:4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at f5610a1. Everything from my earlier comments is taken: the budget follows the SMC fan nodes (apple-pmp-thermal.c:104-115, 762), the power_budget parameter and the Co-Authored-By trailers are gone, the commit messages stick to runtime observations, the record locator runs on system_freezable_wq behind apple_pmp_telemetry_online(), and every piece now keys on the apple,t8132-pmp-v2 node instead of the root SoC or the OS firmware version. The J713 idle dark spans are handled on top in #2730.

New since 12aea2b:

  • 73316fd's commit message still ends with the rebase's # Conflicts: drivers/thermal/apple-pmp-thermal.c lines.
  • On a dark sample the rebased power worker skips apple_pmp_power_sample() (apple-pmp-thermal.c:253-263), so power.last_ns stops moving. Once a span is longer than APPLE_PMP_POWER_STALE_NS, apple_pmp_power_read() (apple-pmp-thermal.c:297-300) returns -EAGAIN for every power input, though rail_mw is still updated. On a fan-cooled Mac the budget is off and the guard ignores the age, so nothing gets restricted, but the rails are not "still reported" during a long idle span as the description says. Advancing a separate report timestamp on dark samples when !budget would fix that.
  • apple_rtkit_boot_or_wake() and the registered-length CONFIRM_IOREG run for every PMP in the match table (pmp.rs OF_TABLE: t8140, t6041, t6000 among them), not just the T8132. I checked the fallback: the completions are complete_all, so apple_rtkit_wake() after a 20 ms miss still finds the endpoint map. On a firmware that waits to be asked, each start now costs up to PMP_SELF_ACK_MS (pmp.rs:80) more. A self-acknowledgment that arrives after the second 20 ms wait times out, but before apple_rtkit_wake() re-arms the completion (rtkit.c:3057-3064), is lost. If word 0x48 is not the entry index on those images, an update could get a non-zero confirmation where it used to get 0.
  • Not from this PR, but this PR exposes it: the thermal driver now probes on every T8132 with the node (J604/J623/J624 included), and the cluster membership is still the default masks plus an apple,j773g check (apple-pmp-thermal.c:751-760). On a board whose CPU numbering differs, apple_pmp_add_cluster() returns -EINVAL. That fails safe, but it leaves the board without a thermal zone. Taking the members from the P and E cpufreq policies would remove the board check.

Rows still missing for this head: a full-image boot on the J773g; a J713 27.2 row on the rebased budget path; suspend and resume on 25G83 and 26B123; and a PMP start plus registry-update row on a T8140 (A18 Pro), a T6041 (M4 Pro) and a T6000 (M1 Pro) for the RTKit and CONFIRM_IOREG changes.

Assisted-by: LLM (Claude:Opus 5.5)

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 (with their own report timestamp and live rail
sum, so long dark sensor spans do not make hwmon go stale), 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. Gate this on
PmpHwConfig::self_ack_start (enabled only on T8132) and start such
SoCs with apple_rtkit_boot_or_wake(): take the firmware's own
acknowledgment if it comes, and ask as before if it doesn't. Other SoCs
keep calling rtk.wake() directly with no behavior change or extra wait.
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 gate answering
UPDATE_IOREG with that entry's registered length on
PmpHwConfig::confirm_ioreg_len (enabled only on T8132). Other SoCs keep
the existing zero payload with no behavior change, and on T8132 an index
that names no registered entry 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>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

@RyanTheTide Thanks for the thorough review! Updated and force-pushed (0b5979cdc37d0) addressing all points:

  1. Stray # Conflicts: lines (cf450974db280): stripped from commit 1's message.
  2. Fan-cooled (!budget) hwmon reporting during long dark spans (cf450974db280): added pmp_thermal.power_report_ns, updated on every valid rail read (including dark spans) and refreshed on wake in apple_pmp_thermal_complete(). apple_pmp_power_read() keeps the exact #2699 path when power_budget is true, and when !power_budget checks power_report_ns and reports the live rail_mw[0] + rail_mw[1] + rail_mw[2] sum on channel 3 instead of going stale with -EAGAIN.
  3. Non-T8132 exposure in pmp.rs (3af4242ec1d8e, d81925b0f02fd): gated both behaviors behind PmpHwConfig (self_ack_start: bool and confirm_ioreg_len: bool), enabled only on HW_CFG_T8132 (false on HW_CFG_DEFAULT, HW_CFG_T8140, HW_CFG_T6041, HW_CFG_T8142, and HW_CFG_T6050). Non-T8132 SoCs keep calling rtk.wake() directly (zero added 20 ms wait) and sending OPC_CONFIRM_IOREG << OPC_SHIFT with zero payload.
  4. RTKit late self-ACK race in apple_rtkit_boot_or_wake() (a730d6b3fa4ca): paired WRITE_ONCE(rtk->iop_power_state, new_state) in apple_rtkit_management_rx_iop_pwr_ack(), check READ_ONCE(rtk->iop_power_state) == APPLE_RTKIT_PWR_STATE_ON unconditionally after apple_rtkit_done_within(), and pass reinit_iop_ack = (ret != 0) to apple_rtkit_wake_common() so a timeout (!ret, where iop_pwr_ack_completion was never signaled) does not reinit_completion() and wipe out a racing late self-ACK.
  5. J604/J623/J624 cluster masks (apple-pmp-thermal.c:751-760): left out of scope here since open PR thermal: apple-pmp: find the T8132 clusters from the cores' nodes #2234 (thermal: apple-pmp: find the T8132 clusters from the cores' nodes) already replaces the hardcoded cluster masks from DT.

Verification on 0b5979cdc37d0:

  • scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES: 0/0/0 on all 9 commits
  • python3 tools/asahi/run-host-tests.py --only pmp: 22/22 passed
  • python3 tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-sensor.py: passed (75,414 rows)

Assisted-by: LLM (Gemini:4 Neon)

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 22, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants