Skip to content

accel/ane: run the Neural Engine on T6041/J616c - #920

Merged
RyanTheTide merged 13 commits into
aurora-silicon:integration/aurorafrom
astaff:t6041/j616c-ane-h16
Nov 5, 2026
Merged

RyanTheTide merged 13 commits into
aurora-silicon:integration/aurorafrom
astaff:t6041/j616c-ane-h16

Conversation

@astaff

@astaff astaff commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

The M4 Max's Neural Engine is the same H16 as the M4 Pro's, at the same addresses. J616c only needs the firmware reservations and alias to use the merged driver.

What

  • t6041-j616c: as on J616s, add the two firmware reservations the boot loader fills, and the ane alias. The nodes stay disabled here.

Stacked on #525. The driver changes this device needs are in #950.

Testing

Kernel is the same merge as #525's proof, with a local boot loader that fills and enables the ANE nodes. conv3x3 output equals the macOS reference over 200 runs, with 0 faults.

Limits

  • Needs the boot-loader handoff that fills and enables the ANE nodes.
  • Long-run reliability and the MobileNet selftest are not measured.
  • The SoC rail floor J616s uses isn't enabled on J616c. Enabling it reset the machine at boot; the cause isn't confirmed.

🤖 Generated with Claude Code

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is in good shape. Each driver commit is small, explains its measurement and comes with KUnit coverage (ANE boot and transport suites 205/205 here, up from 201).

Notes on the commits:

  • Terminal ring (6339bbf). Draining channel 0 is clearly right, since macOS and H14 serve it, and the type-2 check keeps it inert elsewhere. It also runs on the M4 Pro, so we tested it there across 21 boots: ANE startup completes as before, and our known M4 Pro startup stall is unchanged (2 of 20 against a 15% base rate). So it isn't a regression, and not that fix either.
  • iommu_map_sgtable() (dcda6e4). Looks correct. The 16 KiB blocks are IOMMU-page aligned, and a failed iommu_map_sgtable() has already unmapped its partial work. Can you confirm m->mapped always equals size now, and that the unmap path doesn't rely on per-block granularity?
  • dfd158b, b3d1cca, 021c9b6 are fine.

Required fixes

  1. Signed-off-by (hard blocker). None of the 6 commits has a Signed-off-by:. Please add yours after Assisted-by: LLM (git rebase --signoff).
  2. Split from PR 525. The branch carries all 14 commits of #525 underneath, but only the last commit (the J616c ANE DT, 9144639) needs it. Please put the five accel/ane driver commits in their own PR based directly on integration/aurora. They help the M4 Pro too and don't need to wait for 525. The DT commit can follow once 525 lands.
  3. Benchmark for the perf claim. dcda6e4 says twenty program maps go from about 10.3 ms to 2.0 ms. Please post the command you measured with, so we can reproduce it on the M4 Pro. Perf changes need a repeatable benchmark here.

astaff added 13 commits November 4, 2026 20:52
Reuse the existing SoC and PMGR descriptions as the shared T604x base.
Keep the M4 Pro DRAM class in t6040.dtsi on top of it. The J614s and
J616s compiled trees keep every node and property unchanged.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Describe the Max CPU, OPP and register-window differences on the shared
base. Preserve the qualified J616c node and property values.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Move identical register-window constructors into a family helper.
The T6040 and T6041 initialization-data checks retain their exact values.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Select a static 25F84 profile and admit the normalized loaded image
measured in three qualification boots. Remove exploratory overrides
and unknown-image admission from the support path.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Accept 26.5.2 firmware on the T6041 display controllers and add
headerless powerlog parsing.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
A DCP commit signals flip_done from its swap completion, after the rest
of the commit tail has run. drm_atomic_helper_commit_tail_rpm() waits
with drm_atomic_helper_wait_for_vblanks(), but appledrm never calls
drm_vblank_init(), so drm_crtc_vblank_get() fails and that wait returns
at once. A blocking commit therefore returned before flip_done, and
drm_atomic_helper_setup_commit() refuses a nonblocking commit on the
same plane until flip_done. A page flip right after drmModeSetCrtc()
failed with -EBUSY ("busy with a previous commit"), which is what
glmark2-es2-drm hit on the J616c.

Wait with drm_atomic_helper_wait_for_flip_done() instead. The rest is
the sequence of drm_atomic_helper_commit_tail_rpm(), in its order. That
helper makes no runtime PM calls: its name stands for enabling CRTCs
before committing active planes, and this keeps that.

The change is not scoped to the J616c. Neither the empty vblank wait
nor the -EBUSY check depends on the SoC, so a per-machine tail would
only leave the race on the others. On every appledrm machine:

- A blocking commit returns after the swap completes and holds its
  modeset locks until then.
- A nonblocking commit's worker finishes later. The next commit was
  already held back by flip_done, so the flip rate does not change.
- Nothing waits when flip_done is complete early: CRTCs that stay off,
  legacy cursor updates, and the T8132 backend, which sends the event
  from its flush.
- A lost event costs 10 s and an error in the commit that lost it. The
  next commit's dependency wait already has the same bound, so this
  adds no new hang.

Framebuffer lifetime does not depend on this wait: displaced scanout is
already retained until its swap completes.

Seen and tested on the J616c only.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Patching the AOP boot arguments read and rewrote the whole table with
memcpy_fromio() and memcpy_toio(), which choose their access widths from
alignment and length and write back every byte.

Add an AopHwConfig setting for explicit access: read the table in
aligned 32-bit words, rounded out to word boundaries so that
neighbouring bytes are kept, write only the words that changed and read
each one back.

This was chosen for the J616c bring-up so that the first accesses to its
AOP SRAM had a known width. It does not fix an observed fault: the bulk
copy was not run on that machine.

The setting is on in HW_CFG_T6040, so it is not J616c-only. t604x.dtsi
gives the J614s, J616s and J616c the one apple,t6041-aop compatible, and
HW_CFG_T8132 (J713) is a copy of HW_CFG_T6040. Scoping it to the T6041
would take a second compatible, which changes the T6040 device trees, or
a machine check.

On those machines the values written do not change. The access width
does, and there are new ways to fail the probe: -EIO when a word does
not read back, and -EINVAL for an empty table or one whose rounded end
passes the window. Every other SoC keeps the bulk copy.

Synthetic MMIO checks cover malformed tables, bounds and failed
readback. Run on the J616c only.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Describe the six amplifiers and headphone jack in the J616c board DT.

Stop playback when the speaker protection lease is lost on SN012776
cards fed by the AOP. Until now a lost lease only clamped the amp gains,
and the stream kept running with its protection daemon gone or stuck in
a stalled sense capture. The clamp stays; the stream now also goes to
XRUN, so its client sees the loss.

This is shared macaudio code and it is stricter than before. It applies
to the J616c, the J616s and the J713. The J614s uses the same condition
but binds no speaker link, so it has no lease and never gets here.
Narrowing this to the J616c would give machines with the same amps and
the same AOP path different protection, and would take a new match entry
for it.

The stop covers every playback stream of the speaker card, which on
these machines carries only the speaker stream. The headphone jack is a
card of its own and keeps playing. It is a stop, not a refusal: a client
that prepares again plays at the clamped gain until the lease returns.

It fires only when the speakers go from unlocked to locked, so not at
boot, and not for the kernel's own lock across system sleep, where ASoC
suspends the streams itself. A daemon that exits cleanly also loses the
lease. Other amps and non-AOP SN012776 cards behave as before, and the
MAX98360A path still stops only its software-gain streams.

Lease loss was tested on the J616c only.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
The T6041 AVD shares its "apple,t6041-avd" compatible with T6040, which
holds HEVC back until the firmware lists it. Give the T6041 node a more
specific compatible and a variant that holds nothing back, so HEVC is
also available on firmware that publishes no codec list. A firmware
that does publish one still limits the set.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Build the production initialization objects with their soft-float types
and compare constants with explicit capture inputs. Keep T6040 per-chip
calibration validation separate; include no captures or local defaults.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
m1n1 compares DT CPUs with its physical MPIDR enumeration. Appending the Max cores to the Pro topology put CPU 9 out of order and stopped boot before kernel entry.

Define the full family topology in hardware order and remove the extra cores from T6040. Check the compiled DTB order for both SoCs.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
macOS on J616c writes 0x1c890 = 1 and 0x1c918 = 0 for its tiling passes,
where the shared firmware profiles write 0x200440 and 4. Do the same in
T6041's 25F84 build and leave the shared profiles unchanged. 0x1c9a8
stays at the shared 0x3c; macOS writes 0x5c here.

This does not fix the 25F84 reason-0 restarts under concurrent rendering.
They still occurred with these values on an earlier base, also with
0x1c9a8 = 0x5c.

Ran on J616c with 25F84, with PRs 732, 749 and 920 and Mesa ca90d8c1919,
serial rendering off and the firmware log on: three boots of niri, DMS
and 20 Whisper runs each, with no GPU recovery. Add KUnit coverage for
the policy boundary and constructor output.

Link: aurora-silicon#525 (comment)
Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>
As on J616s, add the two firmware reservations the boot loader fills
from this boot's ADT, and the ane alias. J616c's loader also enables
the nodes it fills, so they stay disabled here.

Assisted-by: LLM
Signed-off-by: Artyom Astafurov <artyom.astafurov@gmail.com>

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting the driver side into #950, that one is merged already. This is just the J616c DT now and it matches the J616s layout, with the nodes disabled until the loader fills them. dtbs_check on the J616c DTB shows only the ANE property warnings the J616s already has. Merging!

@RyanTheTide
RyanTheTide merged commit 3331309 into aurora-silicon:integration/aurora Nov 5, 2026
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