Skip to content

soc: apple: clpc, arm64: dts: t6041: M4 Max CLPC policy, GPU/DCS wiring, and macsmc fan lock fix - #1951

Merged
DjDeveloperr merged 4 commits into
aurora-silicon:integration/aurorafrom
astaff:t6041/j616c-llm-perf
Nov 21, 2026
Merged

DjDeveloperr merged 4 commits into
aurora-silicon:integration/aurorafrom
astaff:t6041/j616c-llm-perf

Conversation

@astaff

@astaff astaff commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Separate T6041 (M4 Max) from T6040 (M4 Pro) in apple-clpc, wire the M4 Max GPU and thermal DCS backstop in DT, and prevent macsmc-hwmon fan mode polling from blocking concurrent temperature/power reads.

Summary of changes

  1. hwmon: macsmc: drop chip hwmon lock across fan mode transitions
    Drop the chip-wide hwdev->lock around macsmc_hwmon_set_fan() in macsmc_hwmon_write_fan() so SMC fan mode transitions (Ftst=1 / Ftst=0, which poll up to MACSMC_FAN_MODE_TIMEOUT_MS = 10 s) do not stall concurrent thermal zone polling (hwmon_thermal_get_temp()) or sensor telemetry. Fan state transitions and SMC key transactions remain serialized by hwmon->fan.lock and smc->mutex.

  2. dt-bindings: power: apple,pmc: add the T6041 M4 Max CLPC compatible
    Allow apple,t6041-max-clpc ahead of the apple,t6041-clpc fallback, matching t6041.dtsi's apple,t6041-max-avd convention and apple,t6050-clpc.

  3. soc: apple: clpc: give T6041 its own top-state policy table
    Add a dedicated apple_clpc_hw_t6041 table matched via apple,t6041-max-clpc while keeping T6040 (M4 Pro) on apple,t6041-clpc:

    • Vote DCS 5 and SoC fabric 3 (VOVD; ADT clpc fabric-mem-separation-max = 3) across all quartiles with sustain = 0 and .gpu_input = true.
    • Set .idle_on_time = true on apple_clpc_hw_t6041 (as on T6050): with a single busy core and the remaining 15 CPUs idle on M4 Max, a deferrable timer waits on an idle CPU and leaves single-threaded DRAM loads stuck at DCS state 0 (~284 ns/load vs ~166–187 ns/load once sampled), while leaving all other SoCs on deferrable idle timers.
    • Preserve T6041's DCS 5 / fabric 2 ANE floor, move T6041's 2808000 kHz Low Power platform profile ceiling onto apple_clpc_hw_t6041, and retire the now-unused low_power_machine selector.
  4. arm64: dts: apple: t6041: select M4 Max CLPC and wire GPU/DCS cooling

    • Select "apple,t6041-max-clpc", "apple,t6041-clpc" on &clpc in t6041.dtsi.
    • Link the GPU node in t6041.dtsi to &clpc via apple,clpc, matching t6040.dtsi and t8132-gpu.dtsi.
    • Declare #cooling-cells = <2> on &pmc in t6041.dtsi and bind &pmc to cpu-die-thermal's passive backstop trip on J614c/J616c.

Measurements on J616c (MacBook Pro 16", M4 Max, T6041)

  • Single-thread DRAM pointer chase: ~284 ns/load (stuck at DCS state 0 on deferrable idle timer) → ~166–187 ns/load with .idle_on_time = true (macOS 27.2.1: ~204 ns/load)
  • 12-thread CPU DRAM read bandwidth: ~256 GB/s (fabric state 2) → ~297 GB/s (fabric state 3)
  • 256 MiB GPU copy throughput: ~43 GB/s (state 0, unwired apple,clpc) → ~230 GB/s (DCS 5 / fabric 3)
  • Sustained Vulkan LLM token generation: ~18.9 tok/s → ~55.9 tok/s

Verification

  • python3 tools/asahi/clpc-gpu-demand-tests.py (including all 12 negative controls) and python3 tools/asahi/clpc-high-power-cleanup-tests.py
  • arm64 KUnit under qemu-system-aarch64: apple-clpc-gpu (11/11 passed, including apple_clpc_t6041_policy_test), macsmc-hwmon (3/3 passed), and macsmc-hwmon-fan (13/13 passed)
  • ARCH=arm64 LLVM=1 (CONFIG_WERROR=y, CONFIG_KUNIT=y) build of drivers/soc/apple/clpc.o, drivers/hwmon/macsmc-hwmon.o, apple/t6041-{j616c,j614c,j575c}.dtb, and apple/t6040-{j616s,j614s,j773s}.dtb
  • dt_binding_check (DT_SCHEMA_FILES=power/apple,pmc.yaml) and CHECK_DTBS=y on t6041-{j616c,j614c,j575c}.dtb and t6040-{j616s,j614s,j773s}.dtb
  • ./scripts/checkpatch.pl --strict (0 errors, 0 warnings, 0 checks)

@astaff
astaff force-pushed the t6041/j616c-llm-perf branch from c3b1f12 to 660079a Compare November 17, 2026 05:35
@astaff
astaff marked this pull request as ready for review November 18, 2026 15:25
@astaff astaff changed the title arm64: apple: t6041: wire GPU/top-state CLPC demand, policy-init CPU boost, and non-blocking SMC fan transitions arm64: apple: t6041: enable GPU/top-state CLPC demand, policy-init CPU boost, and non-blocking SMC fan switches Nov 19, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for this. The J616c numbers are a big improvement, and the idle-sampling and fan-lock fixes help every chip.

One change on how the T6041 profile is selected. drivers/soc/apple/clpc.c:1360-1362 looks at the machine compatible (of_machine_is_compatible("apple,t6041")) after matching the T6040 data. The CLPC node already has its own compatible: the match table has { .compatible = "apple,t6041-clpc", .data = &apple_clpc_hw_t6040 }. In this tree we select behaviour from the IP block's compatible or match data, not from the machine.

Could you point that entry at &apple_clpc_hw_t6041 and drop the of_machine_is_compatible() override? That gives the same result on the J616c and covers the J614c and any other T6041 board automatically.

Separately, if the DCS 5 / fabric 3 floors come from a fabric limit that differs from the M4 Pro, a one-line comment saying so would help. If the M4 Pro should get the same floors, we can run rows on our M4 Pro.

@astaff
astaff force-pushed the t6041/j616c-llm-perf branch from 660079a to 5115765 Compare November 19, 2026 17:53
@astaff

astaff commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Updated the series as requested:

  1. CLPC selection via IP compatible (apple,t6041-max-clpc, 069199e08d8c / 33bee7772157 / 511576514e0f):
    t604x.dtsi shares "apple,t6041-clpc" across both t6040.dtsi (M4 Pro; there is no separate T6040 entry in apple_clpc_of_match[]) and t6041.dtsi, so pointing "apple,t6041-clpc" directly at &apple_clpc_hw_t6041 would switch M4 Pro boards onto the T6041 table and vote fabric state 3 on T6040's 0..2 fabric rail. Following t6041.dtsi's existing &avd convention ("apple,t6041-max-avd", "apple,t6041-avd"), &clpc in t6041.dtsi now carries "apple,t6041-max-clpc", "apple,t6041-clpc", apple_clpc_of_match[] maps "apple,t6041-max-clpc" -> &apple_clpc_hw_t6041, and the of_machine_is_compatible("apple,t6041") override in apple_clpc_probe() is dropped. That covers J616c, J614c, J575c, and any future T6041 board automatically from the IP compatible while leaving all T6040 DTBs unchanged on apple_clpc_hw_t6040.

  2. Comment on DCS 5 / fabric 3 vs M4 Pro (33bee7772157):
    Added a comment above apple_clpc_hw_t6041 noting the hardware rail difference: M4 Pro (T6040, 4 AMCCs / 256-bit LPDDR5X-8533, 273 GB/s) only has fabric states 0-2, whereas M4 Max (T6041, 6/8 AMCCs / 384/512-bit LPDDR5X-8533, 410/546 GB/s) adds fabric state 3 (VOVD, ADT fabric-mem-separation-max = 3) and macOS 27.2.1 votes DCS 5 / fabric 3 immediately without a busy-sample streak. (On M4 Pro, the upper half of apple_clpc_hw_t6040 already reaches T6040's top DCS 5 / fabric 2 states; if you'd like to run rows on M4 Pro testing sustain = 0 or top-state across all quartiles (DCS 5 / fabric 2), that would be a great comparison.)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the update. The apple,t6041-max-clpc compatible keeps the M4 Pro boards on their own table, and the comment about the extra fabric state on the M4 Max gives the hardware reason for the different floors. We will run a no-regression row on our M4 Pro.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Review of 5115765 against integration/aurora e0ee46a. It merges cleanly. CI is green on this head, and the combination is being built on today's base in #2532 (CI only). The apple,t6041-max-clpc table, the DT and bindings, and the macsmc-hwmon lock change look good. Fan writes reach macsmc_hwmon_write_fan() only from hwmon_attr_store(), which holds hwdev->lock, so the unlock/relock is balanced. Two of the six commits change behaviour on every Apple SoC, not only on the T6041, and need changes before this can go in:

  1. 8b6c1b8 (cpufreq boost at init) is CPU frequency policy for every SoC with turbo OPPs, not only T6041. This project keeps CPU DVFS policy out of performance work (DCS/fabric is in scope), so we can't take it as part of this PR. Could you move it to its own PR, so the owner can decide it on its own? There is also a technical question. In this tree cpufreq_policy_online() already calls policy_set_boost(policy, cpufreq_boost_enabled()) for a new policy (cpufreq.c:1644-1651). Its cpufreq_boost_set_sw() recomputes cpuinfo with boost_enabled set and raises boost_freq_req. What stayed clamped on the J616c? A dump of cpuinfo_max_freq, scaling_max_freq and boost per policy, with and without the commit, would show it.
  2. e67e339 (non-deferrable idle_work) wakes every SoC at full idle. apple_clpc_sample() requeues idle_work every APPLE_CLPC_SAMPLE_MS (4 ms) for as long as the CLPC runs. Without the deferrable timer, every SoC now wakes a CPU about 250 times a second even when fully idle: the T8140 (J700, a fanless laptop), T8132, T6040, T8142 and T8152. T6050 opted in only after an idle-power measurement (dcabb8e). Could you keep @idle_on_time and set it in the new apple_clpc_hw_t6041 table? That fixes the J616c and leaves the other SoCs alone until each one has an idle-power row. We'll measure the J700 with and without the series either way (idle wakeups per second, idle power, deep sleep) and post the numbers here.

Everything else can go in as it is once those two are settled. @RyanTheTide's M4 Pro row covers the apple,t6041-clpc (T6040) side.

hwmon_attr_store() holds the chip-wide hwdev->lock across ->write()
callbacks. On Apple Silicon machines whose SMC starts fans in system
mode (mode 3), transitioning a fan into manual mode via Ftst=1 or
releasing Ftst=0 back to firmware control in macsmc_hwmon_set_fan()
polls the SMC mode key every 100 ms for up to 10 s
(MACSMC_FAN_MODE_TIMEOUT_MS).

Holding hwdev->lock across that poll loop blocks all concurrent hwmon
reads on the same chip, stalling thermal zone temperature polling
(hwmon_thermal_get_temp()) and userspace telemetry for the duration of
the SMC mode transition.

Fan state transitions and individual SMC key transactions are already
serialized by hwmon->fan.lock and smc->mutex, and kernfs pins the sysfs
attribute across hwmon_attr_store() until ->write() returns. Drop the
chip-wide hwmon lock around macsmc_hwmon_set_fan() in
macsmc_hwmon_write_fan() so temperature and power reads proceed without
stalling during fan mode transitions.

Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
T6040 (M4 Pro) and T6041 (M4 Max) share t604x.dtsi's apple,t6041-clpc
voter node, while M4 Max's wider memory subsystem adds SoC fabric state 3
and needs its own CLPC policy table.

Allow apple,t6041-max-clpc ahead of the apple,t6041-clpc fallback,
matching t6041.dtsi's apple,t6041-max-avd convention and T6050's CLPC
fallback.

Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
T6040 (M4 Pro) and T6041 (M4 Max) share the apple,t6041-clpc compatible
in t604x.dtsi, which previously mapped both SoCs to apple_clpc_hw_t6040
(DCS {1, 2, 5, 5}, fabric {0, 1, 2, 2}, sustain = 3).

Unlike M4 Pro (4 AMCCs, 256-bit LPDDR5X-8533, fabric states 0-2), M4
Max's 6/8-AMCC 384/512-bit memory subsystem reaches SoC fabric state 3
(VOVD; ADT clpc fabric-mem-separation-max = 3) for full 410/546 GB/s
bandwidth, and macOS 27.2.1 votes DCS 5 and fabric 3 immediately for
active CPU demand without a multi-sample busy streak, raising 12-thread
CPU DRAM read bandwidth on J616c from ~256 GB/s at fabric state 2 to
~297 GB/s.

Add a dedicated apple_clpc_hw_t6041 table (DCS 5, fabric 3 across all
quartiles, sustain = 0, host GPU input enabled) matched directly via
apple,t6041-max-clpc in apple_clpc_of_match[] while keeping T6040 on
apple,t6041-clpc. Enable idle_on_time on apple_clpc_hw_t6041 (as on
T6050): with a single busy core and the remaining 15 CPUs idle on M4
Max, a deferrable timer waits on an idle CPU and leaves single-threaded
memory loads stuck at DCS state 0 (~284 ns per load on J616c instead of
~166-187 ns once sampled), while leaving all other SoCs on deferrable
idle timers. Preserve T6041's DCS 5 / fabric 2 ANE floor, move T6041's
2808 MHz Low Power platform profile ceiling onto apple_clpc_hw_t6041,
and retire the now-unused low_power_machine selector.

Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
T6041 boards already enable the PMC and CLPC voter interface, but shared
t604x.dtsi's apple,t6041-clpc compatible with T6040 and left two links
unwired on M4 Max:

1. Give &clpc in t6041.dtsi the apple,t6041-max-clpc compatible ahead of
   its apple,t6041-clpc fallback (matching &avd) so J614c, J616c, J575c,
   and any future T6041 board select apple_clpc_hw_t6041 directly from
   the CLPC node while T6040 stays on apple_clpc_hw_t6040.

2. Link the GPU node in t6041.dtsi to &clpc via apple,clpc, matching
   t6040.dtsi and t8132-gpu.dtsi, so G17 submissions in flight hold the
   DRAM controller and SoC fabric floors while GPU work is active. On
   J616c this raises 256 MiB GPU copy throughput from ~43 GB/s to ~230
   GB/s and sustained Vulkan LLM token generation from ~18.9 to ~55.9
   tok/s.

3. Declare #cooling-cells = <2> on &pmc in t6041.dtsi and bind &pmc to
   cpu-die-thermal's passive backstop trip on J614c/J616c so non-power-
   actor thermal policies such as step_wise can step down the DCS rail if
   die temperature reaches the backstop behind the PMP fast die loop.

Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
@astaff
astaff force-pushed the t6041/j616c-llm-perf branch from 5115765 to 5f3bca9 Compare November 20, 2026 22:56
@astaff astaff changed the title arm64: apple: t6041: enable GPU/top-state CLPC demand, policy-init CPU boost, and non-blocking SMC fan switches soc: apple: clpc, arm64: dts: t6041: M4 Max CLPC policy, GPU/DCS wiring, and macsmc fan lock fix Nov 20, 2026
@astaff

astaff commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @DjDeveloperr and @RyanTheTide!

Rebased onto current integration/aurora (2e1b085dc2d1 -> 5f3bca941c97) and addressed both items:

  1. Dropped 8b6c1b868395 (cpufreq: apple-soc: propagate boost state into policy->boost_enabled at init):

    • Agreed on keeping cross-SoC CPU DVFS policy out of this series.
    • To answer your technical question on what was clamped on J616c: our original 4056 MHz baseline row was measured on Nov 13–14 against a pre-f677f7c87b7c ("cpufreq: apple-soc: start with boost enabled", Nov 14) snapshot where apple_soc_cpufreq_driver.boost_enabled still started false after ddef17bb8698. On current integration/aurora (with f677f7c87b7c), cpufreq_online() (drivers/cpufreq/cpufreq.c:1644-1652) calls policy_set_boost(policy, true) and raises both cpuinfo_max_freq and scaling_max_freq (boost_freq_req) to 4512000 kHz on both P-clusters (policy0 CPUs 0,5-9 and policy10 CPUs 10-15, boost=1; policy1 E-cluster CPUs 1-4 at 2592000 kHz, boost=0). The only remaining difference with 8b6c1b868395 on today's tree is init-time ordering inside cpufreq_policy_online() before line 1646 runs (CPUFREQ_CREATE_POLICY / cpufreq_register_em_with_opp() / of_cpufreq_cooling_register()), so runtime P-core boost (4512 MHz) needs nothing in this PR.
  2. Dropped e67e3397a092 (global non-deferrable idle_work) and set .idle_on_time = true in apple_clpc_hw_t6041 (48c99cfc0d46):

    • Restored INIT_DEFERRABLE_WORK(&clpc->idle_work, ...), @idle_on_time, apple_clpc_queue(), and apple_clpc_hw_t6050.idle_on_time = true unchanged so T8140 (J700), T8132, T6040, T8142, and T8152 keep their deferrable idle timers with zero idle wakeup change.
    • Enabled .idle_on_time = true solely in apple_clpc_hw_t6041 (with the 1-busy / 15-idle core rationale documented above the table) and added assertions in both apple_clpc_t6041_policy_test and tools/asahi/clpc-gpu-demand-tests.py verifying t6041.idle_on_time == true while t8132/t8140/t6040 remain false.

Re-verified with checkpatch.pl --strict (0 errors/warnings/checks), clpc-gpu-demand-tests.py, clpc-high-power-cleanup-tests.py, dt_binding_check + CHECK_DTBS=y (t6041-{j616c,j614c,j575c}.dtb, t6040-{j616s,j614s,j773s}.dtb), and arm64 KUnit (apple-clpc-gpu 11/11, macsmc-hwmon 3/3, macsmc-hwmon-fan 13/13).

@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.

Re-review of 5f3bca9, which sits on integration/aurora 2e1b085. None of the 20 commits that have landed since touch a file in this series.

Both points from the 06:42 review are addressed:

  1. The cpufreq boost-at-init commit is gone. Thanks for answering the boost question: with f677f7c on the base, both P-cluster policies come up at 4512 MHz with boost=1, so nothing here needs it.
  2. INIT_DEFERRABLE_WORK and @idle_on_time are back as they were, and .idle_on_time = true is set only in apple_clpc_hw_t6041. T8140, T8132, T6040, T8142 and T8152 keep their deferrable idle timer, T6050 keeps its opt-in, and both the KUnit case and the host test assert it.

I also re-read the rest on this head:

  • No change on the M4 Pro. apple_clpc_hw_t6040 loses only the low_power_khz/low_power_machine pair, which was gated to apple,t6041 and never applied to T6040.
  • The ceiling move removes a machine gate. The 2808 MHz ceiling moves onto the T6041 table and low_power_machine is dropped. That's one fewer of_machine_is_compatible() gate.
  • Device match. apple,t6041-max-clpc is a compatible on the CLPC node itself, which is how this tree selects behaviour.
  • macsmc-hwmon locking. The unlock and relock are balanced, and kernfs keeps the attribute alive across the window.

Three notes, none blocking:

  • map-dcs does nothing under the default governor. asahi.config defaults to power_allocator. The J616c PMC node has no apple,dcs-power-microwatt, so the PMC registers its cooling device without power ops, and power_allocator skips it as a non-power actor. The map only acts under step_wise, as your commit message says. One side effect: once the zone is switched to step_wise, switching it back to power_allocator fails, because check_power_actors() rejects a non-actor on the control trip. If you want the DCS backstop under the default governor, a follow-up could add a measured apple,dcs-power-microwatt table, as t8140-j700.dts has. That file's note on the zone oscillating between DCS 1 and 4 under GPU load is worth reading first.
  • Idle power on T6041. With .idle_on_time and sustain = 0, the T6041 samples every 4 ms at idle, and any busy sample votes DCS 5 / fabric 3. An idle-power and idle-wakeups row from the J616c, this head against the base, would be good to have on record, as T6050 has for dcabb8e. It only affects T6041, so it can come after the merge.
  • Redundant compatibles. apple_clpc_gpu_get() and apple_clpc_ane_providers[] now also list apple,t6041-max-clpc. The node's apple,t6041-clpc fallback already matches there, so these entries are redundant but harmless.

CI is green on this exact head (dt-checks, host-tests, source, kunit, rust-build, DWC3/ATC), and it merges cleanly, so I'm merging it. Post-merge verification: @RyanTheTide's M4 Pro no-regression row for the T6040 side, and our J700 idle row (wakeups per second, idle power, deep sleep), although nothing on this head changes the J700. A revert is ready if either turns something up.

Thanks for turning this around so quickly, and for the J616c numbers.

@DjDeveloperr
DjDeveloperr merged commit 5d68bcc into aurora-silicon:integration/aurora Nov 21, 2026
8 checks passed
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.

3 participants