Repository navigation
M4 PMP: fan-based rail budget and self-described 27.2 PMP path - #2533
Conversation
|
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 Still capped: with the records found, an idle J713 keeps all six sensors invalid much longer than the 2 s 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 Not covered by this row: the sleep-segment commit, because I ran no suspend. Numbers and method
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) |
|
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. |
|
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 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). |
|
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)):
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) |
|
Blockers: 5.
|
422bc70 to
12aea2b
Compare
|
Rebased onto
Also folded in the version-free 27.2 PMP start ( Checks on Assisted-by: LLM (Gemini:4 Neon) |
|
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, 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. |
|
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 ( At idle the CPUs still stay on the minimum caps. In 150 s I counted 462 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
Assisted-by: LLM (Claude:Opus 5.5) |
12aea2b to
d3a8923
Compare
|
Updated to
Assisted-by: LLM (Gemini:4 Neon) |
d3a8923 to
f5610a1
Compare
|
Rebased cleanly onto
Assisted-by: LLM (Gemini:4 Neon) |
|
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 New since 12aea2b:
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]>
|
I checked current 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. |
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]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
@techmore @RyanTheTide Pushed Fix
Verification at
|
|
Verdict at Before merge
What I checked
|
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]>
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: liveapple-pmp-thermal.komodule verification on7.3.0-ARCH-m4prod25d(policy0CPUs0 7 8 94464 MHz /policy1CPUs1-62892 MHz) probed cleanly (0-EINVAL,apple-pmp-die43.0 C,apple_pmp_power38/5/47/90 mW, cooling devicescpufreq-cpu0+cpufreq-cpu1+aurora-g16g, guard level 8 -> 0,ready=Y,sample_count=373,governor_count=19,0failed units);scripts/checkpatch.pl --strict --ignore FILE_PATH_CHANGES0/0/0,run-host-tests.py --only pmp22/22 pass,test-thermal-sensor.py75,414/75,414 pass. Earlier12aea2b043f2tested two boots on J773g 26B123 with full PMP self-ack start (0-62timeouts, records at0x69764..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 = falseandconfirm_ioreg_len = falseinPmpHwConfig.Not yet: full-image boot on exact head
c0b804090cc4on 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:
segment-rangesdata offset and SRAM RTKit header word at0x234move from0x3c000to0x3d000, and runtime SRAM scans locate the six named die temperature records0x1140bytes later (0x69764..0x69a98, same0xa4stride);-62);UPDATE_IOREGmessages with each entry's registered length (8).Commits in this series (10):
apple,smc-hwmonnodes for availablefan-*children to disable the shared 8 W CPU/GPU rail budget on fan-cooled Macs while keeping it on fanless Airs. Trackspower_report_nsso hwmon rails continue reporting during long dark spans when!power_budget.0x234onsystem_freezable_wqbehindapple_pmp_telemetry_online().apple,sram-keep, falling back to header word0x234with0x68000size.apple_rtkit_boot_or_wake()with a bounded20 mswindow before falling back toapple_rtkit_wake()without losing a racing late self-ACK.HW_CFG_T8132(self_ack_start: true).HW_CFG_T8132(confirm_ioreg_len: true), reading word0x48of each entry'sREGISTER_IOREGbuffer.26.6.2version gate for PMP vote bridge, telemetry, thermal, and report readiness withapple,t8132-pmp-v2.apple,t8132-pmp-v2is present.apple,j773gboard check. Discovers the two cpufreq policies from live topology, verifies they partition every possible CPU with uniform DTcapacity-dmips-mhzper cluster and consistent capacity andcpuinfo.max_freqordering, and orders P before E (PP0b/PPbb). Thanks to @techmore for reporting the J773g 10GbE-22layout failure and @RyanTheTide for review.Evidence
At head
c0b804090cc4: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(18 s).python3 tools/testing/selftests/drivers/gpu/asahi-m4/test-thermal-sensor.py-> passed (75,414rows, production/oracle checks passed).W=1,LLVM=1):drivers/thermal/apple-pmp-thermal.kobuilt cleanly with 0 warnings, vermagic7.3.0-ARCH-m4prod25d SMP preempt mod_unload aarch64, all undefined symbols resolved against7.3.0-ARCH-m4prod25d.26B123,7.3.0-ARCH-m4prod25d) module load ofc0b804090cc4: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), 0setup failed: -22, recovery stepped cleanlylevel=8 -> 0(reason=governor hard=0 level=0 qos_error=0), GPU coolingS1 -> S10.ready=Y,sample_count=373,governor_count=19.thermal_zone0(apple-pmp-die) =43000(43.0 C).cooling_device0(cpufreq-cpu0,max=19),cooling_device1(cpufreq-cpu1,max=7),cooling_device2(aurora-g16g,max=8).apple_pmp_power:PP0b=38000,PPbb=5000,PP1b=47000,sum=90000;apple_pmp:temp1=47000,temp2=44250,temp3=44750,temp5=47000.apple_pmp_thermalafter test (ready=Y,0failed units).