Repository navigation
soc: apple: clpc: hold ANE memory and fabric floor on T8152 - #3977
Conversation
Apple T8152 (M6) defines DCS states 0-7 and SoC fabric states 0-4 in
apple_clpc_hw_t8152 and already accepts G18 GPU demand at the top of
that map (DCS 7, fabric 4), but omits "apple,t8152-clpc" from
apple_clpc_ane_providers[] and leaves apple_clpc_hw_t8152.ane unset.
When CPUs are idle or lightly loaded during ANE execution, both rails
drop to low states.
Add "apple,t8152-clpc" to apple_clpc_ane_providers[] and set
apple_clpc_hw_t8152.ane to { [APPLE_CLPC_DCS] = 7, [APPLE_CLPC_SOC] = 4 },
matching the top states the T8152 table already uses for CPU and G18 GPU
demand (with no CPU cluster frequency floor). On J873g (M6 Mac mini)
with CPUs pinned at minimum frequency, raising the T8152 PMC agent-1
floor from (0, 0) to (7, 3) cut H18G 256x256 FP16 matvec median kernel
execution time 2.2x (643.0 to 290.1 us on ane0; 285.7 us on ane1),
bit-exact.
Extend the apple-clpc-gpu KUnit suite and clpc-gpu-demand host test to
verify T8152 ANE demand (0x47), sub-sample pending capture, vote hold,
and idle release.
Signed-off-by: Kevin loo <kevin@loo.ski>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
sithglan
left a comment
There was a problem hiding this comment.
J873g (M6 Mac mini, apple,j873g / apple,t8152) exact-head hardware row at e53036fbe08f3eb1b0b2e1e0751653ab17d0cf4f (7.3.0-aurora-pr3977+, one-shot aura-try, clean default cmdline console=tty0 rdinit=/init root=LABEL=debian): PASS.
- Boot & peripherals: All 12 CPUs
0-11online, 0 failed units,end010GbE andwlp1s0f0Wi-Fi UP, Vulkan1.4.363(Apple M6 (G18G B1)), 0 CLPC/PMC errors. - Live KUnit on J873g:
apple-clpc-gpu16/16 PASS (includingapple_clpc_ane_demand_hold_test,apple_clpc_ane_states_test,apple_clpc_ane_cluster_test,apple_clpc_ane_no_provider_test,apple_clpc_ane_wake_removal_test);apple-clpc-policy6/6 PASS. - Live CLPC & PMC debugfs (
302800000.power-management:performance-controller@1):ane_states:7 4at boot; writable round-trip7 4 -> 6 3 -> 7 4verified; noane_cluster_khzfloor (0).- PMC agent 1 floor held
0x00000047(dcs 7,soc 4,honoured: 0x00000047) under load and released cleanly to0x00000000(honoured: 0x00000000,last_vote: 0x0 reason_bits 0x0) after 2 s idle;samples: 10851 update errors: 0.
- Host test:
python3 tools/asahi/clpc-gpu-demand-tests.pyPASS (all positive and negative controls). - (End-to-end
apple_clpc_ane_set_active()voting from an upstream T8152 ANE driver remains onNot yetuntil T8152 ANE DT/driver nodes land, as noted in the PR body.)
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approving at e53036fbe08f3eb1b0b2e1e0751653ab17d0cf4f. I read the change itself and checked it on a local merge with current main (b924bf47f0c9, so with #2856, #3992 and #3227 in). The merge is clean: tree b1b57953352c, and the only files that differ from main are the two in this PR. main has since moved to e1543c36a962, which touches only two T8142 USB4 dtsi files; the merge is still clean there.
Code
apple,t8152-clpcinapple_clpc_ane_providers[]is the compatible thatapple_clpc_of_match[]already binds andapple,pmc.yamlalready documents. Onlyt8152-j873-pmc.dtsiuses it..ane = { 7, 4 }equals the top of this SoC's own map on both rails, so theane_statesclamp allows it and the vote can't go above what CPU and GPU work already ask for (floor word 0x47). There is no cluster floor: with noapple,ane-cpu-oppandane_cluster_khz0, probe takes the same path as T8140.- No ANE node on
mainbinds to it yet, so nothing publishes ANE work on T8152 until one lands; until then the only change is the allocated input and theane_statesdebugfs file. A second ANE engine gets no vote because the input takes one publisher; the body says so. - The forward
static constdeclaration sits in the KUnit block next to the T6050 one, and the plain build does not contain it.
Run on the merge (local, hosted jobs are skipped for this fork PR)
run-host-tests.py --only clpcin the Ubuntu 24.04 host-test image with the workflow's pinned toolchain: 9/9 (gpu-demand, high-power-cleanup with and without--old-ref, ane-cpu-opp with its 5 mutations).- The merged
clpc-gpu-demand-tests.pyfails at the newcheck_t8152_aneassertion againstmain'sclpc.c, and with.aneremoved, set to (7, 3), or set to (6, 4).main's own script passes onmain. checkpatch --stricton the commit and on the merge diff: 0 errors, 0 warnings, 0 checks.- arm64
clpc.o, clang 23,defconfig+asahi.config,W=1: 0 warnings withCONFIG_KUNIToff and withCONFIG_KUNIT=y; the KUnit object contains the changed test cases. - No conflict with #3868 (
82166dde5c7d) or #3882 (491e031bb680), and the three clpc host tests pass on each of those trees combined with this one.
Not run by me: the apple-clpc-gpu and apple-clpc-policy KUnit suites. They need arm64 (CPU_FREQ is not available on UML). The J873g row at this head ran them live: 16/16 and 6/6.
Nit, not blocking
The table comment cites a measurement at (7, 3) for a value of (7, 4). The body already lists the SOC 3 against SOC 4 sweep as open; when it is done, put its numbers in that comment.
What: Add
"apple,t8152-clpc"toapple_clpc_ane_providers[]and setapple_clpc_hw_t8152.aneto{ [APPLE_CLPC_DCS] = 7, [APPLE_CLPC_SOC] = 4 }(matching the top statesapple_clpc_hw_t8152.mapalready holds for CPU and G18 GPU demand), with KUnit and host-test coverage.Tested: At
e53036fbe08f:tools/asahi/clpc-gpu-demand-tests.py(including newcheck_t8152_ane()and all negative controls) andtools/asahi/clpc-high-power-cleanup-tests.pypass;scripts/checkpatch.pl --strict --git HEAD~1..HEADreports 0 errors, 0 warnings, and 0 checks. On J873g M6 Mac mini (apple,t8152, Linux7.3.0): raising T8152 PMC agent-1 from(0, 0)to(7, 3)with CPUs pinned at minimum frequency cut H18G256x256FP16 matvec median kernel execution time 2.2x (643.0 us -> 290.1 usonane0,285.7 usonane1, bit-exactmax_abs_err=0), and T8152 CLPC with.ane = { 7, 4 }ran across a 5-minute sustained multi-engine load and cold reboots with 0 CLPC update errors.Risk: two-way door · M6 (T8152) only; zero behavioral change for any other Mac or CLPC compatible.
Not yet: Live boot on J873g M6 at exact head
e53036fbe08f, end-to-endapple_clpc_ane_set_active()voting once upstream T8152 ANE driver and DT nodes land, aSOC 3vsSOC 4power sweep across heavier H18G workloads, and other T8152 boards (J804,J833ct).Details
Problem
apple_clpc_hw_t8152defines DCS states0-7and SoC fabric states0-4and already takes G18 GPU input (gpu_input = true) at the top of its map (DCS 7,SOC 4, floor word0x47), whilet8152-j873-pmc.dtsideclarescompatible = "apple,t8152-clpc". However,drivers/soc/apple/clpc.comits"apple,t8152-clpc"fromapple_clpc_ane_providers[]and leavesapple_clpc_hw_t8152.aneall-zero, soclpc->aneis never allocated and ANE work with idle or lightly loaded CPUs leaves both rails at low states.Changes
drivers/soc/apple/clpc.c:{ .compatible = "apple,t8152-clpc" }toapple_clpc_ane_providers[]soapple_clpc_ane_get()binds T8152 ANE clients (both via explicitapple,clpcphandle and fallback matching).apple_clpc_hw_t8152.ane = { [APPLE_CLPC_DCS] = 7, [APPLE_CLPC_SOC] = 4 }, using the top states already qualified inapple_clpc_hw_t8152.mapfor CPU and G18 GPU work (runtime tunable via debugfsane_states). No CPU cluster frequency floor (ane_cluster_khz = 0) is set, so this has zero interaction or conflict with soc: apple: clpc: take the ANE cluster floor and High Power from the DT #3741 (apple,ane-cluster-floor).apple_clpc_ane_demand_hold_test()andapple_clpc_ane_cluster_test()in theapple-clpc-gpuKUnit suite to verify T8152's(7, 4)ANE demand andane_cluster_khz == 0.tools/asahi/clpc-gpu-demand-tests.py:apple_clpc_hw_t8152alongside the other SoC tables and addcheck_t8152_ane()exercisingapple_clpc_sample()for idle (0x00), active ANE demand (0x47,reason=32), sub-sample pending capture,HOLD_MShold boundary (reason=16), and idle release (0x00,queued_idle).No devicetree or binding changes are required (
apple,t8152-clpcis already documented inDocumentation/devicetree/bindings/power/apple,pmc.yamland present inarch/arm64/boot/dts/apple/t8152-j873-pmc.dtsi).Follow-up note
T8152 carries two ANE engines (
ane0andane1), whereasapple_clpc_ane_get()currently enforces a single publisher (refcount == 1). Extendingapple_clpc_aneto track multiple concurrent publishers is intentionally kept out of scope here for a dedicated follow-up once upstream T8152 ANE driver support lands.Evidence
Local checks at
e53036fbe08f(baseorigin/mainbf7d80caf)Hardware measurement (J873g M6 Mac mini,
apple,t8152)Workload: H18G
1x256 @ [256, 256]FP16 matvec (256/256bit-exact against CPU FP16 reference,max_abs_err=0), CPUs pinned atpowersaveminimum (1.440 GHz/0.972 GHz):(0, 0)ane0643.0 us(550.9 us)725.2 usmax_abs_err=0)(7, 3)ane0290.1 us(257.7 us)332.3 usmax_abs_err=0)(7, 3)ane1285.7 us(262.0 us)326.4 usmax_abs_err=0)CLPC agent-1 with
apple_clpc_hw_t8152.ane = { 7, 4 }(0x47) also ran cleanly on J873g across a 5-minute sustained multi-engine load and unattended cold reboots with0CLPC update errors.