Skip to content

Neo ANE: hold DRAM and fabric floors while the engine runs, keep gating off back-to-back (MobileNet 2.3-2.5 -> 1.25-1.31 ms) - #1137

Merged
RyanTheTide merged 4 commits into
integration/aurorafrom
anex/neo-ane-floor
Nov 7, 2026
Merged

RyanTheTide merged 4 commits into
integration/aurorafrom
anex/neo-ane-floor

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What

The Neo's Neural Engine (T8140, H17) ran MobileNetV1 at 2.2-2.5 ms per request, while the M4 Pro ANE runs the same kind of program in 0.57 ms. Most of that time is spent waiting on memory: nothing raises the DRAM controller (DCS) or the SoC fabric while the ANE runs, because the CLPC only follows CPU and GPU load. Busy CPUs made the ANE faster, which is how this showed up.

Four commits:

  1. accel/ane: h17: keep dynamic power gating off across back-to-back requests. H16 got this in fedd276. H17 still sent the gate command before and after every EXECUTE. With the same 2 ms hold, back-to-back requests skip both commands (gate open 42-66 us and gate close 24-27 us become 0.1 and 0.0 us).
  2. soc: apple: clpc: raise DRAM and fabric floors for ANE work. Adds an ANE input to the CLPC next to the host GPU input. A driver gets a client with apple_clpc_ane_get() and reports work in flight with apple_clpc_ane_set_active(). An idle-to-active edge samples at once, and a request shorter than the sampling period is latched until the next sample. The per-SoC rail states then merge with CPU and GPU demand under the usual hold. T8140 asks for DCS 4 and fabric 3, the same floor the GPU gets for streaming work. Other SoCs have no ANE input. The client never defers, so without a CLPC the ANE runs as before. A root-only debugfs file, ane_states, overrides the states for measurements.
  3. accel/ane: h17: hold the CLPC memory floor while an EXECUTE runs. The H17 backend reports each EXECUTE through the existing session busy hook.
  4. tools/asahi: cover the CLPC ANE input in the host demand test. The CLPC host test compiles the driver's sample path, which now calls the ANE helper. It now also checks that T8140 ANE work votes 0x34 with reason 32, that a request shorter than one sample is still seen once, and that the vote expires after the hold. It also adds an omit-ane-demand negative control.

H16 (J616s) is not changed. It already holds the PMC soc-max floor per request through its perf power domain. H17 cannot take a second power domain without reworking how its loader hand-off binds, so it uses the CLPC.

Benchmark (Neo, J700)

Method: MobileNetV1 224 (kit-ss1-neo program, one linked 28-task H17 program), ane-run.py with 300 EXECUTEs per run. Times are host p50/p90 around the EXECUTE ioctl, plus the driver's debugfs ane-h17/.../execute phase means. The runs are interleaved A/B/C, three rounds, on one boot, switching the CLPC ANE states between runs through ane_states.

Test kernel 7.3.0-aurora-fleet23anex2 = fleet23 (810b92c) + this series + two unrelated fixes (T604x pmgr, H13 perf). One-shot boot 5c56c6e8, silent, 11-08 00:20.

ane_states round p50 us p90 us engine (report->done) us submit->ack us
0 0 (no floor) 1 / 2 / 3 2500.2 / 2313.7 / 2317.2 2572.9 / 2376.6 / 2381.0 2016 / 1806 / 1841 187 / 176 / 170
4 0 (DCS only) 1 / 2 / 3 1780.6 / 1840.6 / 1776.3 1898.8 / 1960.2 / 1964.2 1567 / 1531 / 1544 145 / 154 / 152
4 3 (default) 1 / 2 / 3 1305.0 / 1274.1 / 1254.6 1496.5 / 1494.1 / 1511.3 1032 / 1013 / 1016 100 / 99 / 98

Single cold requests (one EXECUTE per process, 8 runs) with the default states: engine time 940-1058 us, so the latch also catches one-off requests.

Gate hold, same boot: gate open 0.1 us and gate close 0.0 us per request. On fleet23 (boot f955b7be, same kit) they were 42-66 us and 24-27 us.

Earlier cross-check on fleet22 (boot fc023511): holding the PMC DCS floor some other way (AP agent 3 = 0x4 through the ProRes perf consumer) gave p50 2241-2374 us without the floor and 1287-1462 us with it.

Gates

  • KUnit x86_64: CLPC suite 9/9 on the final head, ANE boot 213/213, ANE transport 213/213.
  • W=1 clang arm64: 0 new warnings in drivers/soc/apple and drivers/accel/ane.
  • Host tests: run-host-tests.py --only clpc passes, and all 10 negative controls fail as they should (omit-ane-demand included). --only ane passes 3/3.
  • checkpatch --strict: 0/0/0 on all four commits.
  • Neo test boot: ANE up, top-1 correct, no new error lines, SELinux enforcing. The default was restored and the test kernel removed afterwards.

🤖 Generated with Claude Code

…uests

The H17 path still sends 0x002d 0 before and 0x002d 1 after every
EXECUTE. On the Neo (T8140) that costs 68-78 us of each MobileNet
request (gate open 43-52 us, gate close 20-26 us, debugfs means over
300-3400 requests on fleet22), out of 2.2 ms.

The session hold that commit fedd276 ("accel/ane: h16: keep dynamic
power gating off across back-to-back requests") added for H16 is
generic: gating goes back on 2 ms after the last request ended, before
TERMINATE and UNLOAD and before system sleep, and a firmware booted
again from the preload starts with gating on. Set the same 2 ms hold
for the H17 backend.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
On the Neo (T8140) nothing raises the memory controller (DCS) or the SoC
fabric while the Neural Engine runs: the CLPC only follows CPU and GPU
load. A MobileNetV1 EXECUTE then takes 2.3-2.5 ms. With DCS 4 and fabric
3, the floor the GPU already gets for streaming work, it takes
1.25-1.31 ms; the engine time drops from 1.8-2.0 ms to about 1.0 ms.

Add an ANE input next to the host GPU one. A driver gets a client with
apple_clpc_ane_get() and reports work in flight with
apple_clpc_ane_set_active(). The client has its own reference, so a late
publication or put after the CLPC went away is harmless, and getting it
never defers: without a bound CLPC the ANE runs without the floor. An
idle-to-active edge samples at once, a request shorter than the sampling
period is latched until the next sample, and the per-SoC ANE rail states
then merge with the CPU and GPU demand under the usual hold.

T8140 asks for DCS 4 and fabric 3. Other SoCs have no ANE input. A
root-only debugfs file, ane_states, overrides the two states (clamped
to each rail) for measurements, and the status file reports the ANE
input and reason bit 32.

KUnit covers demand and hold, short requests, provider removal, cold
wake, a missing provider and the state overrides.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Get the CLPC ANE client at the program stage and report each EXECUTE
through the session's busy hook, so the CLPC raises DRAM and the SoC
fabric while the H17 engine works. Without a CLPC nothing changes.

On the Neo this takes MobileNetV1 from 2.31-2.50 ms to 1.25-1.31 ms per
EXECUTE (300 requests, three rounds, ane_states 0 0 against 4 3).

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
The CLPC host test compiles the driver's sample path from clpc.c, which
now also calls apple_clpc_ane_input_demand(). Extract that helper too,
stub its client and lock, and check that T8140 ANE work votes DRAM 4 and
fabric 3 (0x34) with reason bit 32, that a request shorter than one
sample is still seen once, and that the vote expires after the hold.
A new negative control drops the ANE demand and must fail.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
@RyanTheTide
RyanTheTide merged commit 1eac5fa into integration/aurora Nov 7, 2026
3 checks passed
@RyanTheTide
RyanTheTide deleted the anex/neo-ane-floor branch November 7, 2026 14:23
RyanTheTide added a commit that referenced this pull request Nov 7, 2026
Brings aurora-wip up to fleet25: DT descriptions (#1029, #1030, #1112),
the J715 board (#1129), Stockholm NFC (#1042, #1136), the AV1 tile check
(#1100), the M4 Max ANE profile and AVD quirk (#1088, #1091), boot-log
fixes (#1103, #1104) and the Neo ANE memory floor (#1137).

Conflicts: macaudio.c and apple,macaudio.yaml, where aurora-wip's J813
and J873 entries and integration's J715 entries were added at the same
spot. Keep all of them.

Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
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.

1 participant