Skip to content

soc: apple: clpc: hold ANE memory/fabric floor on T8142 - #2865

Open
niteria wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
niteria:t8142/clpc-ane-floor
Open

niteria wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
niteria:t8142/clpc-ane-floor

Conversation

@niteria

@niteria niteria commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On T8142 (M5), the H17 ANE driver already calls apple_clpc_ane_get() and publishes in-flight work via apple_clpc_ane_set_active(), and the T8142 device trees already declare "apple,t8142-clpc". However, drivers/soc/apple/clpc.c neither lists "apple,t8142-clpc" in apple_clpc_ane_providers[] nor sets a floor in apple_clpc_hw_t8142.ane. When the CPUs are idle or lightly loaded during ANE inference, both the DRAM controller (DCS) and SoC fabric drop to low states, throttling memory- and fabric-bound workloads (for example, cold-SLC denoise-640 firmware time degrades from 10.37 ms to 20.02 ms).

Change

  • Add { .compatible = "apple,t8142-clpc" } to apple_clpc_ane_providers[].
  • Set apple_clpc_hw_t8142.ane to { [APPLE_CLPC_DCS] = 7, [APPLE_CLPC_SOC] = 3 } with a comment documenting that DCS 7 is T8142's top DCS state and fabric 3 is a measured policy choice below top fabric state 4, backed by three workload classes (denoise-640, unet-320 conv UNet, mm-512x2048 GEMM) and the measured power cost of fabric 4.
  • Update the apple-clpc-gpu KUnit suite to verify T8142's DCS 7 / fabric 3 ANE demand instead of asserting apple_clpc_hw_t8142.ane[APPLE_CLPC_DCS] == 0.

This applies to every T8142 Mac declaring "apple,t8142-clpc" (t8142-j813, t8142-j815, t8142-j704) with no DT changes and no kernel command-line parameters. Only J813 (MacBook Air 13" M5) was tested on hardware. Pinning P-cluster CPU frequency from 1.0 to 4.46 GHz does not change ANE firmware time (10.25 ms vs 10.24 ms), so no ane_cluster_khz floor is set.

Testing

Tested on MacBook Air 13" M5 (J813, T8142) on a one-shot NixOS boot of 95f042dcd43f (7.3.0-air-m5-95f042dcd43f, identical object code to 07effed23425 which updates only the comment and commit message) on the default kernel command line (no ane_states override):

  • CLPC/PMC floor behaviour: At idle, agent1 floor: 0x00000000 honoured: 0x00000000. During ANE execution with both CPU clusters voting dcs 0 soc 0, CLPC votes 0x00000037 (reason_bits 0x20, ane=32), PMC reports agent1 floor: 0x00000037 honoured: 0x00000037, and after inference completes + hold expiry it drops cleanly back to 0x00000000 (update errors: 0).
  • Same-machine A/B (J813, H17 ANE, bit-for-bit sha256 match on all 6 workloads):
Workload Baseline (0, 0) fw / host p50 Final (7, 3) fw / host p50 Delta (fw) Conformance
denoise-640 (cold SLC, 1 GHz CPU) 20023 us / 25443 us (ioctl mean) 10371 us / 14076 us (ioctl mean) -48.2% exact sha256
mm-512x2048 (cold SLC, 1 GHz CPU) 782 us / 2112 us (ioctl mean) 526 us / 1532 us (ioctl mean) -32.7% exact sha256
denoise-640 (default schedutil, 100 runs) 11597 us / 15426 us 10353 us / 13984 us -10.7% exact sha256
denoise-320 (default schedutil, 100 runs) 3767 us / 4429 us 3576 us / 4136 us -5.1% exact sha256
mm-512x2048 (default schedutil, 100 runs) 435 us / 736 us 416 us / 712 us -4.4% exact sha256
unet-320 (default schedutil, 100 runs) 2495 us / 2728 us 2440 us / 2610 us -2.2% exact sha256
xf-l-256 (default schedutil, 100 runs) 738 us / 774 us 680 us / 700 us -7.8% exact sha256
xf-a-128 (default schedutil, 100 runs) 259 us / 270 us 235 us / 242 us -9.5% exact sha256
  • Fabric 3 vs fabric 4 multi-workload power and latency (J813, A-B-A (7,3)->(7,4)->(7,3) via macsmc_hwmon Total System Power PSTR, CPUs pinned at min frequency so ANE owns the floor):
Workload (class) (0, 0) fw / power (7, 2) fw / power (7, 3) fw / power (A-B-A mean) (7, 4) fw / power (7, 4) vs (7, 3)
denoise-640 (conv UNet denoiser) 16484 us / 3.490 W 11665 us / 4.179 W 10328 us / 4.284 W 10345 us / 4.405 W 0% fw, +121 mW (+2.8%)
unet-320 (conv UNet) 3939 us / 3.352 W 2787 us / 3.843 W 2462 us / 3.944 W 2463 us / 4.035 W 0% fw, +91 mW (+2.3%)
mm-512x2048 (GEMM) 627 us / 3.378 W 493 us / 3.901 W 420 us / 3.948 W 420 us / 4.019 W 0% fw, +71 mW (+1.8%)

Under default schedutil on denoise-640, (7, 4) likewise adds +95 mW (4.841 W vs 4.746 W A-B-A mean at (7, 3)) with no firmware speedup.

  • Sustained power, heat, and idle-power check (fanless J813, default schedutil, default ane_states = 7 3, ambient TAOL 21.8 C):
Phase Duration / Runs System power (PSTR) SoC die (macsmc_soc_die) PMC agent1 floor / thermal Result
Pre-soak idle 30 s 2.600 W mean (2.524 W med) 27.0 -> 26.8 C 0x00000000 (28/30), ane: active 0 baseline
Sustained denoise-640 soak 631 s (10.5 min, 45,164 runs) 4.717 W mean (steady 4.70-4.75 W) 26.8 -> 31.7 C (plateaued 31.5-31.7 C) 0x00000037 held, cool=0,0, dcs limit: 0/7, err=0 fw_p50 steady 10342-10355 us, exact sha256
Post-close idle (after close(/dev/accel/accel0)) 0-90 s 2.475-2.477 W (30-90 s steady) 31.7 -> 27.2 C 0x00000000 within 1 s, ane: active 0, err=0 idle power & floor restored
Thermal-limit check (denoise-640 + 10-core CPU burn) 75 s (6,366 ANE runs) 31.39 W peak -> 26.61 W throttled 96.7 C trigger, held <= 99.6 C PMP lane1 engaged (33..96), P-cluster 4464 -> 3720-4020 MHz, err=0 thermal loop wins cleanly, exact sha256
  • Suspend/resume (deep sleep, 30s RTC wake): Clean resume (PM: suspend exit, H17 ANE: resume ok: parked until the next request). Post-resume denoise-640 (50 runs) ran at 10310 us firmware / 13906 us p50 with bit-for-bit sha256 match, raising agent1 floor to 0x00000037 (honoured: 0x00000037, reason_bits 0x20) and returning cleanly to 0x00000000 at idle (update errors: 0).
  • System health: 0 failed systemd units, 0 new kernel errors (NixOS; SELinux not enabled).
  • Local checks on 07effed23425: scripts/checkpatch.pl --strict --git HEAD~1..HEAD (0 errors, 0 warnings, 0 checks), tools/asahi/clpc-gpu-demand-tests.py (pass), tools/asahi/clpc-high-power-cleanup-tests.py (pass), arm64 KUnit apple-clpc-gpu (11/11 passed), full arm64 J813 kernel build.

Still to run

  • Hardware runs on other T8142 boards (t8142-j815 MacBook Air 15" M5 and t8142-j704 MacBook Pro 14" M5), which share "apple,t8142-clpc" (only J813 was tested).
Minimal DCS / fabric state sweep on J813 (cold SLC and warm SLC)

All per-phase timings read from /sys/kernel/debug/ane-h17/420000000.ane/execute (mean microseconds).

Cold SLC (64 MiB eviction + 250 ms idle wait before each EXECUTE, CPUs fixed at 1.0 GHz, pre-exec CLPC floor 0x0)

ane_states (DCS, SOC) denoise-640 firmware denoise-640 copy_out denoise-640 ioctl mm-512x2048 firmware mm-512x2048 copy_out mm-512x2048 ioctl
(0, 0) 20023.1 3893.5 25442.8 781.7 937.1 2111.5
(7, 0) 16020.8 2421.0 19778.5 727.7 672.4 1759.8
(7, 1) 15787.5 2423.2 19741.7 721.4 674.7 1750.5
(7, 2) 11710.1 2359.3 15430.7 559.6 657.8 1575.6
(7, 3) 10371.0 2328.0 14076.2 525.9 655.2 1531.6
(7, 4) 10361.8 2322.7 14112.6 552.1 646.8 1568.2
(0, 3) 10381.3 2728.7 14442.9 538.2 747.5 1648.7
(4, 3) 10351.9 2407.8 14076.6 529.7 663.9 1559.5
(6, 3) 10360.0 2380.7 14131.5 533.7 662.2 1549.4
(0, 4) 10378.5 2745.8 14443.0 532.9 747.7 1683.5
(6, 4) 10360.9 2361.3 14047.9 539.3 660.9 1558.5

Warm SLC (40 runs each, CPUs fixed at 1.0 GHz, pinned to cpu1)

ane_states xf-l-256 fw mm-512x2048 fw unet-320 fw denoise-320 fw denoise-640 fw
(0, 0) 837.1 453.2 2771.0 4097.8 11783.9
(7, 0) 839.9 454.1 2765.1 4048.7 11816.7
(7, 2) 839.3 454.8 2767.9 4048.0 11756.1
(7, 3) 772.1 388.7 2441.6 3580.3 10316.5
(7, 4) 774.8 389.8 2446.8 3712.0 10307.7

CPU cluster frequency control (ane_states = 7 4)

P-cluster / E-cluster / pin denoise-640 firmware denoise-640 copy_in + copy_out mm-512x2048 firmware
1.00 GHz / 1.00 GHz / cpu1 10250.2 us 3585.9 us 389.5 us
4.46 GHz / 1.00 GHz / cpu1 10299.1 us 3522.9 us 388.3 us
4.46 GHz / 2.96 GHz / cpu0 10244.9 us 583.5 us 403.4 us

CPU frequency changes only host-side copy_in/copy_out, not ANE engine firmware time.

CLPC / PMC debugfs capture (boot, post-close, and post-resume on 7.3.0-air-m5-95f042dcd43f)
# Pre-ANE idle
agent: 1 floor: 0x00000000 (saved 0x00000000)
last_vote: 0x0 reason_bits 0x0 (cpu=1 host_gpu=2 streaming_gpu=4 dense_gpu=8 hold=16 ane=32)
ane: active 0 request_ns 0 sequence 0
samples: 1415 update errors: 0
agent1 floor: 0x00000000 honoured: 0x00000000

# Mid-ANE active (denoise-640, default ane_states=7 3)
agent: 1 floor: 0x00000037 (saved 0x00000000)
last_vote: 0x37 reason_bits 0x20 (cpu=1 host_gpu=2 streaming_gpu=4 dense_gpu=8 hold=16 ane=32)
samples: 1480 update errors: 0
cluster cpu0: busy 0% level 29% -> dcs 0 soc 0
cluster cpu1: busy 0% level 32% -> dcs 0 soc 0
agent1 floor: 0x00000037 honoured: 0x00000037

# Post-soak (+1s after close(/dev/accel/accel0), after 45,164 runs)
agent: 1 floor: 0x00000000 (saved 0x00000000)
last_vote: 0x0 reason_bits 0x0
ane: active 0 request_ns 1523399433668 sequence 509948
samples: 352293 update errors: 0
agent1 floor: 0x00000000 honoured: 0x00000000

# Post-resume (deep sleep, 30s RTC wake) mid-ANE active
agent: 1 floor: 0x00000037 (saved 0x00000000)
last_vote: 0x37 reason_bits 0x20
ane: active 1 request_ns 244272159176 sequence 1571
cluster cpu0: busy 0% level 29% -> dcs 0 soc 0
cluster cpu1: busy 11% level 67% -> dcs 0 soc 0
agent1 floor: 0x00000037 honoured: 0x00000037
# denoise-640 (50 runs): fw=10310.1 us, rd=10111.2 us, p50=13906.1 us, sha256 MATCH
# Post-resume post-ANE idle (+1s): agent1 floor: 0x00000000 honoured: 0x00000000, update errors: 0

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Review at 95f042d.

Thanks, the measurements are clear (denoise-640 cold-SLC 20.0 -> 10.4 ms, fabric 4 flat, P-cluster floor no effect), and the change uses the existing H17 busy hook, so the floor is released by the same idle/error/power-down paths as on T6040/T8140. Points:

  1. Where 7 / 3 come from: DCS 7 is the top of T8142's DCS range ("states 0-7"), but fabric 3 is a knee measured on one J813 with one model, below the top state (4). The T6040 entry is described as "its top qualified DCS and fabric states", which the machine defines. Please either use the top state the hardware reports for both rails (and show the power cost of fabric 4 against 3), or say in the comment that fabric 3 is a measured policy choice and back it with a second workload (e.g. mm-512x2048 plus one convolution model), so it isn't tuned to denoise-640.
  2. Power and heat: the J813 is fanless, and DCS 7 / fabric 3 is held for as long as any ANE request is in flight. Please add a sustained row (10+ minutes of continuous ANE load) with package power and die temperature, checking that thermal limits still win. Also add an idle-power check after the ANE device is closed (floor back to 0).
  3. Reach: this applies to J815 and J704 too (same compatible). One boot plus a short ANE run on either, or a note that only J813 was tested.
  4. Merge order: soc: apple: clpc: hold the M4 (T8132) memory, fabric and P-cluster floors for ANE work #2856 reworks the same apple_clpc_ane_providers[] list and ANE floor handling for T8132. Whichever lands second needs a rebase. If soc: apple: clpc: hold the M4 (T8132) memory, fabric and P-cluster floors for ANE work #2856 moves the provider list into the per-chip data, this line moves with it.

The H17 ANE driver on T8142 (M5) already requests an ANE CLPC handle
via apple_clpc_ane_get() and publishes activity via
apple_clpc_ane_set_active(), and the T8142 device trees already declare
"apple,t8142-clpc", but drivers/soc/apple/clpc.c neither lists
"apple,t8142-clpc" in apple_clpc_ane_providers[] nor configures a floor
in apple_clpc_hw_t8142.

When the CPUs are idle or lightly loaded, both the DRAM controller (DCS)
and SoC fabric stay at low states while ANE inference runs, throttling
memory- and fabric-bound workloads. Register "apple,t8142-clpc" as an
ANE CLPC provider and set apple_clpc_hw_t8142.ane to DCS 7 (top DCS
state) and fabric 3 (a measured policy choice below top fabric state 4).

Measured on J813 (MacBook Air 13" M5; J815 and J704 share the
compatible and were not tested) via /sys/kernel/debug/ane-h17/.../
execute, CLPC ane_states, and macsmc_hwmon Total System Power:
- Cold-SLC denoise-640 firmware time (CPU fixed at 1 GHz, pre-exec
  floor 0): 20.02 ms at (0, 0) -> 16.02 ms at (7, 0) -> 15.79 ms at
  (7, 1) -> 11.71 ms at (7, 2) -> 10.37 ms at (7, 3); (7, 4) is
  10.36 ms (no gain).
- Cold-SLC mm-512x2048 firmware time: 782 us at (0, 0) -> 728 us at
  (7, 0) -> 560 us at (7, 2) -> 526 us at (7, 3); (7, 4) is 552 us.
- Controlled A-B-A sweep (CPU pinned at min freq so ANE owns the floor)
  across three workload classes shows fabric 3 saturates firmware time
  while fabric 4 adds 71-121 mW with zero speedup:
  * denoise-640 (conv UNet): 16.48 ms (0, 0) -> 11.67 ms (7, 2) ->
    10.33 ms / 4.284 W (7, 3) vs 10.35 ms / 4.405 W (7, 4) (+121 mW).
  * unet-320 (conv UNet): 3.94 ms (0, 0) -> 2.79 ms (7, 2) ->
    2.46 ms / 3.944 W (7, 3) vs 2.46 ms / 4.035 W (7, 4) (+91 mW).
  * mm-512x2048 (GEMM): 627 us (0, 0) -> 493 us (7, 2) ->
    420 us / 3.948 W (7, 3) vs 420 us / 4.019 W (7, 4) (+71 mW).
- Default schedutil (warm SLC, 100 runs) denoise-640 firmware / p50
  host latency: 11.60 / 15.43 ms at (0, 0) -> 10.35 / 13.90 ms at
  (7, 3); (7, 4) adds +95 mW (4.841 vs 4.746 W) with no fw speedup.
- Sustained 10.5 min (631 s, 45,164 runs) continuous denoise-640 soak
  on fanless J813: 4.717 W mean total system power, SoC die plateaued
  at 31.7 C (21.8 C ambient), 0 CLPC update errors, bit-exact sha256.
  Closing /dev/accel/accel0 drops the floor to 0x0 within 1 s and
  returns idle system power to 2.48 W (vs 2.52 W median pre-soak).
  Under combined ANE + 10-core CPU load, PMP fast-die-effort (lane1)
  still engages cleanly at 96.7 C and holds die temp <= 99.6 C.
- Pinning CPU P-cluster frequency from 1.0 to 4.46 GHz does not change
  ANE firmware time (10.25 vs 10.24 ms), so no CPU cluster floor is
  needed.

Update the apple-clpc-gpu KUnit suite to assert T8142's DCS 7 / fabric
3 ANE demand instead of expecting no ANE floor on T8142.

Signed-off-by: Bartosz Nitka <niteria@gmail.com>
@niteria
niteria force-pushed the t8142/clpc-ane-floor branch from 95f042d to 07effed Compare November 22, 2026 21:35
@niteria

niteria commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Updated at 07effed23425 and measured the requested power, multi-workload, and sustained thermal data on J813 (7.3.0-air-m5-95f042dcd43f, identical object code to 07effed23425):

  1. Fabric 3 rationale & fabric 4 power cost: Kept DCS 7 / fabric 3 and updated the comment in apple_clpc_hw_t8142 to state explicitly that DCS 7 is the top DCS state while fabric 3 is a measured policy choice below top state 4, backed by controlled A-B-A ((7,3) -> (7,4) -> (7,3), CPUs pinned at min frequency so ANE owns the floor) measurements across three workload classes:

    • denoise-640 (conv UNet denoiser): (0,0) 16.48 ms -> (7,2) 11.67 ms -> (7,3) 10.33 ms / 4.284 W vs (7,4) 10.35 ms / 4.405 W (0% fw gain, +121 mW).
    • unet-320 (conv UNet): (0,0) 3.94 ms -> (7,2) 2.79 ms -> (7,3) 2.46 ms / 3.944 W vs (7,4) 2.46 ms / 4.035 W (0% fw gain, +91 mW).
    • mm-512x2048 (GEMM): (0,0) 627 us -> (7,2) 493 us -> (7,3) 420 us / 3.948 W vs (7,4) 420 us / 4.019 W (0% fw gain, +71 mW).
      (Under default schedutil on denoise-640, (7,4) similarly adds +95 mW — 4.841 W vs 4.746 W — with no firmware speedup.)
  2. Sustained 10+ min thermal/power soak & post-close idle power (fanless J813, default schedutil, default ane_states = 7 3, ambient TAOL 21.8 C):

    • Pre-soak idle (30 s): 2.600 W mean (2.524 W median) Total System Power (macsmc_hwmon PSTR), macsmc_soc_die 27.0 -> 26.8 C, agent1 floor: 0x00000000.
    • Sustained denoise-640 (631 s / 10.5 min, 45,164 continuous runs): 4.717 W mean system power (steady 4.70-4.75 W), SoC die plateaued at 31.5-31.7 C (+9.9 C over ambient), fw_p50 steady 10342-10355 us, cool=0,0, dcs limit: 0/7, update errors: 0, bit-exact sha256 match.
    • Post-close idle (close(/dev/accel/accel0)): Within 1 s, ane: active 0 and PMC agent1 floor/honoured dropped to 0x00000000; idle system power returned to 2.475-2.477 W (30-90 s post-close) while die cooled from 31.7 -> 27.2 C.
    • Thermal-limit check (75 s continuous denoise-640 + 10-core CPU burn, 6,366 ANE runs): Total system power peaked at 31.39 W and die reached 96.7 C at t=25 s, where PMP fast-die-effort lane1 immediately engaged (33..96), tapering P-cluster clocks 4464 -> 3720-4020 MHz and reducing power to 26.61 W while holding die temperature <= 99.6 C (0 CLPC errors, exact sha256).
  3. Reach: Noted in both the code comment and PR description that only J813 was tested on hardware (J815 and J704 share "apple,t8142-clpc").

  4. Merge order: Checked soc: apple: clpc: hold the M4 (T8132) memory, fabric and P-cluster floors for ANE work #2856 (still open); happy to rebase cleanly if soc: apple: clpc: hold the M4 (T8132) memory, fabric and P-cluster floors for ANE work #2856 lands first (and move the T8142 entry into per-chip data if soc: apple: clpc: hold the M4 (T8132) memory, fabric and P-cluster floors for ANE work #2856 refactors apple_clpc_ane_providers[]).

Re-ran checkpatch.pl --strict, both CLPC Python host test suites, and arm64 KUnit (apple-clpc-gpu 11/11 passed) on 07effed23425.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 07effed. The delta from 95f042d is the comment above apple_clpc_hw_t8142.ane (clpc.c:1753-1765) and the commit message only, so the J813 rows at 95f042d apply to this head.

  • Fabric 3 rationale: fixed. The comment now says DCS 7 is the top state and fabric 3 a measured choice below 4, and the three-workload A-B-A data (fabric 4: no firmware gain, +71 to +121 mW) backs it.
  • Sustained load and idle after close: fixed. The 10.5 min soak (die plateau 31.7 C, floor held with 0 errors), floor back to 0 within 1 s of close, and PMP still taking over at 96.7 C under ANE plus CPU load cover it.
  • J815/J704: noted as untested in the comment and message, fine.
  • soc: apple: clpc: hold the M4 (T8132) memory, fabric and P-cluster floors for ANE work #2856: still open; this merges cleanly onto integration/aurora today. Whichever lands second rebases.

Nothing else from my side. LGTM.

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