Repository navigation
soc: apple: clpc: hold the M4 (T8132) memory, fabric and P-cluster floors for ANE work - #2856
RyanTheTide wants to merge 10 commits into
Conversation
The M4 (T8132) CLPC takes no ANE input, so Neural Engine work runs with the memory controller and fabric at whatever the CPUs ask for. On an idle J713 MobileNetV1 takes 0.92 ms an EXECUTE (firmware 0.70 ms). With every CPU busy, which makes the CLPC hold its M5/F3 busy floor, the same program takes 0.35 ms (firmware 0.34 ms). The M4 Pro, whose CLPC holds an ANE floor, takes 0.27 ms. Make the T8132 CLPC an ANE provider and hold that one qualified busy floor, M5/F3 (the state the GPU gets while it has work in flight), while ANE work is in flight. Also add the SMC dependency the CLPC KUnit config was missing (the test kernel did not link without it). Signed-off-by: Ryan Murray <[email protected]>
As on the M4 Pro, the M4's Neural Engine runs at a speed set by the frequency of one CPU cluster, whatever runs on it: here the P cluster (cpu-map cluster1). With the M5/F3 floor held, MobileNetV1 on a J713 spends 0.44 ms in the firmware with the P cluster at or below 1.512 GHz, 0.32 ms at 2.616 GHz and 0.29-0.31 ms from there up to 4.104 GHz. Hold the P cluster at 2.616 GHz, the start of that plateau, while ANE work is in flight, through the existing cluster floor. Signed-off-by: Ryan Murray <[email protected]>
The Neural Engine on M4-generation SoCs runs at a speed set by the frequency of one CPU cluster, whatever runs on it. Let the CLPC node name an OPP of that cluster's table: while ANE work is in flight the cluster is held at or above that OPP's frequency. Signed-off-by: Ryan Murray <[email protected]>
On a J713, MobileNetV1 spends 0.44 ms in the ANE firmware with the P cluster at or below 1.512 GHz, 0.32 ms at 2.616 GHz and 0.29-0.31 ms from there up to 4.104 GHz. Point the CLPC's apple,ane-cpu-opp at the P cluster's 2.616 GHz OPP, the start of that plateau. The property goes in t8132.dtsi, not in t8132-memory.dtsi with the rest of the CLPC node: the T8132 platform-data adapter shares that file without the CPU OPP tables, so a boot that takes its nodes from the adapter gets no ANE cluster floor. Signed-off-by: Ryan Murray <[email protected]>
The T8132 ANE cluster floor came from the CLPC's hardware table (cluster 1, 2616000 kHz) and was applied only on machines compatible with "apple,t8132". Both are already in the device tree: the cluster is the one whose CPUs use the OPP table, and the floor is an OPP in it. Read the CLPC node's apple,ane-cpu-opp at probe: the cluster is a CPU whose operating-points-v2 is the OPP's table, the floor is its opp-hz. Without the property there is no cluster floor on T8132. T6040 keeps its table entry until its tree carries the property. tools/asahi/clpc-ane-cpu-opp-tests.py runs the production parser over a fake tree: the CPU comes from the OPP's table and the floor from its opp-hz, an OPP no CPU uses or without a usable frequency is refused, a CPU without a node is skipped, and every node it gets is put. Taking any CPU, reporting hertz or leaking the OPP node each fail it. Signed-off-by: Ryan Murray <[email protected]>
Probe registered the cpufreq policy notifier for the ANE cluster floor before apple_clpc_stop() was installed as a devres action. Any probe error in between (a bad apple,gpu-power-state, no PMC parent, no reg, a bad rail count, an allocation failure) freed the CLPC data with its notifier still on the global policy chain, and the notifier would also have taken sample_lock before mutex_init(). Register it from one helper, used by the ANE floor and by the platform profile, only once apple_clpc_stop() is in place to unregister it. The ANE floor and its ane_cluster_khz debugfs file now exist only when the notifier is registered. apple,ane-cpu-opp accepted any opp-hz up to UINT_MAX kHz, but the floor is a frequency QoS request, which is an s32: a value above S32_MAX kHz turned into a negative request that failed on every sample. Refuse it, compare the CPU's OPP table before putting it, and cover both bounds (1 kHz, S32_MAX kHz), an OPP outside a table and a CPU without a table in clpc-ane-cpu-opp-tests.py, with mutants for the bound and the missing parent check. Also put the T8132 ANE KUnit expectations under their own comment. Signed-off-by: Ryan Murray <[email protected]>
|
Review at a3ff203. The DT shape for the cluster floor is the right direction, but the series still carries a SoC gate, the floor value comes from a benchmark, and the head mechanism has not run on hardware.
|
There was a problem hiding this comment.
Adversarial pre-PR checklist review (§1–§6) at a3ff20338afe6fd8190de3151a6569a468c20b96 (REQUEST_CHANGES).
Checklist Summary
- §1 (No model gating): Pass — at head
a3ff2033, T8132's ANE cluster floor is driven purely from the DT propertyapple,ane-cpu-opp = <&donan_p_opp_2616>inarch/arm64/boot/dts/apple/t8132.dtsi(documented inDocumentation/devicetree/bindings/power/apple,pmc.yaml), withapple_clpc_hw_t8132.ane_cluster_khz = 0and.ane_cluster_machine = NULL. T6040 retains its existing table entry only as a fallback whenapple,ane-cpu-oppis absent (-ENOENT), per §1 chicken-and-egg rules. - §2 (Production-ready / default cmdline): Pass — works on default command line with no module parameters or hacks.
- §3 (Safety & concurrency): Pass (with one pre-existing non-blocking concurrency note below) —
apple_clpc_ane_cpu_opp()validatesopp-hzin[1 kHz, S32_MAX kHz](preventing negatives32PM QoS requests), comparescpu_table == tablebeforeof_node_put(), and balances all OF node references (verified byclpc-ane-cpu-opp-tests.py+ 5 mutations). Movingapple_clpc_policy_nb_register()afterdevm_add_action_or_reset(dev, apple_clpc_stop, clpc)andmutex_init(&clpc->sample_lock)closes the probe-error UAF / uninitialized-mutex race and prevents double registration when bothane_cpu >= 0andlow_power_khzare set.clpc->anekref +apple_clpc_ane_detach()remain safe across removal. - §4 (Clean-room & attribution): Pass — all 6 commits carry human author/committer and human
Signed-off-by:only; PR body includesAssisted-by:. - §5 (Evidence): Blocked — see Blocker below.
- §6 (Naming): Pass — clean Aurora/Linux naming throughout.
Blocker
- §5 (Evidence) — No J713 hardware run or arm64 KUnit run at head
a3ff2033(and CI still running):- The J713 MobileNetV1 table in the PR body was collected on the earlier table-based commits (prior to
apple,ane-cpu-oppDT parsing, theapple_clpc_policy_nb_register()/apple_clpc_stop()reordering, and the rebase onto#2816). - As listed under
**Still to run.**, please post the heada3ff2033evidence:- arm64 QEMU KUnit (
drivers/soc/apple/clpc.kunitconfig) ona3ff2033. - J713 run on
a3ff2033with a Stage 2 DTB built from this tree: 2.616 GHz P-cluster floor held during MobileNetV1 and released after, matching EXECUTE latency, plus a boot withoutapple,ane-cpu-oppshowing no cluster floor and no regressions. - On the same J713 boot:
#2816low-power/performanceplatform profiles still behave as before, thermal/scaling_max_freqcap below 2.616 GHz still wins over the ANE floor, idle/sustained package power, and regression counts (0 SELinux denials, 0 failed units, 0 new kernel errors).
- arm64 QEMU KUnit (
- Also wait for CI
dt-checksandkunitto finish green (currentlyIN_PROGRESS;host-tests,source,rust-build, and DWC3/ATC builds are green).
- The J713 MobileNetV1 table in the PR body was collected on the earlier table-based commits (prior to
Non-blocking Technical Notes
- Pre-existing lock race between
apple_clpc_halt()andapple_clpc_policy_notify()(drivers/soc/apple/clpc.c:1196-1199, 1221-1230, 1252-1262):apple_clpc_halt()readsclpc->ane_qos_khzand callsfreq_qos_update_request(&clpc->ane_qos, FREQ_QOS_MIN_DEFAULT_VALUE)without holdingclpc->sample_lock, and inapple_clpc_stop()it runs beforecpufreq_unregister_notifier(). A concurrentCPUFREQ_REMOVE_POLICYcallback (which takessample_lockand callsfreq_qos_remove_request(&clpc->ane_qos)) can race withapple_clpc_halt()on suspend or unbind. Wrapping theane_qosupdate inapple_clpc_halt()withsample_lock(and checkingfreq_qos_request_active(&clpc->ane_qos)) would close this cleanly. apple_clpc_ane_cpu_opp()missing-vs-invalid phandle (clpc.c:1288-1290): Ifapple,ane-cpu-oppis present in DT with a broken phandle,of_parse_phandle()returnsNULLand the helper returns-ENOENT, which on a fallback-capable SoC (like T6040) would silently fall back to the table instead of returning-EINVAL. Checkingof_property_present()first would distinguish absent from malformed.- Intermediate commit gating: Commit 2 (
2b4248d1523b) temporarily adds.ane_cluster_machine = "apple,t8132"before commit 5 (60dd04604a66) replaces it withapple,ane-cpu-opp. Net state ata3ff2033is clean.
|
Review at a3ff203: BLOCKERS:
The two code findings from the #2671 review are fixed at this head, and I found no new code defect. The blockers above are the hardware rows that review asked for, which are still owed. Full reviewCode findings from the #2671 review (9736f57), checked at a3ff203:
Replay onto #2816: the only conflict, Other Macs: when the property is absent, Lifetime/refcount: the DT/binding: Mechanics: every commit in integration/aurora..a3ff203 carries only Run here at a3ff203:
Assisted-by: LLM (Claude:Opus 5.5) |
|
arm64 KUnit at a3ff203 (§5 item 1): |
|
J713 rows at a3ff203 (13-inch M4 Air, 27.2), for item 3 of the review. The kernel is integration/aurora 95a13cf plus open heads, including this PR at a3ff203, booted as a one-shot on the default command line. The ANE load is MobileNetV1 looped on the H16G. policy0 is the P cluster (CPUs 0, 7, 8, 9). Values were sampled every 50 ms.
Still to run: the boot with a DTB that lacks Assisted-by: LLM (Claude:Opus 5.5) |
Once the T8142 engine AXI2AF bridge tunables are applied, pure ANE execution time on T8142 also depends on the P-cluster frequency (cpu-map cluster1), independent of which CPU cluster submits the request. Measured on J813 (MacBook Air 13" M5, T8142; J815 and J704 share the compatible) pinned to an E-core with the DCS 7 / SOC 3 floor active, unet-320 firmware report_done drops from 660.5 us with no P-cluster floor to 350.7 us at 4176 MHz (host p50 954.4 us -> 616.5 us, 4.49 W average), with no further reduction at 4464 MHz (363.0 us, 5.31 W). Enable the existing CLPC ANE cluster frequency floor on apple_clpc_hw_t8142 for cluster 1 at 4176000 kHz, matching all T8142 machines via "apple,t8142" as required by the current apple_clpc_probe() check (no single-board gating; can move to apple,ane-cpu-opp once aurora-silicon#2856 lands). Extend apple_clpc_ane_cluster_test accordingly. Signed-off-by: Bartosz Nitka <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at a3ff20338afe: the code is ready; it needs only a row at this head.
Blockers: none in the code. Missing row: your J713 rows at this head show the floors held under the ANE load, and KUnit passes 11/11. What your 11-22 note still asks for is one J713 boot with apple,ane-cpu-opp removed from the DTB, probing cleanly with no cluster floor. The branch also conflicts with main; update it first.
Checked: no Apple material. The CPU OPP comes from the DT (apple,ane-cpu-opp), not a table.
Keep the platform-profile and PMC probe paths from main. Resolve the ANE OPP after its provider is allocated and register the shared policy notifier after the teardown action is registered. Signed-off-by: Ryan Murray <[email protected]>
There was a problem hiding this comment.
Verdict: FINISH, then merge at f55414fe
Blockers:
- 27 CI checks (
apple-build,dt-checks,host-tests,source,pr-text,readiness, KUnit suites) were cancelled atf55414feand need a green rerun. - Missing the negative J713 boot row at
f55414fe(booting withapple,ane-cpu-oppabsent from the DTB to confirm clean probe with no cluster floor) alongside exact-head confirmation.
Checked:
- Code & DT binding (
apple,ane-cpu-oppinapple,pmc.yamlandt8132.dtsi, policy notifier registered after teardown action ina3ff2033, cleanly forward-merged atf55414fe): no SoC/board gates,MERGEABLEonmain. - Checked for Apple material, tool attribution, and private serials: clean.
Evidence
- Head:
f55414feee1f(base: main,mergeable: MERGEABLE,+293/-27across 6 files).
Signed-off-by: Ryan Murray <[email protected]>
|
Forward-merged main into this branch, new head 34249ab. The merge was clean, with no force push. The PR's diff against main is still the same 6 files: clpc.c, t8132.dtsi, apple,pmc.yaml, clpc.kunitconfig, the clpc-ane-cpu-opp host test and its run-host-tests entry. clpc.c now sits on top of #3293 (deferrable idle timers) and the apple,cpu-busy-floor change. |
There was a problem hiding this comment.
Verdict: HOLD — forward merge clean, awaiting queued CI and exact-head hardware rows at 34249abde14b
Blockers:
- 27 CI checks at
34249abde14b(apple-build,dt-checks,host-tests,kunit,rust-build,source,pr-text,readiness, KUnit suites) are still queued and must finish green. - Exact-head hardware rows at
34249abde14bremain open: (a) J713 with the shipped DTB (ANE load holds memory, fabric, and P-cluster floors, release drops them, plus ones2idlecycle), (b) J713 negative boot withapple,ane-cpu-oppremoved from the DTB confirming clean probe with no cluster floor, and (c) J473 or J413 no-change row (platform_profileswitch and clean teardown).
Checked:
- Forward merge
34249abde14bofmain(#3293deferrable idle timers +apple,cpu-busy-floor): clean (MERGEABLE), confined to the same 6 files (apple,pmc.yaml,t8132.dtsi,clpc.c,clpc.kunitconfig,clpc-ane-cpu-opphost test, andrun-host-tests.py). apple_clpc_ane_cpu_opp()reference counting (of_node_putoncpu_np,cpu_table,table,opp), frequency bounds (hz >= 1000,div_u64(hz, 1000) <= S32_MAX),apple_clpc_policy_nb_register()ordering afterapple_clpc_stop(), andtools/asahi/run-host-tests.py --only clpc(9/9passed).
Evidence
- Verified
t8132.dtsiplacesapple,ane-cpu-opp = <&donan_p_opp_2616>outsidet8132-memory.dtsiso legacy-loader adapters without CPU OPP tables stay unaffected. - No code blockers found at
34249abde14b.
|
34249ab J473 (M2 Mac mini, T8112) no-change regression PASS: combined guarded one-shot |
Signed-off-by: Ryan Murray <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
|
I merged current |
There was a problem hiding this comment.
Verdict: HOLD at ec83c545.
Checked: Compared the PR patch before and after the forward merge. The file set and added and removed lines match the reviewed revision. Keep hosted DT and driver checks, the J713 ANE floor/release row and the negative boot without the optional OPP.
There was a problem hiding this comment.
Verdict: MERGE at ec83c545c748
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: Compared the PR patch before and after the forward merge. The file set and added and removed lines match the reviewed revision. Keep hosted DT and driver checks, the J713 ANE floor/release row and the negative boot without the optional OPP.
Follow-ups (not blocking): hosted DT/driver checks, J713 ANE floor/release row, negative boot without optional OPP
What: Let the T8132 CLPC hold memory and fabric floors for active Neural Engine work. The optional
apple,ane-cpu-oppphandle identifies the CPU cluster and OPP. The policy notifier is registered only after the teardown action is installed.Tested: Forward head
f55414feee1f0: arm64clpc.obuilt withW=1from the fleet89 configuration, with the corrected Rust bindings generator. All nine CLPC host jobs passed, including absent/invalid OPP coverage, the five parser mutations, and platform-profile teardown checks. Prior J713 M4 Air ata3ff20338afeused the default cmdline on 27.2 firmware and held the expected floors with no reported faults.Risk: one-way door · optional T8132 devicetree binding. The driver also shares platform-profile and teardown paths with other Macs.
Not yet: Guarded J713 at this head, including a DTB without
apple,ane-cpu-opp. Repeat normal ANE and release checks and a shared peer with the current default.Details
Supersedes #2671. This forward merge onto
ba29027e1580keeps the main branch's PMC and platform-profile probe paths. The driver resolves the OPP after allocating the ANE provider. Both ANE and the low-power profile use one idempotent notifier registration after cleanup is registered. The legacy fallback stays available on hardware where it was already configured. T8132 has no fallback CPU floor when the property is absent.Evidence
CONFIG_APPLE_CLPC=y,CONFIG_MFD_MACSMC=yandCONFIG_ACPI_PLATFORM_PROFILE=y. The OPP parser bounds output to 1 kHz throughS32_MAXkHz and puts every devicetree node it obtains.