Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
aa6da17
accel/ane: stage cold-acquired H17 on the shared firmware transport
RyanTheTide Oct 31, 2026
16ae2f0
dt-bindings: npu: apple,ane: describe the T8140 cold-direct resources
RyanTheTide Oct 31, 2026
1b8cf64
arm64: dts: apple: describe disabled T8140 cold ANE and a lead test DTB
RyanTheTide Oct 31, 2026
cbfd370
accel/ane: serialize staged acquisition against system sleep
RyanTheTide Oct 31, 2026
513920c
accel/ane: fence a second H17 LOAD at transport publication
RyanTheTide Oct 31, 2026
331b6ba
accel/ane: align the second-LOAD KUnit assertions
RyanTheTide Oct 31, 2026
6e5627c
accel/ane: include platform and OF DMA declarations
RyanTheTide Oct 31, 2026
8ebdf63
dt-bindings: npu: apple,ane: complete the T8140 example
RyanTheTide Oct 31, 2026
7db7c75
accel/ane: queue the first H17 EXECUTE after a program change
RyanTheTide Nov 1, 2026
db17550
Merge H17 cold acquisition and switch requeue into the H17 clean branch
RyanTheTide Nov 1, 2026
6f55ede
accel/ane: run H17 HWX programs through the clean ABI 3 path
RyanTheTide Nov 1, 2026
b71c22e
accel/ane: read the H17 engine only after it is powered
RyanTheTide Nov 1, 2026
5c9870f
selftests: drivers/ane: add a generic ABI 3 runner
RyanTheTide Nov 1, 2026
d76b818
accel/ane: log the H17 DART stream enables in the cold snapshot
RyanTheTide Nov 1, 2026
e846e44
accel/ane: do not judge DART stream enables in the H17 cold check
RyanTheTide Nov 1, 2026
0e31762
accel/ane: mark the ANE accel node as using unsigned file offsets
RyanTheTide Nov 1, 2026
bab7578
Merge ane/h16-latency ee818558 into ane/h17-clean
RyanTheTide Nov 1, 2026
7fcd579
accel/ane: map the H17 firmware heap tail before boot
RyanTheTide Nov 1, 2026
d5ac14e
accel/ane: mark the shared H16 boot tables as maybe unused
RyanTheTide Nov 1, 2026
0048177
accel/ane: send no custom BAR record on H17
RyanTheTide Nov 1, 2026
7da7f19
accel/ane: describe each EXECUTE buffer with its declared size
RyanTheTide Nov 1, 2026
94c72b4
accel/ane: keep the H16 EXECUTE section sizes
RyanTheTide Nov 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions Documentation/accel/apple-ane-cold.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
.. SPDX-License-Identifier: GPL-2.0-only OR MIT

Cold-acquired H17 firmware backend
=================================

This experimental backend shares the H16/H17 channel transport, LOAD and
EXECUTE wire formats and UUID completion helpers. It does not take over a
running Exclave engine. Production T8140 nodes remain disabled. The separate
``t8140-j700-ane-test.dtb`` enables only the lead's one-shot test.

The staged observer is installed before platform driver registration. This
avoids the platform bus's automatic genpd power-on and default DMA attachment
before the read-only probe. The existing H14 ABI is never exposed for H17.
Build ``CONFIG_DRM_ACCEL_ANE=y`` and ``CONFIG_APPLE_DART=y`` for acquisition;
an ANE module supports observation only because the kexec blocker requires a
built-in caller. No module parameter opens this backend.

Loader contract
---------------

The loader must publish ``/chosen/apple,ane-cold-boot`` with the exact string
``raw-no-xnu-ane-untouched-v1`` only when the reset path ran no XNU, SPTM,
ExclaveCore or other ANE owner and left the engine untouched. This is boot
evidence, not an operator opt-in. Neither the production nor test DTS supplies
it. A warm handoff, kexec, unknown loader or missing evidence must refuse.

The loader also supplies two ``no-map``, non-reusable reserved-memory nodes,
referenced by ``memory-region`` and named ``firmware-text`` and
``firmware-data``. Their sizes are 0xc0000 and 0x2ac000. Physical addresses
come from that boot's preload records, never from compiled-in lab addresses.
The DVA pair is 0x10000000000 and 0x100000c0000.

TEXT must match the measured 26.6.2 H17 SHA-256 pin in the driver. The loader's
``apple,preload-data-sha256`` is a digest of the full live DATA segment. The
driver copies both reserved segments into private coherent RAM and preserves
every iBoot-written DATA byte. The DATA digest establishes preservation of the
loader's supplied segment; it is not a cross-build immutable-DATA manifest.
A pinned manifest excluding only the individually documented mutable fields
remains required before production enablement. No firmware image is shipped.

Stages and recovery
-------------------

Use the platform device's root-writable ``firmware_stage`` attribute. Reading
it reports ``unverified``, ``probe``, ``map``, ``boot``, ``startup``,
``program`` or ``quarantined``. Write these actions in order::

echo probe > firmware_stage
echo map > firmware_stage
echo boot > firmware_stage
echo startup > firmware_stage
echo program > firmware_stage

The engine block and its DARTs sit behind ANE_SYS, and an access to them
while it is off stalls the bus. ANE_SYS is no cold marker: it can read on
while genpd reports off, and generic DART runtime PM or a refused platform
probe turns it off again. Every register is therefore read only once its
block is known to be powered, in the order the U2 runs measured as safe.

``probe`` reads only PMGR: ANE_SYS, the ANE CPU power state (low byte off)
and the sub-block power state (0x300). With the loader's raw-boot evidence it
moves to ``probe``; it writes nothing and never touches the engine or DARTs.

``map`` repeats the PMGR check, then retains the module and power lifetime,
blocks system sleep (and kexec when built in) and acquires genpd ANE_SYS. It
reads PWGATE (request 3, acknowledge 0), turns the CPU power state on, clears
the PWGATE request and turns the sub-block on. Only then does it read and
check the engine and DARTs: CE state and error, CPU control (0) and status
(0x6a), RVBAR, IRQ pending, scratch, and unlocked, unfaulted DARTs of version
0x203 with no stream enabled. DAPF records and invalid TTBR payloads are
logged, never used as cold markers. Nothing in the engine has been written at
that point; a failed check quarantines with power retained. ``map`` then
completes CE, attaches only SID0 on three DARTs to the private paging domain,
writes and reads back the four DT-provided DAPF ranges, maps their pages as
identity MMIO, and maps preloads, command pool, IPC and heap at their
documented DVAs.

``boot`` runs the scratch handshake, checks the exact request sizes, validates
all eight channel descriptors and arms host rings. ``startup`` sends only
PRINT_ENABLE, START, CONFIG_GET and RESOURCE_INFO_GET, servicing shared
allocations with an absolute deadline. Completion is polled. Neither IRQ 655
nor IRQ 668 is registered or enabled. Secure-mode commands 0x27, 0x28, 0x34
and Exclave commands 0x30, 0x31 are denied at the publication boundary. 0x2f
is shared-event initialization, not an Exclave command, and is not sent.

Any failure after acquisition, including a normal map synchronization timeout,
quarantines the device, retains mappings and power and requires a reboot.
There is no in-place reset or retry. Suspend is refused while retained.
The ANE DART profile also refuses generic suspend/resume and never resets
foreign streams. Rollback is an ordinary reboot to the saved production
entry, never module unload after acquisition.

Program integration and measured limits
--------------------------------------

``program`` creates the shared H16/H17 program session on this transport and
registers the ABI 3 accel node (``DRM_ANE_CHIP_H17``). Userspace passes the
original H17 HWX and its four host-built sections, as on H16; the kernel
validates them, places every section in private mappings, binds a linked
program's ``__DATA`` scratch to kernel-owned memory and runs the
0x2d/EXECUTE/0x2d sequence with UUID completion. Operation records with a
kernel table must bind the kernel BAR to resource index 1007; legacy tag 2 is
refused before LOAD because the measured H17 firmware asserts on it. The
firmware frees each process pool after UNLOAD, often only during a later
program; that FREE is acknowledged and its backing retained until reboot.

Several programs may run in one firmware boot. The firmware has a direct
submission path that reuses the engine's current BAR context. If that context
belongs to a different program, a job can write through the earlier program's
output binding. This happens even after that program was terminated and
unloaded, and a full TLB invalidation does not prevent it. Bit 0 of the
EXECUTE flags word at offset 0x30 keeps a request off the direct path and
queues it for the full execution loop, which installs a fresh BAR context.
The transport sets that bit in its copy of the first EXECUTE after any change
of program or process, and after any LOAD, CREATE, TERMINATE or UNLOAD, since
firmware IDs may be reused. Later jobs of the same process keep the direct
path. Measured on the J700 with 11 of 11 program switches correct, at about
60 us extra on the switching job only. H16 shares the firmware design but has
not executed under Linux, so its requests are published unchanged. Output
mappings of earlier programs stay pinned and are never reused.
The observed FREE response is DVA|1 with zero length and handle. It is
accepted for any live exact allocation once the program stage started, since
the firmware frees a process pool after UNLOAD, often only during a later
program. Its backing and quota stay pinned and are never recycled, so the
12 MiB allocation quota bounds the program lifetimes of one firmware boot
(each process pool is 2 MiB). Duplicate, interior and unsolicited FREEs
refuse. The canonical FREE form remains unproven.

Provenance
----------

Register and wire facts were taken from the supplied clean H16/H17 field
specifications and the measured H17 cold-boot and harness results. No private
implementation source or firmware bytes are included. The operation-record
geometry is also documented by the MIT-licensed public ``libane/ane_m2.c``
in https://github.com/joshuaswarren/omarchy-ane. The H17 resource-index rule
overrides that older generation's kernel-tag convention.
5 changes: 4 additions & 1 deletion Documentation/accel/apple-ane.rst
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ then exercise command, geometry, tensor, aperture, symbol, relocation and
digest refusal paths. No hardware inference result is implied.

H13 timeout and engine recovery
==============================
=======================

The host task-manager path (``ane.ko``) gives each submission one second,
including DART fault-drain retries. An expired submission returns
Expand Down Expand Up @@ -897,3 +897,6 @@ teardown, the second-LOAD refusal, bad LOAD/CREATE replies, mismatched
UUIDs and IDs, and state-2 quarantine.
``tools/testing/selftests/drivers/ane/h16-run.py`` loads the pinned add-128
HWX, runs it twice with poisoned output and compares with ``expected.bin``.
=======
For the experimental T8140 cold AP-direct stages and their ownership and
loader requirements, see :doc:`apple-ane-cold`.
4 changes: 4 additions & 0 deletions Documentation/devicetree/bindings/iommu/apple,dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ properties:
- apple,t8103-usb4-dart
- apple,t8110-dart
- apple,t6000-dart
- items:
- const: apple,t8140-ane-dart
- const: apple,t8140-dart
- const: apple,t8110-dart
- items:
- enum:
- apple,t6000-dart
Expand Down
38 changes: 29 additions & 9 deletions Documentation/devicetree/bindings/npu/apple,ane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@ properties:
containing 16 KiB pages in its private domain. These are MMIO ranges,
not allocatable DMA memory or additional preload segments.

apple,dapf-ranges:
$ref: /schemas/types.yaml#/definitions/uint64-array
minItems: 8
maxItems: 8
description: Four inclusive SID0 physical MMIO start/end pairs

apple,preload-data-sha256:
$ref: /schemas/types.yaml#/definitions/uint8-array
minItems: 32
maxItems: 32
description:
Bootloader-produced digest of the live reserved DATA including all
personalized parameter bytes. This establishes preservation of that
boot's DATA, not a cross-build firmware identity. TEXT has a driver pin.

apple,ane-type:
$ref: /schemas/types.yaml#/definitions/uint32
enum: [0x110, 0x200]
Expand Down Expand Up @@ -203,19 +218,18 @@ allOf:
then:
properties:
reg:
maxItems: 6
minItems: 3
maxItems: 3
reg-names:
minItems: 1
items:
- const: engine
- const: pmgr
- const: aux-0
- const: aux-1
- const: aux-2
- const: aux-3
- const: pwgate
required:
- apple,dapf-ranges
- if:
required:
- apple,firmware-iovas
- apple,preload-data-sha256
then:
properties:
memory-region:
Expand Down Expand Up @@ -384,13 +398,19 @@ examples:

ane@400000000 {
compatible = "apple,t8140-ane";
reg = <0x4 0x0 0x0 0x2000000>;
reg-names = "engine";
reg = <0x4 0x0 0x0 0x2000000>,
<0x3 0x00700000 0x0 0x18000>,
<0x3 0x00726680 0x0 0x34>;
reg-names = "engine", "pmgr", "pwgate";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 655 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 668 IRQ_TYPE_LEVEL_HIGH>;
iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>;
power-domains = <&ps_ane_sys>;
apple,dapf-ranges = /bits/ 64 <0x321668000 0x321668003
0x30070c000 0x30070c013
0x300700290 0x300700293
0x482668000 0x482668003>;
status = "disabled";
};
};
Expand Down
2 changes: 2 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -8190,8 +8190,10 @@ L: dri-devel@lists.freedesktop.org
S: Maintained
F: Documentation/ABI/testing/sysfs-class-accel-ane
F: Documentation/ABI/testing/sysfs-driver-ane-performance
F: Documentation/accel/apple-ane-cold.rst
F: Documentation/accel/apple-ane.rst
F: Documentation/devicetree/bindings/npu/apple,ane.yaml
F: arch/arm64/boot/dts/apple/t8140-j700-ane-test.dts
F: drivers/accel/ane/
F: include/uapi/drm/ane_accel.h
F: tools/accel/ane-bench.py
Expand Down
3 changes: 3 additions & 0 deletions arch/arm64/boot/dts/apple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,6 @@ dtb-$(CONFIG_ARCH_APPLE) += t8132-j773g.dtb
dtb-$(CONFIG_ARCH_APPLE) += t8140-j700.dtb
dtb-$(CONFIG_ARCH_APPLE) += t8142-j813.dtb
dtb-$(CONFIG_ARCH_APPLE) += t8152-j873g.dtb

# Explicit cold-ANE lead test; never select as the production board DTB.
dtb-$(CONFIG_ARCH_APPLE) += t8140-j700-ane-test.dtb
21 changes: 21 additions & 0 deletions arch/arm64/boot/dts/apple/t8140-j700-ane-test.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: GPL-2.0+ OR MIT
/* One-shot lead test only. Loader reservations and cold evidence are required.
* This DTB deliberately does not manufacture either assertion.
*/
#include "t8140-j700.dts"

&ane {
status = "okay";
};

&ane_dart0 {
status = "okay";
};

&ane_dart1 {
status = "okay";
};

&ane_dart2 {
status = "okay";
};
27 changes: 18 additions & 9 deletions arch/arm64/boot/dts/apple/t8140.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -1763,48 +1763,57 @@
};

ane_dart0: iommu@401800000 {
compatible = "apple,t8140-dart", "apple,t8110-dart";
compatible = "apple,t8140-ane-dart", "apple,t8140-dart",
"apple,t8110-dart";
reg = <0x4 0x01800000 0x0 0xc000>;
#iommu-cells = <1>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 656 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_ane_sys>;
apple,dma-range = <0x100 0x0 0x300 0x0>;
status = "disabled";
};

ane_dart1: iommu@401820000 {
compatible = "apple,t8140-dart", "apple,t8110-dart";
compatible = "apple,t8140-ane-dart", "apple,t8140-dart",
"apple,t8110-dart";
reg = <0x4 0x01820000 0x0 0x20000>;
#iommu-cells = <1>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 656 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_ane_sys>;
apple,dma-range = <0x100 0x0 0x300 0x0>;
status = "disabled";
};

ane_dart2: iommu@401840000 {
compatible = "apple,t8140-dart", "apple,t8110-dart";
compatible = "apple,t8140-ane-dart", "apple,t8140-dart",
"apple,t8110-dart";
reg = <0x4 0x01840000 0x0 0x20000>;
#iommu-cells = <1>;
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 656 IRQ_TYPE_LEVEL_HIGH>;
power-domains = <&ps_ane_sys>;
apple,dma-range = <0x100 0x0 0x300 0x0>;
status = "disabled";
};

/* The T8140 firmware and child power sequence need their own backend. */
/* Cold AP-direct is staged; production nodes remain disabled. */
ane: ane@400000000 {
compatible = "apple,t8140-ane";
reg = <0x4 0x0 0x0 0x2000000>;
reg-names = "engine";
reg = <0x4 0x0 0x0 0x2000000>,
<0x3 0x00700000 0x0 0x18000>,
<0x3 0x00726680 0x0 0x34>;
reg-names = "engine", "pmgr", "pwgate";
interrupt-parent = <&aic>;
interrupts = <AIC_IRQ 655 IRQ_TYPE_LEVEL_HIGH>,
<AIC_IRQ 668 IRQ_TYPE_LEVEL_HIGH>;
iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>;
power-domains = <&ps_ane_sys>;
apple,firmware-preloaded;
apple,firmware-iovas = /bits/ 64 <0x10000000000 0x100000c0000>;
/* Inclusive SID0 identity windows from the ADT. */
apple,dapf-ranges = /bits/ 64 <0x321668000 0x321668003
0x30070c000 0x30070c013
0x300700290 0x300700293
0x482668000 0x482668003>;
status = "disabled";
};
};
Expand Down
12 changes: 7 additions & 5 deletions drivers/accel/ane/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ config DRM_ACCEL_ANE
Choose this option if you have an Apple SoC with a Neural Engine:
M1 (T8103), M1 Pro, Max and Ultra (T6000, T6001, T6002), M2
(T8112), or M2 Pro, Max and Ultra (T6020, T6021, T6022).
H16 (M4 Pro) and H17 are recognized for firmware preflight and
ownership refusal by default. A bound H16 device stays idle until
a bring-up stage is written to its debugfs control file. The last
stage, program, adds an ABI 3 accel node that loads one original
HWX program per firmware boot. H17 inference is not available.
H16 (M4 Pro) and H17 (A18 Pro) are recognized for firmware preflight
and ownership refusal by default. A bound H16 device stays idle until
a bring-up stage is written to its debugfs control file. H17 has a
staged cold-boot backend that requires loader ownership evidence and
reserved preload memory, driven from its firmware_stage sysfs file.
On both, the last stage, program, adds an ABI 3 accel node that
loads original HWX programs.

The interface exposed to userspace is described in
include/uapi/drm/ane_accel.h.
Expand Down
4 changes: 3 additions & 1 deletion drivers/accel/ane/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ obj-$(CONFIG_DRM_ACCEL_ANE_FW_KUNIT_TEST) += ane_fw_platform_test.o \
ane_fw_protocol_test.o ane_h16_tasks_test.o ane_h16_execute_test.o \
ane_fw_transport_test.o ane_h16_boot_test.o \
ane_h16_pending_test.o ane_h16_hwx_test.o ane_h16_preload_test.o \
ane_h16_program_test.o ane_h16_accel_test.o ane_t6021_lifetime_test.o
ane_h16_program_test.o ane_fw_cold_test.o ane_h16_accel_test.o \
ane_t6021_lifetime_test.o

ane-y := \
ane_drv.o \
Expand All @@ -22,6 +23,7 @@ ane_t6021-y := \
ane_fw_platform.o \
ane_h16_backend.o \
ane_h16_accel.o \
ane_fw_cold.o \
ane_t6021_rtclient_main.o \
ane_t6021_fwload.o \
ane_t6021_boot.o
Loading