Skip to content

soc: apple: clpc: take High Power mode from the device tree - #2784

Merged
RyanTheTide merged 2 commits into
integration/aurorafrom
prfix/clpc-high-power-r3-20261122
Nov 22, 2026
Merged

RyanTheTide merged 2 commits into
integration/aurorafrom
prfix/clpc-high-power-r3-20261122

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

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 a Co-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

  • The board device tree says which Macs have High Power mode: a boolean apple,high-power-mode on the CLPC node, set in t6040-j616s.dts and t6050-j714s.dts, documented in the binding.
  • The J714s fallback stays. .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.
  • On a machine with High Power mode and no low-power ceiling, the platform profile still registers, named apple-smc, so userspace keeps its own low-power CPU budget.
  • Low power samples on time only where it has a CPU ceiling to keep; a High Power-only profile stays deferrable at idle.
  • t604x.dtsi links the CLPC to the SMC (apple,smc = <&smc>). Its comment no longer names one board: boards opt in with apple,high-power-mode.
  • M4 Max boards (t6041-j614c.dts, t6041-j616c.dts) are not part of this PR. They keep the apple-clpc low-power profile as before; High Power for them is a follow-up once someone has the macOS row for those chassis.

Testing

Still to run

  • J714s (M5 Pro) row for the DT path. The fallback keeps the current behaviour on that Mac until we have it.

Assisted-by: LLM (Claude:Opus 5.5)

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>

@DjDeveloperr DjDeveloperr left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-PR checklist review (§1–§6) at ef719df79394dc2987ad40f193a2b2b2e366c85e: APPROVE (hold merge until in-progress dt-checks finishes green).

Prior #2655 blockers — verified fixed

  1. §4 (Attribution): Both commits (68986f0eb553, ef719df79394) carry human author/committer (Ryan Murray <ryan@aurorasilicon.org>) and human Signed-off-by: only, with zero Co-Authored-By: or AI trailers. Assisted-by: is disclosed in the PR body.
  2. §1 (No model gating & chicken-and-egg): High Power mode is now driven by the board DT boolean apple,high-power-mode (set on t6040-j616s.dts and t6050-j714s.dts, documented in Documentation/devicetree/bindings/power/apple,pmc.yaml), while .high_power_machine = "apple,j714s" is properly retained as a fallback in apple_clpc_hw_t6050 so 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 before of_parse_phandle(dev->of_node, "apple,smc", 0) and devm_platform_profile_register(), so apple_clpc_stop() cleanly clears High Power mode (zETM) and calls of_node_put(clpc->smc_np) after the profile is unregistered (verified by clpc-high-power-cleanup-tests.py).
    • Verified T6041 (M4 Max) impact of adding apple,smc = <&smc> in t604x.dtsi: although apple_clpc_hw_t6041 has low_power_khz = 2808000 (so clpc->smc_np is parsed), low_power_mw == 0 and neither M4 Max board sets apple,high-power-mode, so apple_clpc_smc() is never called and smc_np is released in apple_clpc_stop(). Non-J616s T6040 boards never parse smc_np or register a profile.
    • Naming the ceiling-less High Power profile "apple-smc" preserves userspace aurora-power-budget on J616s, and gating non-deferrable low-power sampling on clpc->hw->low_power_khz && READ_ONCE(clpc->low_power) avoids idle wakeups on battery (covered by check_low_power() in clpc-gpu-demand-tests.py).
  • §2 / §3 / §5 / §6: Clean. J616s soak and idle numbers from #2140/#2655 cover the exact J616s runtime path (0 failed units, 0 AVC denials, 0 kernel errors); source, rust-build, host-tests, kunit, and all three DWC3/ATC CI jobs are SUCCESS.

Non-blocking notes

  • Hold merge until dt-checks (currently IN_PROGRESS) turns green.
  • Minor PR-body wording nit: git diff 42029434 <head> -- <the 7 files> is not literally empty since #2784 intentionally kept the .high_power_machine fallback in clpc.c and updated the t604x.dtsi comment (the J616s runtime path itself is identical).
  • Please still collect the J714s DT-path boot row before retiring .high_power_machine in a follow-up PR.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train adversarial review (MERGETRAIN-LINUX3) at ef719df: NO BLOCKERS. dt-checks and host-tests are green.

  • The DT boolean is the primary source. The apple,j714s entry is the existing legacy fallback for older DTBs, so this adds no new board gate. On the J614s nothing changes (no property means no profile). The M4 Max is also unchanged: the SMC read is still gated on low_power_mw.
  • Nit: the body says the diff against soc: apple: clpc: J616s: tell the SMC about High Power mode #2655's 4202943 is empty for the 7 files. It is not: there are 16 lines in clpc.c (the high_power_machine fallback) plus one dtsi comment line. I checked that this delta doesn't touch the J616s path (apple_clpc_hw_t6040 has no high_power_machine), so the J616s rows from soc: apple: clpc: J616s: tell the SMC about High Power mode #2655 still apply.
  • Still to run: the J714s on a DTB that carries apple,high-power-mode. That DT path hasn't run yet; old DTBs take the fallback.

@RyanTheTide
RyanTheTide merged commit 2b67c4e into integration/aurora Nov 22, 2026
8 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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 drivers/soc/apple/clpc.c, and whichever lands second needs a rebase. The textual conflict is in apple_clpc_probe(). There is also one line git merges without a conflict that is still wrong after #1906: the idle-sampling call !(clpc->hw->low_power_khz && READ_ONCE(clpc->low_power)). After #1906 the low-power ceiling can come from the DT alone (clpc->low_power_khz). That is exactly the J616s case: its table value is 0 and the loader writes 2808 MHz. So everywhere this PR reads clpc->hw->low_power_khz (4 places), it has to read clpc->low_power_khz. Otherwise a DT-only ceiling registers as apple-smc, never applies its ceiling and samples deferrably in low-power. tools/asahi/clpc-gpu-demand-tests.py also needs the new field in its model struct. With both changes, the two host tests pass.

Rows (one boot, P-core probe = one busy thread on cpu9 for 8 s):

  • Class: platform-profile-0, name apple-clpc, choices low-power balanced performance.
  • Class performance: smc high power: on (1 records sent). balanced: off (2). low-power: P cluster at 2868 MHz, 8.78 W system (4512 MHz, ~12.9 W in balanced/performance).
  • Through Fedora's tuned-ppd, none of this happens with the shipped userspace. tuned only writes /sys/firmware/acpi/platform_profile, which a DT boot doesn't have, so the class stays balanced and High Power stays off. With power: hand the profile to the kernel's platform profile handler aurora-platform#35 (head 0c44cbbc) it works end to end: Power Saver → low-power (2868 MHz, 8.83 W), Performance → performance + on (3), Balanced → off (4).
  • 0 failed units, 0 AVC, 0 kernel errors. The trial Stage 2 and test kernel were removed afterwards.
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)

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