Repository navigation
soc: apple: clpc: take High Power mode from the device tree - #2784
Conversation
The 16-inch MacBook Pro with M4 Pro (J616s) has High Power mode on macOS. With it on, the SMC lets the fans run to their maximum under a sustained load: under a 300 s CPU and GPU load on macOS 27 the fans peak at about 3800 rpm in Automatic and about 5850 rpm in High Power, at the same CPU and GPU clocks, for 4-5% more sustained throughput. Linux has no way to ask for it on this Mac: the CLPC registers its platform profile only where it has a low-power ceiling, the J616s CLPC node has no link to the SMC, and the only machine that gets the High Power record is the J714s, named by compatible in the T6050 match data. Whether a Mac has High Power mode is a property of the board (the chassis and its cooling), not of the SoC. Describe it in the board device tree: a boolean "apple,high-power-mode" on the CLPC node, set on the J616s and the J714s and documented in the binding. The driver sends the record when the property is present and the node links an SMC. - link the T604x CLPC to the SMC, and say in the binding that the SMC also receives High Power mode; - register the platform profile on a machine that has High Power mode but no low-power ceiling, named "apple-smc", so that userspace keeps its own low-power CPU budget there (aurora-power-budget steps aside only for "apple-clpc"); - print the High Power state in debugfs outside the low-power block; - clpc-high-power-cleanup-tests: look for the devm_platform_profile_register() call itself, since the profile name is no longer a literal. The J714s entry in the T6050 match data stays as a fallback for a DTB without the property: the device tree on the ESP can lag the kernel, and dropping the entry would turn High Power mode off on a J714s that boots such a DTB. It can go once released DTBs carry the property. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
With a profile that has High Power but no low-power ceiling (J616s), choosing low-power sets clpc->low_power, and the sample loop then queues its 4 ms sample as non-deferrable. apple_clpc_profile_limit() returns at once when there is no low-power ceiling, so those ~250 wakeups/s do nothing and cost idle power in the mode users pick for battery. Sample on time in low power only when there is a low-power ceiling to keep. clpc-gpu-demand-tests covers it: idle in low power with no ceiling samples deferrably, with a ceiling on time, and balanced deferrably again. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
There was a problem hiding this comment.
Pre-PR checklist review (§1–§6) at ef719df79394dc2987ad40f193a2b2b2e366c85e: APPROVE (hold merge until in-progress dt-checks finishes green).
Prior #2655 blockers — verified fixed
- §4 (Attribution): Both commits (
68986f0eb553,ef719df79394) carry human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and humanSigned-off-by:only, with zeroCo-Authored-By:or AI trailers.Assisted-by:is disclosed in the PR body. - §1 (No model gating & chicken-and-egg): High Power mode is now driven by the board DT boolean
apple,high-power-mode(set ont6040-j616s.dtsandt6050-j714s.dts, documented inDocumentation/devicetree/bindings/power/apple,pmc.yaml), while.high_power_machine = "apple,j714s"is properly retained as a fallback inapple_clpc_hw_t6050so J714s machines booting an older ESP/Stage-2 DTB keep High Power mode.
Code & cross-SoC verification
drivers/soc/apple/clpc.c:- Probe ordering is sound:
devm_add_action_or_reset(dev, apple_clpc_stop, clpc)runs beforeof_parse_phandle(dev->of_node, "apple,smc", 0)anddevm_platform_profile_register(), soapple_clpc_stop()cleanly clears High Power mode (zETM) and callsof_node_put(clpc->smc_np)after the profile is unregistered (verified byclpc-high-power-cleanup-tests.py). - Verified T6041 (M4 Max) impact of adding
apple,smc = <&smc>int604x.dtsi: althoughapple_clpc_hw_t6041haslow_power_khz = 2808000(soclpc->smc_npis parsed),low_power_mw == 0and neither M4 Max board setsapple,high-power-mode, soapple_clpc_smc()is never called andsmc_npis released inapple_clpc_stop(). Non-J616s T6040 boards never parsesmc_npor register a profile. - Naming the ceiling-less High Power profile
"apple-smc"preserves userspaceaurora-power-budgeton J616s, and gating non-deferrable low-power sampling onclpc->hw->low_power_khz && READ_ONCE(clpc->low_power)avoids idle wakeups on battery (covered bycheck_low_power()inclpc-gpu-demand-tests.py).
- Probe ordering is sound:
- §2 / §3 / §5 / §6: Clean. J616s soak and idle numbers from
#2140/#2655cover the exact J616s runtime path (0failed units,0AVC denials,0kernel errors);source,rust-build,host-tests,kunit, and all threeDWC3/ATCCI jobs are SUCCESS.
Non-blocking notes
- Hold merge until
dt-checks(currentlyIN_PROGRESS) turns green. - Minor PR-body wording nit:
git diff 42029434 <head> -- <the 7 files>is not literally empty since#2784intentionally kept the.high_power_machinefallback inclpc.cand updated thet604x.dtsicomment (the J616s runtime path itself is identical). - Please still collect the J714s DT-path boot row before retiring
.high_power_machinein a follow-up PR.
Assisted-by: LLM (Gemini 4 Neon)
|
Merge-train adversarial review (MERGETRAIN-LINUX3) at ef719df: NO BLOCKERS. dt-checks and host-tests are green.
|
|
J616s (MacBook Pro 16" M4 Pro) rows with this PR merged together with #1906 and #2549 on integration/aurora a463112 (fleet78 config). The J616s Device Tree carried only this PR's two CLPC properties on top of production (one-shot Stage 2 trial). Conflict with #1906. The two PRs conflict in Rows (one boot, P-core probe = one busy thread on cpu9 for 8 s):
Resolution used for the row (combined diff of the merge, clpc.c) and the host-test change@@@ -105,13 -105,12 +105,13 @@@ enum apple_clpc_rail
* @idle_on_time: sample every period even with no vote held, instead of
* from a deferrable timer
* @low_power_khz: CPU frequency ceiling of the low-power platform profile,
- * taken up to the next table frequency; 0 for no platform profile
+ * taken up to the next table frequency, for a node without
+ * apple,low-power-frequency-max-mhz; 0 for no platform profile
* @low_power_mw: package power (the SMC's PHPC key) the low-power profile
* holds the CPU clusters to; 0 for none
- * @high_power_machine: the machine compatible on which the performance
- * profile tells the SMC that macOS's High Power mode is on (the zETM
- * record below); NULL for none
+ * @high_power_machine: the machine compatible that had High Power mode from
+ * this table before the board DT carried "apple,high-power-mode"; kept so
+ * that a DTB without the property keeps High Power mode. NULL for none
*/
struct apple_clpc_hw {
unsigned int rail[APPLE_CLPC_RAILS];
@@@ -993,9 -990,15 +993,15 @@@ static void apple_clpc_sample(struct ap
apple_clpc_profile_limit(clpc);
- /* Sample on time while graphics is powered, to see it power off, and in low power. */
+ /*
+ * Sample on time while graphics is powered, to see it power off, and in
+ * low power where it has a ceiling to keep. A profile with no low-power
+ * ceiling (High Power only) has nothing to do there, so it stays
+ * deferrable.
+ */
apple_clpc_queue(clpc, !apple_clpc_floor(clpc, state) && !clpc->gpu_on &&
- !clpc->ane_qos_khz && !READ_ONCE(clpc->low_power));
+ !clpc->ane_qos_khz &&
- !(clpc->hw->low_power_khz && READ_ONCE(clpc->low_power)));
++ !(clpc->low_power_khz && READ_ONCE(clpc->low_power)));
}
static void apple_clpc_run(struct apple_clpc *clpc)
@@@ -1363,7 -1366,7 +1369,8 @@@ static int apple_clpc_probe(struct plat
struct device_node *gpu = NULL;
struct apple_clpc *clpc;
unsigned int rail, i;
+ bool high_power;
+ u32 mhz;
int ret;
clpc = devm_kzalloc(dev, sizeof(*clpc), GFP_KERNEL);
@@@ -1501,29 -1504,40 +1508,49 @@@
clpc->profile = PLATFORM_PROFILE_BALANCED;
clpc->power_next = jiffies;
+ /*
+ * The boot loader copies the ADT's Low Power mode CPU ceiling
+ * (pmgr/clpc cpu-low-power-frequency-max) into the node. Without it,
+ * a SoC's own value applies where it has one.
+ */
+ if (!of_property_read_u32(dev->of_node, "apple,low-power-frequency-max-mhz", &mhz))
+ clpc->low_power_khz = mhz * 1000;
+ else
+ clpc->low_power_khz = clpc->hw->low_power_khz;
- if (clpc->low_power_khz && IS_REACHABLE(CONFIG_ACPI_PLATFORM_PROFILE)) {
- struct device *ppdev;
-
+ /*
+ * The board DT says whether the machine has High Power mode: then the
+ * performance profile tells the SMC that it is on (the zETM record).
+ * A machine with High Power mode and no low-power ceiling still gets
+ * the platform profile, named "apple-smc" so that userspace keeps its
+ * own low-power CPU budget.
+ */
+ high_power = of_property_read_bool(dev->of_node, "apple,high-power-mode");
+ /*
+ * A DTB from before the property (the ESP copy can lag the kernel)
+ * keeps High Power mode where this table already gave it.
+ */
+ if (!high_power && clpc->hw->high_power_machine)
+ high_power = of_machine_is_compatible(clpc->hw->high_power_machine);
- if ((clpc->hw->low_power_khz || high_power) && IS_REACHABLE(CONFIG_ACPI_PLATFORM_PROFILE)) {
++ if ((clpc->low_power_khz || high_power) && IS_REACHABLE(CONFIG_ACPI_PLATFORM_PROFILE)) {
/* The SMC is optional: without it the low-power profile has only its ceiling. */
clpc->smc_np = of_parse_phandle(dev->of_node, "apple,smc", 0);
- clpc->high_power = clpc->smc_np && clpc->hw->high_power_machine &&
- of_machine_is_compatible(clpc->hw->high_power_machine);
- if (!clpc->policy_nb_added) {
+ clpc->high_power = clpc->smc_np && high_power;
+ }
+ /* High Power mode alone needs the SMC; without it there is no profile. */
- if ((clpc->hw->low_power_khz || clpc->high_power) && IS_REACHABLE(CONFIG_ACPI_PLATFORM_PROFILE)) {
++ if ((clpc->low_power_khz || clpc->high_power) && IS_REACHABLE(CONFIG_ACPI_PLATFORM_PROFILE)) {
+ struct device *ppdev;
+
- if (clpc->hw->low_power_khz && !clpc->policy_nb_added) {
++ if (clpc->low_power_khz && !clpc->policy_nb_added) {
clpc->policy_nb.notifier_call = apple_clpc_policy_notify;
clpc->policy_nb_added = !cpufreq_register_notifier(&clpc->policy_nb,
CPUFREQ_POLICY_NOTIFIER);
}
- ppdev = devm_platform_profile_register(dev, "apple-clpc", clpc,
- &apple_clpc_profile_ops);
+ /*
+ * "apple-clpc" budgets the low-power profile itself; "apple-smc"
+ * only carries High Power mode, and userspace keeps the CPU budget.
+ */
- ppdev = devm_platform_profile_register(dev, clpc->hw->low_power_khz ? "apple-clpc" :
++ ppdev = devm_platform_profile_register(dev, clpc->low_power_khz ? "apple-clpc" :
+ "apple-smc", clpc, &apple_clpc_profile_ops);
if (IS_ERR(ppdev))
dev_warn(dev, "no platform profile: %pe\n", ppdev);
}diff --git a/tools/asahi/clpc-gpu-demand-tests.py b/tools/asahi/clpc-gpu-demand-tests.py
index ff36eb19c162c..93174c9880039 100644
--- a/tools/asahi/clpc-gpu-demand-tests.py
+++ b/tools/asahi/clpc-gpu-demand-tests.py
@@ -112,6 +112,7 @@ struct apple_clpc {
unsigned int ane_qos_khz;
unsigned long ane_until;
bool low_power;
+ unsigned int low_power_khz;
};
static unsigned long jiffies;
static u64 ktime_get_mono_fast_ns(void) { return jiffies * 1000000ull; }
@@ -277,14 +278,15 @@ static void check_t8140_dense(void) {
}
// Low power samples on time only where it has a CPU ceiling to keep
-// (low_power_khz); a High Power-only profile stays deferrable when idle.
+// (clpc->low_power_khz: the DT ceiling, else the table one); a High Power-only
+// profile stays deferrable when idle.
static void check_low_power(void) {
struct apple_clpc_gpu gpu={0};
struct apple_clpc_hw lp=apple_clpc_hw_t6040;
struct apple_clpc c={.hw=&lp,.agent=1,.mask=3,.gpu=&gpu,.low_power=true};
read_error=vote_error=0; pmgr_status=0xf0; published=~0u;
jiffies=3000; apple_clpc_sample(&c); assert(published==0 && queued_idle);
- lp.low_power_khz=2808000;
+ c.low_power_khz=2808000;
jiffies=3004; apple_clpc_sample(&c); assert(published==0 && !queued_idle);
c.low_power=false;
jiffies=3008; apple_clpc_sample(&c); assert(published==0 && queued_idle);Assisted-by: LLM (Claude:Opus 5.5) |
…r-2784-20261123 soc: apple: clpc: Take the Low Power mode ceiling from the DT (rebased on #2784)
Replaces #2655 (and before it #2140). Same change, rebuilt as two clean commits on integration/aurora (b0cc6dc). Each commit carries only human identity and a
Signed-off-by:; the old branch had aCo-Authored-By:trailer and no sign-off in 8e2766c, and history is never force-pushed, so the fix is a new branch.Problem
The 16-inch M4 Pro (J616s) has High Power mode on macOS, and Linux has no way to ask for it there. The CLPC registers its platform profile only where it has a low-power ceiling (the M4 Max), and the J616s CLPC node has no link to the SMC.
Change
apple,high-power-modeon the CLPC node, set int6040-j616s.dtsandt6050-j714s.dts, documented in the binding..high_power_machine = "apple,j714s"remains in the T6050 match data, so a J714s booting an older ESP/Stage 2 DTB without the property keeps High Power mode. It can be dropped in a later PR once released DTBs carry the property.apple-smc, so userspace keeps its own low-power CPU budget.t604x.dtsilinks the CLPC to the SMC (apple,smc = <&smc>). Its comment no longer names one board: boards opt in withapple,high-power-mode.t6041-j614c.dts,t6041-j616c.dts) are not part of this PR. They keep theapple-clpclow-power profile as before; High Power for them is a follow-up once someone has the macOS row for those chassis.Testing
git diff 42029434 <head> -- <the 7 files>is empty), so the J616s rows from soc: apple: clpc: J616s: tell the SMC about High Power mode #2140/soc: apple: clpc: J616s: tell the SMC about High Power mode #2655 apply as they are: profileapple-smc; performance sends the record and balanced clears it; 300 s CPU + GPU soak fan peak 3564/3804 -> 5431/5946 rpm (macOS 3796 -> 5855), CPU +3.9 % (macOS +4.2 %); low-power idle equals balanced (CLPC samples/s 193.4 / 196.2 / 177.0). 0 failed units, 0 AVC, 0 kernel errors.clpc.o,t6040-j616s.dtb).tools/asahi/clpc-gpu-demand-tests.pyandtools/asahi/clpc-high-power-cleanup-tests.pypass, negative controls included.Still to run
Assisted-by: LLM (Claude:Opus 5.5)