Repository navigation
Conversation
An ANE node may name the CPU cluster performance domain that the driver holds up while requests run. Signed-off-by: Satya Benson <satya@benson.earth>
… run The H16/H17 backends raise the CLPC's DRAM and fabric floors while an EXECUTE is in flight, but leave the CPU clusters to the governor. When the node names a CPU cluster in performance-domains, hold that cluster up from the first EXECUTE until 100 ms after the last one ends: a minimum-frequency request at the policy's maximum, and a resume latency of 0 on its CPUs so that cpuidle keeps them out of power-down. A policy maximum such as a thermal limit still wins. Nodes without performance-domains, or naming a domain without CPUs, hold nothing; there is no SoC or board check. The requests are changed from work items, never in the request path, attach once the cluster's cpufreq policy exists, and are dropped before system sleep. Tested on J775c (Mac Studio M5 Max, T6050) on cand-16b + #3003 + #3004 with this final driver code (boot_id d34470f0-1857-40c5-aef5-13df4d3dc646): on the first EXECUTE the driver logged "ane_t6021 508000000.ane: CPUs 12-17 (cpufreq policy12) held up while requests run", policy12 scaling_min_freq/scaling_cur_freq rose from 300000 kHz before EXECUTE to 4608000 kHz during EXECUTE and returned to 300000 kHz after idle release, with 0 ANE errors, 0 CLPC/PMC errors, 0 SELinux denials, 0 failed units, and 0 new kernel errors. Median unet-320 latency on the tip stack is unchanged around ~2.5-2.65 ms; in a separate baseline-kernel measurement with an earlier cluster-hold implementation where per-inference latency was sub-millisecond, holding the cluster reduced unet-320 median from 912.7 us to 550.7 us. Signed-off-by: Satya Benson <satya@benson.earth>
Name the cpufreq_pc cluster in the ANE node's performance-domains, so the driver holds it up while requests run. Signed-off-by: Satya Benson <satya@benson.earth>
satchlj
force-pushed
the
satchlj/ane-cluster-hold
branch
from
November 23, 2026 19:42
21e182a to
a1c9e7b
Compare
5 tasks done
DjDeveloperr
requested changes
Nov 23, 2026
DjDeveloperr
left a comment
Contributor
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at a1c9e7bfcbff9561ace139eb0db107c2eeb301ca (REQUEST_CHANGES).
What passes
- Buildability & DT schema:
W=1arm64 builds (CONFIG_DRM_ACCEL_ANE=y,=m, andCONFIG_CPU_FREQ=n) verified by author; live CIdt-checksandhost-testsare green; OF node refcounting inane_cluster_hold_attach()(of_parse_phandle_with_args,of_cpu_device_node_get) and init/fini error unwinds inane_fw_cold.candane_h16_backend.care clean; non-J775c nodes withoutperformance-domainstake the no-op path. - §4 & §6 (Clean-room, attribution, naming): All 3 commits (
d9087e4df56a,8cd431751654,a1c9e7bfcbff) carry human author/committer (Satya Benson <satya@benson.earth>) and humanSigned-off-by:only (zero AI trailers); PR body carriesAssisted-by:; clean naming.
Blockers
- Suspend race / stuck cluster hold & PM QoS (
ane_fw_pm_event()&ane_h16_pm_event()):- Both
ane_fw_pm_event()(ane_fw_cold.c) andane_h16_pm_event()(ane_h16_backend.c) callane_cluster_hold_drop(&...->hold)beforeane_fw_sleep_prepare()/ane_h16_sleep_prepare()callsane_h16_session_sleep(..., true)to quiesce in-flight and incomingEXECUTErequests. ane_cluster_hold_drop()'s own contract requires "with requests stopped" (and it clearsh->want = falsewithout clearingh->busy). Because requests are NOT stopped yet, an in-flightEXECUTEfinishing or a newEXECUTEstarting on an unparked engine betweenane_cluster_hold_drop()andane_h16_session_sleep(..., true)will callane_cluster_hold_busy()and re-queueapply/release, allowing the system to enter sleep withFREQ_QOS_MINpinned atmax_freqandDEV_PM_QOS_RESUME_LATENCY = 0active.- In addition,
ane_h16_pm_event()drops the hold even on platforms without a sleep path (!sleep_warm && !sleep_cold) right before refusing suspend while requests may still run; and despite the PR body claimingPM_HIBERNATION_PREPAREhandling, neither notifier callsane_cluster_hold_drop()onPM_HIBERNATION_PREPARE.
- Both
- Missing
CPUFREQ_REMOVE_POLICYhandling & silentfreq_qoserror state drift (ane_cluster_hold.c):ane_cluster_hold_attach()takespolicy = cpufreq_cpu_get(cpu), stores it permanently inh->policy, and addsfreq_qos_add_request(&policy->constraints, &h->freq, ...)without registering aCPUFREQ_POLICY_NOTIFIERforCPUFREQ_REMOVE_POLICY. Compareapple_clpc_policy_notify()indrivers/soc/apple/clpc.c: if the cpufreq driver module unloads or a cluster policy is torn down,h->freqis never withdrawn andh->policystays pinned/stale until reboot (since pinned ANE backends never runfini).- In
ane_cluster_hold_apply(), iffreq_qos_update_request()returns< 0,WRITE_ONCE(h->held, want)still flips unconditionally, leavingh->heldout of sync with the actual QoS request (so a failed drop would never be retried).
- Architectural duplication & policy conflict with
drivers/soc/apple/clpc.c(#3009 / #2856):apple-clpcalready implements the ANE CPU cluster frequency floor (apple_clpc_ane_cluster(), active on T6040 in tree, extended to T8142 in #3009, and being made DT-driven viaapple,ane-cpu-oppin #2856) driven by the sameapple_clpc_ane_set_active()hook.#3006introduces a second, parallelfreq_qosmechanism and a competing DT binding (performance-domainsonapple,ane) that unconditionally pinsFREQ_QOS_MINatpolicy->cpuinfo.max_freqrather than a measured knee OPP (for example, on T8142 #3009 measured4176 MHz/4.49 Was the knee vs4464 MHz/5.31 Wwith no speedup; on T8132 #2856 measured2616 MHzvs4.1 GHz). If both CLPC and#3006are ever active on the same SoC,#3006'smax_freqvote silently overrides CLPC's power-optimal knee OPP and adds mismatched hold windows (32 msvs100 ms).- Please converge on a single mechanism/DT binding (e.g. extending CLPC's DT-driven
apple,ane-cpu-oppfrom #2856 to T6050) rather than carrying two parallel ANE cluster-hold implementations, unless hardware A/B provesDEV_PM_QOS_RESUME_LATENCY = 0is strictly necessary on a board with deep cpuidle states.
- §1 Single-board DT gating (Patch 3):
- Patch 3 adds
performance-domains = <&cpufreq_pc>only toarch/arm64/boot/dts/apple/t6050-j775c.dtsinstead of the shared T6050 DTSI (t6050-peripherals.dtsi/t6050-max.dtsi), even thoughcpufreq_pcandane0are common across T6050 boards (j714s,j716c,j775c, etc.).
- Patch 3 adds
- §5 Evidence & test gaps:
- On the tested PR stack (
boot_id: d34470f0-1857-40c5-aef5-13df4d3dc646),unet-320latency was unchanged (~2.50–2.66 msvs#3004alone2.55 ms; the912.7 -> 550.7 usfigure is from a separate older kernel/implementation). DEV_PM_QOS_RESUME_LATENCY = 0could not be observed/verified on J775c (WFI-onlylatency=1usstates), andPM_SUSPEND_PREPAREwas untested.ane_cluster_hold.cadds ~290 lines of concurrency/lifecycle state machine without KUnit tests. (Also note PR body cites5d911e8fe25bfor static checks rather than live heada1c9e7bfcbff.)
- On the tested PR stack (
Assisted-by: LLM (Gemini 4 Neon)
Member
Author
|
Gemini 4 Neon on @satchlj's behalf. Closing this PR to converge on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hold up the CPU cluster named by an ANE node's
performance-domainsDT property whileEXECUTErequests are in flight (plus a 100 ms idle hold), usingfreq_qos(FREQ_QOS_MINat policy max) anddev_pm_qos(DEV_PM_QOS_RESUME_LATENCY = 0).dt-bindings: npu: apple,ane: describe performance-domains— documents optionalperformance-domainsonapple,anepointing to the CPU cluster performance domain held up while requests run.accel/ane: hold up the performance-domains CPU cluster while requests run— addsdrivers/accel/ane/ane_cluster_hold.{c,h}and wires it into the H16/H17 (ane_h16_backend.c,ane_fw_cold.c) execution path:performance-domainsmatching a CPU cluster'sperformance-domainsphandle + specifier args (#performance-domain-cells0-cell and multi-cell safe). Nodes withoutperformance-domains, or pointing to a domain without CPUs, are a no-op; no SoC or board checks.ane_cluster_hold_busy()paired withWRITE_ONCE/READ_ONCE; allfreq_qos/dev_pm_qosmutations run in work items (kick/release), never in the request path.FREQ_QOS_MINcannot overrideFREQ_QOS_MAX).cancel_work_sync) onPM_SUSPEND_PREPARE/PM_HIBERNATION_PREPARE, andane_cluster_hold_fini()is a safe no-op (if (!h->ready) return;) on zero-initialized holds beforeane_cluster_hold_init().arm64: dts: apple: t6050-j775c: link the ANE to its CPU cluster— linksane0to&cpufreq_pcon J775c.Verification
Static & build checks (on exact PR tree
5d911e8fe25b)scripts/checkpatch.pl --git origin/integration/aurora..HEAD: 0 errors (only expectedMAINTAINERSnotice for new files underdrivers/accel/ane/, covered byF: drivers/accel/ane/).make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/npu/apple,ane.yaml: PASS (0 warnings, 0 errors).make dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/npu/apple,ane.yaml apple/t6050-j775c.dtb: PASS (0 warnings, 0 errors).W=1arm64 compile withCONFIG_DRM_ACCEL_ANE=y: PASS (0 warnings, 0 errors).W=1arm64 compile withCONFIG_DRM_ACCEL_ANE=m: PASS (0 warnings, 0 errors).W=1arm64 compile withCONFIG_CPU_FREQ=n+CONFIG_DRM_ACCEL_ANE=y: PASS (0 warnings, 0 errors).Hardware test on J775c (Mac Studio M5 Max, T6050) — final driver code
cand-16b+#3003+#3004(c8d987803624, boot-default.ane = { 6, 2 }, no debugfs override) + exact final#3006driver (ane_cluster_hold.csha256:eac0efce...,ane_cluster_hold.hsha256:e88ae278...) withane@508000000performance-domains = <&cpufreq_pc0>in the carry DTB.7.3.0-lobata-cand+ #3 SMP PREEMPT Mon Nov 23 14:38:22 EST 2026,build-id: 44ecd8f1a0edae7c7ecda9d2f9189c1fbbcac2c5,boot_id: d34470f0-1857-40c5-aef5-13df4d3dc646,Image.gzsha256:1f1f0880301a414a5bca7e8c523e12b15972c4013394257fc6ffb51b0b093d28,t6050-j775c.dtbsha256:0442bec28ef4c650d4e3395589f7001808c7e5b4a3bdd4971fc466d68f9de0ed.dmesgattach:/proc/device-tree/soc/ane@508000000/performance-domains = 0x00000008resolved topolicy12(CPUs 12-17,min=300000,max=4608000,gov=schedutil).[ 11.611878] ane_t6021 508000000.ane: CPUs 12-17 (cpufreq policy12) held up while requests runpolicy12scaling_cur_freq/scaling_min_freq& cpuidle):EXECUTE:cur=300000 min=300000.unet-320200 runs, p502658.2 µs, p902675.5 µs, p992686.1 µs, mean2641.6 µs;add64p50170.9 µs):EXECUTE(20 samples @ 40 ms):15× (4608000, 4608000),3× (300000, 300000),1× (1620000, 300000),1× (2292000, 300000).cpuidledeltas across CPUs 12–17 (WFI-only states,latency=1us):state0 +usage=309 +time=3800238us,state1 +usage=343 +time=1038263us.cur=300000 min=300000.unet-320200 runs, p502498.3 µs, p902520.3 µs, p992540.0 µs, mean2499.3 µs;add64p50175.0 µs):EXECUTE(20 samples @ 40 ms):14× (4608000, 4608000),5× (300000, 300000),1× (2880000, 300000).cpuidledeltas across CPUs 12–17:state0 +usage=8186 +time=3560433us,state1 +usage=130 +time=538813us.cur=300000 min=300000.finite True, max|ref| 2.512, max abs err 0.0035, mean abs err 0.00042, rel 0.0014.unet-320latency on the tip stack is unchanged around ~2.5–2.65 ms; in a separate baseline-kernel measurement with an earlier cluster-hold implementation where per-inference latency was sub-millisecond, holding the cluster reducedunet-320median from912.7 µsto550.7 µs.0 ANE errors,0 CLPC/PMC errors,0 SELinux AVC denials,0 failed systemd units,0 new kernel errors(same 3 pre-existingcand-16blines injournalctl -b -k -p err: 1snd-soc-macaudiosafety-disable + 2apple-dcplines). Clean warm handback to known-good default kernel verified (f463db85-87c5-4e1e-b21a-fba02ad1d72f,marker: spent, both ESPs clean).Not tested
performance-domains, so the driver takes the no-op path;=y/=m/!CONFIG_CPU_FREQcompile paths verified).cand-16b+#3003+#3004+ this series becauseintegration/auroratip does not yet carry the full J775c boot stack standalone (patch 3t6050-j775c.dtsis verified bydtbs_check; the carry DTB uses the sameperformance-domainslink onane@508000000).PM_SUSPEND_PREPARErelease path) was not exercised on J775c in this row (S2R is not yet enabled on J775c).state0/state1withlatency=1us), soDEV_PM_QOS_RESUME_LATENCY = 0suppression of deep power-down states is not observable on this board.Assisted-by: LLM (Anthropic:Claude Opus 5.5)
Assisted-by: LLM (Google:Gemini 4 Neon)