Skip to content

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

Merged
DjDeveloperr merged 12 commits into
mainfrom
djdev/t8132-pmp-272
Nov 24, 2026
Merged

DjDeveloperr merged 12 commits into
mainfrom
djdev/t8132-pmp-272

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What: Enables M4 (T8132) PMP session, telemetry, and thermal support across macOS 27.2 (26B123) and 26.6.2 firmware without OS-version or board-name gates, disables the shared 8 W rail power budget on fan-cooled Macs using DT fan nodes, and derives CPU cluster membership from live CPU topology and cpufreq policies rather than hardcoded board CPU masks.
Tested: J773g M4 Mac mini (26B123) at c0b804090cc4: live apple-pmp-thermal.ko module verification on 7.3.0-ARCH-m4prod25d (policy0 CPUs 0 7 8 9 4464 MHz / policy1 CPUs 1-6 2892 MHz) probed cleanly (0 -EINVAL, apple-pmp-die 43.0 C, apple_pmp_power 38/5/47/90 mW, cooling devices cpufreq-cpu0 + cpufreq-cpu1 + aurora-g16g, guard level 8 -> 0, ready=Y, sample_count=373, governor_count=19, 0 failed units); scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES 0/0/0, run-host-tests.py --only pmp 22/22 pass, test-thermal-sensor.py 75,414/75,414 pass. Earlier 12aea2b043f2 tested two boots on J773g 26B123 with full PMP self-ack start (0 -62 timeouts, records at 0x69764..0x69a98), die thermal zone, hwmon, and GPU bring-up.
Risk: two-way door · M4 (T8132) boards (J713, J773g, J604, J623/J624); non-T8132 PMP SoCs keep self_ack_start = false and confirm_ioreg_len = false in PmpHwConfig.
Not yet: full-image boot on exact head c0b804090cc4 on J773g 26B123 (and J773g 10GbE re-check), J713 26.6.2/27.2 regression rows on this head, and suspend/resume on 25G83 and 26B123 for the SRAM data-segment backup path.

Details

Observed runtime differences on T8132 macOS 27.2 (26B123) compared to 26.6.2:

  • the ADT segment-ranges data offset and 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).

Commits in this series (10):

  1. thermal: apple-pmp: no shared rail power budget on fan-cooled Macs. Inspects available apple,smc-hwmon nodes for available fan-* children to disable the shared 8 W CPU/GPU rail budget on fan-cooled Macs while keeping it on fanless Airs. Tracks power_report_ns so hwmon rails continue reporting during long dark spans when !power_budget.
  2. soc: apple: pmp: find the T8132 temperature records by name. Checks the 26.6.2 offsets first, then scans SRAM from header word 0x234 on system_freezable_wq behind apple_pmp_telemetry_online().
  3. soc: apple: pmp: keep the T8132 firmware's own data segment over a sleep. Prefers DT apple,sram-keep, falling back to header word 0x234 with 0x68000 size.
  4. soc: apple: rtkit: start a firmware that powers itself on without asking it. Adds apple_rtkit_boot_or_wake() with a bounded 20 ms window before falling back to apple_rtkit_wake() without losing a racing late self-ACK.
  5. soc: apple: pmp: take the firmware's own IOP power acknowledgment at start. Enabled only on HW_CFG_T8132 (self_ack_start: true).
  6. soc: apple: pmp: confirm a registry update with the entry's registered length. Enabled only on HW_CFG_T8132 (confirm_ioreg_len: true), reading word 0x48 of each entry's REGISTER_IOREG buffer.
  7. soc: apple: pmp: refuse a T8132 image whose header names no data segment. Fails at probe instead of first sleep.
  8. soc: apple: t8132: key the PMP session's pieces on the PMP node compatible. Replaces the 26.6.2 version gate for PMP vote bridge, telemetry, thermal, and report readiness with apple,t8132-pmp-v2.
  9. soc: apple: t8132-platform-handoff: key platform handoff on the PMP node compatible. Applies SoC PMGR ownership and missing memory nodes (MCC, PMC, CLPC) whenever apple,t8132-pmp-v2 is present.
  10. thermal: apple-pmp: derive CPU clusters from topology and cpufreq. Drops the hardcoded CPU masks and apple,j773g board check. Discovers the two cpufreq policies from live topology, verifies they partition every possible CPU with uniform DT capacity-dmips-mhz per cluster and consistent capacity and cpuinfo.max_freq ordering, and orders P before E (PP0b / PPbb). Thanks to @techmore for reporting the J773g 10GbE -22 layout failure and @RyanTheTide for review.
Evidence

At head c0b804090cc4:

  • Static checks: scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES -g c0b804090cc4 -> 0 errors, 0 warnings, 0 checks.
  • Host tests:
    • python3 tools/asahi/run-host-tests.py --only pmp -> 22/22 passed (18 s).
    • python3 tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-sensor.py -> passed (75,414 rows, production/oracle checks passed).
  • Arm64 build (W=1, LLVM=1): drivers/thermal/apple-pmp-thermal.ko built cleanly with 0 warnings, vermagic 7.3.0-ARCH-m4prod25d SMP preempt mod_unload aarch64, all undefined symbols resolved against 7.3.0-ARCH-m4prod25d.
  • Live J773g M4 Mac mini (26B123, 7.3.0-ARCH-m4prod25d) module load of c0b804090cc4:
    • Live cpufreq layout: policy0: related_cpus=0 7 8 9 max_freq=4464000, policy1: related_cpus=1 2 3 4 5 6 max_freq=2892000.
    • dmesg: probe of apple-pmp-thermal.1.auto with driver apple-pmp-thermal returned 0 after 182 usecs (rail power reported, no power budget), 0 setup failed: -22, recovery stepped cleanly level=8 -> 0 (reason=governor hard=0 level=0 qos_error=0), GPU cooling S1 -> S10.
    • Parameters: ready=Y, sample_count=373, governor_count=19.
    • Thermal zone: thermal_zone0 (apple-pmp-die) = 43000 (43.0 C).
    • Cooling devices: cooling_device0 (cpufreq-cpu0, max=19), cooling_device1 (cpufreq-cpu1, max=7), cooling_device2 (aurora-g16g, max=8).
    • Hwmon apple_pmp_power: PP0b=38000, PPbb=5000, PP1b=47000, sum=90000; apple_pmp: temp1=47000, temp2=44250, temp3=44750, temp5=47000.
    • Restored stock apple_pmp_thermal after test (ready=Y, 0 failed units).

@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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
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 <[email protected]>
…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 <[email protected]>
…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 <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

I checked current main at d6656a21a059 and this PR's unchanged head 0b5979cdc37d. The inherited J773g-specific CPU mask is still present in the thermal setup. The earlier J773g 10GbE row at this head reported setup error -22 and no die thermal zone when the actual cpufreq policy masks differed. That leaves the newly enabled J773g path with an unresolved setup failure.

Please derive cluster membership from the actual CPU topology and cpufreq policies so both layouts can use normal thermal setup. A J713 pass covers the Air path. The J773g failure still needs a verified correction before this PR can land.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) area:power Area from CODEOWNERS (bot) area:rust Area from CODEOWNERS (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
Logical CPU numbering depends on the boot CPU and device-tree order, so
hardcoded CPU bitmasks fail on boards or boot paths whose numbering
differs. On J773g 10GbE booted through aura, the P cluster is CPUs 0,
7-9 and the E cluster is CPUs 1-6, while the J773g override expected P
on 0, 3-5 and E on 1-2, 6-9, causing apple_pmp_add_cluster() to fail
setup with -EINVAL and leave the system without the apple-pmp-die
thermal zone.

Drop the board-specific J773g check and hardcoded bitmasks. Discover
the two CPU clusters directly from the live cpufreq policies, verify
they partition every possible CPU with uniform DT capacity-dmips-mhz
per cluster and consistent capacity and max-frequency ordering, and
assign the P cluster to index 0 (PP0b) and the E cluster to index 1
(PPbb). Fail closed with -EPROBE_DEFER while policies are still coming
up or -EINVAL/-ENODEV on any topology mismatch.

Signed-off-by: Diljit Singh <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 24, 2026 19:06
@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at c606e96d: not ready yet

Check Detail
CI at head ok 9 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA c606e96d, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · M4 (T8132) boards (J713, J773g, J604, J623/J624); non-T8132 PMP SoCs keep selfackstart = false and confirmioreglen = false in PmpHwConfig.

Areas: area:gpu, area:platform, area:power, area:rust

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

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

@techmore @RyanTheTide Pushed c0b804090cc4 (thermal: apple-pmp: derive CPU clusters from topology and cpufreq) on top of 0b5979cdc37d to fix the -22 cluster setup failure.

Fix

  • Dropped the hardcoded CPU cluster bitmasks and the apple,j773g board check in drivers/thermal/apple-pmp-thermal.c.
  • Added apple_pmp_discover_clusters() to discover the two cpufreq policies from live topology, verify they partition every possible CPU with uniform DT capacity-dmips-mhz per cluster and consistent capacity and cpuinfo.max_freq ordering, and order P before E (PP0b at index 0, PPbb at index 1). Returns -EPROBE_DEFER while policies are still coming up and -EINVAL/-ENODEV on any topology mismatch.

Verification at c0b804090cc4

  • Static & host checks:
    • scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES -g c0b804090cc4: 0 errors, 0 warnings, 0 checks.
    • 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).
  • Arm64 module build (LLVM=1 W=1): drivers/thermal/apple-pmp-thermal.ko compiled with 0 warnings and all symbols resolved against 7.3.0-ARCH-m4prod25d.
  • Live J773g (M4 Mac mini, 26B123, 7.3.0-ARCH-m4prod25d) verification:
    • Live cpufreq layout on our J773g matches the reported layout: policy0 related_cpus=0 7 8 9 (4464000 kHz), policy1 related_cpus=1 2 3 4 5 6 (2892000 kHz).
    • Unloaded stock apple_pmp_thermal and loaded the c0b804090cc4 module: probed cleanly (probe of apple-pmp-thermal.1.auto with driver apple-pmp-thermal returned 0 after 182 usecs, rail power reported, no power budget, no setup failed: -22), guard recovered level=8 -> 0 (qos_error=0), ready=Y, sample_count=373, governor_count=19.
    • thermal_zone0 (apple-pmp-die) read 43000 (43.0 C); cooling devices registered in P-then-E order (cpufreq-cpu0 max 19, cpufreq-cpu1 max 7, aurora-g16g max 8); apple_pmp_power hwmon read PP0b=38000, PPbb=5000, PP1b=47000, sum=90000.
    • Stock module restored cleanly afterwards (0 failed units).

@techmore A quick re-check on your J773g 10GbE unit at c0b804090cc4 would be much appreciated when you have a moment.

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at c0b80409: no blocking findings. CI is green at this head (all 12 checks). It cannot merge yet, though: after #2676 landed at 19:07 UTC, the branch conflicts with main.

Before merge

  1. Rebase onto main. drivers/soc/apple/pmp-telemetry.c and include/linux/soc/apple/pmp-display.h conflict with 45b05cd ("detect retained T8132 PMP bridge from the device tree"). That commit keys the same check on the pmp node and also requires apple,tunable-soc-device. To resolve it, keep main's apple_pmp_t8132_retained_board() in both places and drop this PR's copy. Everything else merges cleanly against 0c4e19dfdde7 (I checked with git merge-tree), including the thermal: apple-pmp: stop the power reader at shutdown #2455 shutdown change in apple-pmp-thermal.c.
  2. Those conflicts are in files this PR changes, so re-run the J773g row on the rebased head. A full-image boot also closes the first "Not yet" item.
What I checked
  • c0b80409, cluster discovery:
    • apple_pmp_discover_clusters() takes one reference per policy and drops them all on every error path. A failure after discovery goes through apple_pmp_thermal_cleanup(), which puts both.
    • A possible CPU that no policy covers defers. A CPU in two policies, or a third policy, returns -EINVAL. P/E order requires capacity and max frequency to agree.
    • t8132.dtsi gives all ten cores capacity-dmips-mhz (754 E, 1024 P), so J713, J773g, J604 and J623/J624 all have what the check reads.
    • Both the old J773g numbering (P on 0, 3-5) and the one techmore reported (P on 0, 7-9) now give P at index 0 (PP0b) and E at index 1 (PPbb). The thermal setup has no board or SoC check left.
  • J773g row at this head (comment): on the same P 0, 7-9 layout that failed, probe returns 0 with no -22. The apple-pmp-die zone registers, cpufreq-cpu0, cpufreq-cpu1 and aurora-g16g cooling devices register, and the rails are reported.
  • Rest of the diff against main:
    • The self-acknowledged RTKit start and the registered-length CONFIRM_IOREG apply only on T8132 (self_ack_start and confirm_ioreg_len are false everywhere else). Existing apple_rtkit_wake() callers behave as before.
    • The record search stays inside the SRAM mapping and runs only while the PMP is online.
    • The platform handoff puts every node reference on every exit.
  • Commits and text: all 10 commits carry the human author and one human Signed-off-by, with no tool trailers in commits, title or body. The PR text has What, Tested, Risk and Not yet.

Resolve conflicts with merged #2676 and #1971:
- Keep main's apple_pmp_t8132_retained_board() check (including
  apple,tunable-soc-device) in include/linux/soc/apple/pmp-display.h.
- Keep #1971's unbudgeted fan-cooled power policy (apple_pmp_unbudgeted,
  apple_pmp_power_init_unbudgeted, apple_pmp_power_dark) in
  drivers/thermal/apple-pmp-thermal.c alongside this branch's
  topology/cpufreq cluster discovery.
- Keep this branch's self-described 27.2 temperature-record lookup in
  drivers/soc/apple/pmp-telemetry.c.

Signed-off-by: Diljit Singh <[email protected]>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) ci-failing A check failed at the PR head (bot) labels Nov 24, 2026
@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 24, 2026
@DjDeveloperr
DjDeveloperr merged commit c763cd8 into main Nov 24, 2026
10 checks passed
@DjDeveloperr
DjDeveloperr deleted the djdev/t8132-pmp-272 branch November 24, 2026 20:28
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) area:platform Area from CODEOWNERS (bot) area:power Area from CODEOWNERS (bot) area:rust Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants