From 1384151213116a4e46ae38b7c20a48435412a8d7 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 12 Nov 2026 13:22:11 +1100 Subject: [PATCH 1/9] dt-bindings: npu: apple,ane: Add the T8132 Neural Engine Extend the ANE binding for the T8132 geometry: six register windows (no aux-3), two interrupts, five DAPF records and ane-type 0x100. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Erik Bourget --- .../devicetree/bindings/npu/apple,ane.yaml | 86 +++++++++++++++++-- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/npu/apple,ane.yaml b/Documentation/devicetree/bindings/npu/apple,ane.yaml index 1383ed8cdfe18..ae2091adc3881 100644 --- a/Documentation/devicetree/bindings/npu/apple,ane.yaml +++ b/Documentation/devicetree/bindings/npu/apple,ane.yaml @@ -20,7 +20,10 @@ description: its CPU, MPM and task domains depend on the ANE system domain, and its base domain depends on the task domain. T6050 follows the T8140 model, with five DAPF ranges. Interrupt roles on T6041, T6050 and T8140 are not - yet established. + yet established. T8132 has a single H16 engine, two interrupts, six + register windows (no second-engine aux-3), and five DAPF records. Its + virtual ANE-SYS-V gate resolves to the ANE system domain; ANE-SYS-V-PMP + is a firmware notification gate with no physical PMGR power state. properties: compatible: @@ -34,6 +37,7 @@ properties: - apple,t6041-ane - apple,t6050-ane - apple,t8112-ane + - apple,t8132-ane - apple,t8140-ane - apple,t8142-ane - items: @@ -97,8 +101,8 @@ properties: description: The power states the engine needs, five on T8103, six on T6000 with ANE level control (including PMP report SRAM), eight on - T602x, seven on T8112 and one system domain on T8140. T6041 may add - a sixth, "perf", a performance floor (such as the SoC rail floor) + T602x, seven on T8112 and one system domain on T8132 and T8140. + T6041 may add a sixth, "perf", a performance floor (such as the SoC rail floor) that the driver holds only while requests are in flight. minItems: 1 maxItems: 8 @@ -120,8 +124,8 @@ properties: maxItems: 2 description: On T602x, the IOVA-only reservation of the firmware entry alias. - On T6041, T6050 and T8140, bootloader-provided physical TEXT and DATA preload - reservations in that order. Each reservation must have no-map, must + On T6041, T6050, T8132 and T8140, bootloader-provided physical TEXT + and DATA preload reservations in that order. Each reservation must have no-map, must not be reusable, and must remain reserved until reboot. Physical addresses vary per boot and must not be hard-coded in a board DTS. @@ -150,8 +154,8 @@ properties: - description: Physical start address, inclusive - description: Physical end address, inclusive description: - Four (five on T6050) DART address protection filter (DAPF) ranges, in - hardware record order. Each pair contains inclusive 64-bit physical + Four (five on T6050 and T8132) DART address protection filter (DAPF) + ranges, in hardware record order. Each pair contains inclusive 64-bit physical bounds, not a base and length. The same records apply to all three ANE DARTs. Firmware accesses these registers through identity mappings of the containing 16 KiB pages in its private domain. These are MMIO ranges, @@ -170,7 +174,7 @@ properties: apple,ane-type: $ref: /schemas/types.yaml#/definitions/uint32 - enum: [0x110, 0x200] + enum: [0x100, 0x110, 0x200] description: Firmware generation identifier supplied by the bootloader apple,firmware-preloaded: @@ -277,6 +281,7 @@ allOf: enum: - apple,t6041-ane - apple,t6050-ane + - apple,t8132-ane - apple,t8140-ane - apple,t8142-ane required: @@ -330,6 +335,35 @@ allOf: - apple,ane-type - apple,firmware-preloaded - apple,dapf-ranges + - if: + properties: + compatible: + const: apple,t8132-ane + then: + properties: + interrupts: + minItems: 2 + reg: + minItems: 6 + maxItems: 6 + reg-names: + items: + - const: engine + - const: pmgr + - const: aux-0 + - const: aux-1 + - const: aux-2 + - const: aux-4 + power-domains: + maxItems: 1 + apple,ane-type: + const: 0x100 + apple,dapf-ranges: + minItems: 5 + required: + - apple,ane-type + - apple,firmware-preloaded + - apple,dapf-ranges - if: properties: compatible: @@ -353,6 +387,7 @@ allOf: - apple,t6041-ane - apple,t6050-ane - apple,t8142-ane + - apple,t8132-ane then: properties: interrupt-names: false @@ -453,6 +488,7 @@ allOf: - apple,t8140-ane - apple,t6041-ane - apple,t6050-ane + - apple,t8132-ane - apple,t6001-ane - apple,t8142-ane else: @@ -599,3 +635,37 @@ examples: status = "disabled"; }; }; + + - | + #include + #include + + soc { + #address-cells = <2>; + #size-cells = <2>; + + ane@500000000 { + compatible = "apple,t8132-ane"; + reg = <0x5 0x00000000 0x0 0x2000000>, + <0x3 0x80700000 0x0 0x18000>, + <0x3 0x80724000 0x0 0x4000>, + <0x3 0x803c0000 0x0 0x30000>, + <0x2 0x11000000 0x0 0xff4000>, + <0x3 0x882c8000 0x0 0x4000>; + reg-names = "engine", "pmgr", "aux-0", "aux-1", "aux-2", "aux-4"; + interrupt-parent = <&aic>; + interrupts = , + ; + iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>; + power-domains = <&ps_ane_sys>; + apple,ane-type = <0x100>; + apple,firmware-preloaded; + apple,dapf-ranges = /bits/ 64 <0x48d668000 0x48d668003>, + /bits/ 64 <0x38070c000 0x38070c01b>, + /bits/ 64 <0x380700570 0x380700573>, + /bits/ 64 <0x3807273cc 0x3807273cf>, + /bits/ 64 <0x302668000 0x302668003>; + apple,firmware-iovas = /bits/ 64 <0x10000000000 0x100000c0000>; + status = "disabled"; + }; + }; From 6f13d78ef2248c9f6e73d936c6fa2d1d849aa03a Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 12 Nov 2026 13:22:11 +1100 Subject: [PATCH 2/9] arm64: dts: apple: Describe the disabled T8132 Neural Engine Describe the M4 H16 ANE and its three DARTs from the public, Unlicense GravityLinux ADTs, with six register windows, two interrupts and five DAPF records. Keep the engine, DARTs and existing DAPF companion disabled. Sources (ane / dart-ane) in GravityLinux/adt-collection at 14f45bbf1ea6: 26.6.2/t8132-j773.txt:26993-27128 27.0/t8132-j604.txt:25089-25218 26.5.1/t8132-j713.txt:26711-26846 Translate arm-io register addresses by 0x200000000; DAPF ranges already contain CPU physical addresses. T8132 has no T6041 second-engine aux-3. Resolve power-gate 292 (ANE-SYS-V, no_ps) through its parent device 155 (ANE_SYS, psreg 5 / psidx 14) to ps_ane_sys at 0x570. Gate 396 (ANE-SYS-V-PMP, no_ps, notify_pmp) has no physical parent or PMGR power state, so do not invent a second genpd for it. The J713 domain override is unchanged. Default firmware IOVAs match the J773/J713 segment-ranges; physical preload reservations must come from the loader. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Erik Bourget --- .../boot/dts/apple/t8132-peripherals.dtsi | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi b/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi index f291e5161a58a..4e3522574613a 100644 --- a/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi @@ -140,6 +140,40 @@ status = "disabled"; }; + ane_dart0: iommu@501800000 { + compatible = "apple,t8132-dart", "apple,t8110-dart"; + reg = <0x5 0x01800000 0x0 0xc000>; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&ps_ane_sys>; + /* Include firmware identity MMIO pages below the preload DVAs. */ + apple,dma-range = <0x0 0x0 0x400 0x0>; + status = "disabled"; + }; + + ane_dart1: iommu@501820000 { + compatible = "apple,t8132-dart", "apple,t8110-dart"; + reg = <0x5 0x01820000 0x0 0xc000>; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&ps_ane_sys>; + apple,dma-range = <0x0 0x0 0x400 0x0>; + status = "disabled"; + }; + + ane_dart2: iommu@501840000 { + compatible = "apple,t8132-dart", "apple,t8110-dart"; + reg = <0x5 0x01840000 0x0 0xc000>; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&ps_ane_sys>; + apple,dma-range = <0x0 0x0 0x400 0x0>; + status = "disabled"; + }; + dart_ane_companion3: filter@501810000 { compatible = "apple,t8132-dapf", "apple,dapf"; reg = <0x5 0x01810000 0x0 0x4000>; @@ -309,6 +343,43 @@ status = "disabled"; }; + /* + * ADT-derived only: keep disabled until an M4 owner qualifies the H16 + * backend and the loader hands off reserved TEXT/DATA preloads. + */ + ane: ane@500000000 { + compatible = "apple,t8132-ane"; + reg = <0x5 0x00000000 0x0 0x2000000>, + <0x3 0x80700000 0x0 0x18000>, + <0x3 0x80724000 0x0 0x4000>, + <0x3 0x803c0000 0x0 0x30000>, + <0x2 0x11000000 0x0 0xff4000>, + <0x3 0x882c8000 0x0 0x4000>; + /* There is no second-engine aux-3 window on T8132. */ + reg-names = "engine", "pmgr", "aux-0", "aux-1", "aux-2", "aux-4"; + interrupt-parent = <&aic>; + interrupts = , + ; + iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>; + /* + * Gate 292 (ANE-SYS-V) resolves to physical gate 155 (ANE_SYS). + * Gate 396 (ANE-SYS-V-PMP) is a virtual PMP notification, not a + * PMGR power state, and has no genpd provider yet. + */ + power-domains = <&ps_ane_sys>; + apple,ane-type = <0x100>; + apple,firmware-preloaded; + /* ADT dapf-instance-0: inclusive CPU addresses, in record order. */ + apple,dapf-ranges = /bits/ 64 <0x48d668000 0x48d668003>, + /bits/ 64 <0x38070c000 0x38070c01b>, + /bits/ 64 <0x380700570 0x380700573>, + /bits/ 64 <0x3807273cc 0x3807273cf>, + /bits/ 64 <0x302668000 0x302668003>; + /* Default layout; the loader supplies per-boot physical reservations. */ + apple,firmware-iovas = /bits/ 64 <0x10000000000 0x100000c0000>; + status = "disabled"; + }; + scaler0: scaler@505000000 { compatible = "apple,t8132-scaler", "apple,scaler"; reg = <0x5 0x05000000 0x0 0x38000>, From 3127723acbeaa2450bfa7769868787a151164c11 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 12 Nov 2026 13:22:12 +1100 Subject: [PATCH 3/9] accel/ane: Recognize T8132 H16 while refusing unqualified boots Select the shared H16 platform path for apple,t8132-ane with the ADT's six resource names (no aux-3), type 0x100, two IRQs and five DAPF records. Do not assign T6041 firmware profiles, MMIO tables or power-write words to the unqualified M4. Make boot qualification explicit and refuse T8132 before resource, preload, power, IOMMU or MMIO validation. Registration-time preflight also prevents driver-core DMA and genpd setup on an enabled node. Existing platforms retain their behavior. Aura does not yet hand off T8132 firmware, and an owner must qualify the single-engine backend, IRQs, DAPF and power sequence before this platform can run. Add a KUnit case for real preflight/probe refusal with no DT resources, when the firmware tests and full driver are both built in. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Erik Bourget --- drivers/accel/ane/ane_fw_platform.c | 45 +++++++++++++++++++++ drivers/accel/ane/ane_fw_platform.h | 3 ++ drivers/accel/ane/ane_fw_platform_test.c | 23 +++++++++++ drivers/accel/ane/ane_t6021_rtclient_main.c | 5 +++ 4 files changed, 76 insertions(+) diff --git a/drivers/accel/ane/ane_fw_platform.c b/drivers/accel/ane/ane_fw_platform.c index 411b1732e41aa..fa105ffedc2b7 100644 --- a/drivers/accel/ane/ane_fw_platform.c +++ b/drivers/accel/ane/ane_fw_platform.c @@ -24,6 +24,15 @@ static const u32 ane_h16_reg_sizes[] = { 0x2000000, 0x18000, 0x4000, 0x30000, 0xff4000, 0x2000000, 0x4000, }; +/* T8132 has no second engine (aux-3); retain the ADT window ordering. */ +static const char * const ane_t8132_reg_names[] = { + "engine", "pmgr", "aux-0", "aux-1", "aux-2", "aux-4", +}; + +static const u32 ane_t8132_reg_sizes[] = { + 0x2000000, 0x18000, 0x4000, 0x30000, 0xff4000, 0x4000, +}; + /* Offsets in reg[1]; genpd, never the ANE driver, owns transitions. */ static const u32 ane_h16_power_words[] = { 0x3c0, 0xc008, 0xc000, 0xc010, 0xc018, @@ -90,11 +99,39 @@ const struct ane_fw_platform ane_h16_platform = { * EXCLAVE_MODE_STOP. */ .sleep_cold = true, + .boot_qualified = true, .firmware_preloaded = true, .safe_reset = false, .pmp_report = "apple,t6041-pmp-v2-report", }; +/* + * M4: resource metadata from the public T8132 J773/J604/J713 ADTs. + * The shared H16 path is selected, but T6041's firmware profiles, MMIO + * tables, power sequence and second-engine window are not qualified here. + * Keep boot_qualified false until an owner validates a T8132 preload and + * the backend handles its single engine, two IRQs and five DAPF records. + */ +const struct ane_fw_platform ane_t8132_platform = { + .soc = 0x8132, + .chip_family = 16, + .ane_type = 0x100, + .interrupt_count = 2, + .irq_role = ANE_FW_IRQ_UNKNOWN, + .owner = ANE_FW_OWNER_AP, + .reg_names = ane_t8132_reg_names, + .reg_sizes = ane_t8132_reg_sizes, + .reg_count = ARRAY_SIZE(ane_t8132_reg_names), + .dapf_dart = 0, + .dapf_offset = 0x10000, + .dapf_size = SZ_16K, + .dapf_count = 5, + .preload_dva = { 0x10000000000, 0x100000c0000 }, + .preload_size = { 0xc0000, 0x2ac000 }, + .boot_qualified = false, + .firmware_preloaded = true, +}; + const struct ane_fw_platform ane_h17_platform = { .soc = 0x8140, .chip_family = 17, @@ -115,6 +152,7 @@ const struct ane_fw_platform ane_h17_platform = { .preload_dva = { 0x10000000000, 0x100000c0000 }, .preload_size = { 0xc0000, 0x2ac000 }, .stream_mask = BIT(0), + .boot_qualified = true, .firmware_preloaded = true, .safe_reset = false, /* 25G83 boots this firmware in Exclave mode (SPEC-ANE-SLEEP-H17.md). */ @@ -165,6 +203,7 @@ const struct ane_fw_platform ane_t6050_platform = { .preload_dva = { 0x10000000000, 0x100000c0000 }, .preload_size = { 0xc0000, 0x2ac000 }, .stream_mask = BIT(0), + .boot_qualified = true, .firmware_preloaded = true, .safe_reset = false, .sleep_warm = false, @@ -311,6 +350,12 @@ int ane_fw_platform_preflight(struct platform_device *pdev, unsigned int i; int ret; + /* Refuse unqualified SoCs before resources, DMA, power or MMIO. */ + if (!soc->boot_qualified) + return dev_err_probe(dev, -EOPNOTSUPP, + "ANE boot unqualified for SoC %#x; requires owner qualification and bootloader firmware preload support\n", + soc->soc); + /* No backend has acquired ownership, even if DT omits the marker. * Check before resources, firmware, power, IOMMU or engine access. */ diff --git a/drivers/accel/ane/ane_fw_platform.h b/drivers/accel/ane/ane_fw_platform.h index dd5e3278c423d..1642a029edec8 100644 --- a/drivers/accel/ane/ane_fw_platform.h +++ b/drivers/accel/ane/ane_fw_platform.h @@ -59,6 +59,8 @@ struct ane_fw_platform { u64 preload_dva[2]; u64 preload_size[2]; u16 stream_mask; + /* Boot qualification is platform-specific, never implied by generation. */ + bool boot_qualified; bool firmware_preloaded; bool safe_reset; /* @@ -147,6 +149,7 @@ ane_fw_sleep_path(const struct ane_fw_platform *platform) extern const struct ane_fw_platform ane_h16_platform, ane_h17_platform, ane_t6050_platform, ane_t8142_platform; +extern const struct ane_fw_platform ane_t8132_platform; int ane_fw_platform_preflight(struct platform_device *pdev, const struct ane_fw_platform *soc); diff --git a/drivers/accel/ane/ane_fw_platform_test.c b/drivers/accel/ane/ane_fw_platform_test.c index 7fa82abf63faf..9105c224e72c1 100644 --- a/drivers/accel/ane/ane_fw_platform_test.c +++ b/drivers/accel/ane/ane_fw_platform_test.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only OR MIT #include #include +#include #include "ane_fw_platform.h" @@ -66,7 +67,29 @@ static void ane_platform_staged_bind_test(struct kunit *test) KUNIT_EXPECT_EQ(test, ane_fw_sleep_path(&h17), ANE_SLEEP_FW_BACKEND); } +#if IS_BUILTIN(CONFIG_DRM_ACCEL_ANE) && IS_BUILTIN(CONFIG_DRM_ACCEL_ANE_FW_KUNIT_TEST) +/* Even a manually enabled DT must not take the T6041 acquisition path. */ +static void ane_t8132_unqualified_test(struct kunit *test) +{ + struct platform_device *pdev = platform_device_alloc("ane-unqualified", -1); + + KUNIT_ASSERT_NOT_NULL(test, pdev); + KUNIT_EXPECT_FALSE(test, ane_t8132_platform.boot_qualified); + KUNIT_EXPECT_EQ(test, ane_t8132_platform.reg_count, 6U); + KUNIT_EXPECT_STREQ(test, ane_t8132_platform.reg_names[5], "aux-4"); + /* No DT, resources or preload: refusal must precede their validation. */ + KUNIT_EXPECT_EQ(test, ane_fw_platform_preflight(pdev, &ane_t8132_platform), + -EOPNOTSUPP); + KUNIT_EXPECT_EQ(test, ane_fw_platform_probe(pdev, &ane_t8132_platform), + -EOPNOTSUPP); + platform_device_put(pdev); +} +#endif + static struct kunit_case ane_fw_platform_cases[] = { +#if IS_BUILTIN(CONFIG_DRM_ACCEL_ANE) && IS_BUILTIN(CONFIG_DRM_ACCEL_ANE_FW_KUNIT_TEST) + KUNIT_CASE(ane_t8132_unqualified_test), +#endif KUNIT_CASE(ane_platform_staged_bind_test), KUNIT_CASE(ane_platform_sleep_path_test), KUNIT_CASE(ane_preload_ranges_test), diff --git a/drivers/accel/ane/ane_t6021_rtclient_main.c b/drivers/accel/ane/ane_t6021_rtclient_main.c index a4f0d6fd7e872..ad05961fadba1 100644 --- a/drivers/accel/ane/ane_t6021_rtclient_main.c +++ b/drivers/accel/ane/ane_t6021_rtclient_main.c @@ -4414,6 +4414,10 @@ static const struct ane_t602x_soc ane_h16_soc = { .platform = &ane_h16_platform, }; +static const struct ane_t602x_soc ane_t8132_soc = { + .platform = &ane_t8132_platform, +}; + static const struct ane_t602x_soc ane_h17_soc = { .platform = &ane_h17_platform, }; @@ -4432,6 +4436,7 @@ static const struct of_device_id ane_rtclient_of_match[] = { { .compatible = "apple,t6022-ane", .data = &ane_t6022_soc }, { .compatible = "apple,t8112-ane", .data = &ane_t8112_soc }, { .compatible = "apple,t6041-ane", .data = &ane_h16_soc }, + { .compatible = "apple,t8132-ane", .data = &ane_t8132_soc }, { .compatible = "apple,t8140-ane", .data = &ane_h17_soc }, { .compatible = "apple,t6050-ane", .data = &ane_t6050_soc }, { .compatible = "apple,t8142-ane", .data = &ane_t8142_soc }, From 12559f08e2c1fcafe00c2b2afe8bff0ec422b4bf Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 12 Nov 2026 13:26:03 +1100 Subject: [PATCH 4/9] dt-bindings: npu: apple,ane: Use complete conditional schemas The current dt-schema meta-schema rejects the two existing ANE if/else clauses without a then branch. Express the same exceptions as negated compatible conditions with then branches, retaining the power-domain and clock constraints. This lets the extended T8132 binding pass the required schema validation. Assisted-by: LLM Signed-off-by: Ryan Murray Signed-off-by: Erik Bourget --- .../devicetree/bindings/npu/apple,ane.yaml | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Documentation/devicetree/bindings/npu/apple,ane.yaml b/Documentation/devicetree/bindings/npu/apple,ane.yaml index ae2091adc3881..afb9abccdffdb 100644 --- a/Documentation/devicetree/bindings/npu/apple,ane.yaml +++ b/Documentation/devicetree/bindings/npu/apple,ane.yaml @@ -483,15 +483,16 @@ allOf: - if: properties: compatible: - contains: - enum: - - apple,t8140-ane - - apple,t6041-ane - - apple,t6050-ane - - apple,t8132-ane - - apple,t6001-ane - - apple,t8142-ane - else: + not: + contains: + enum: + - apple,t8140-ane + - apple,t6041-ane + - apple,t6050-ane + - apple,t8132-ane + - apple,t6001-ane + - apple,t8142-ane + then: properties: power-domains: minItems: 5 @@ -513,11 +514,12 @@ allOf: - if: properties: compatible: - contains: - enum: - - apple,t6001-ane - - apple,t6050-ane - else: + not: + contains: + enum: + - apple,t6001-ane + - apple,t6050-ane + then: properties: clocks: false From fb73edba2f95b93491c467973fa0a979d6f6daac Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 14 Nov 2026 23:07:04 -0500 Subject: [PATCH 5/9] dt-bindings: npu: apple,ane: Give the T8132 ANE five power domains The T8132 ANE has the T6041's five domains: ANE_SYS, then the CPU, MPM, TD and base. Signed-off-by: Erik Bourget --- Documentation/devicetree/bindings/npu/apple,ane.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/npu/apple,ane.yaml b/Documentation/devicetree/bindings/npu/apple,ane.yaml index afb9abccdffdb..999599f852d8a 100644 --- a/Documentation/devicetree/bindings/npu/apple,ane.yaml +++ b/Documentation/devicetree/bindings/npu/apple,ane.yaml @@ -101,7 +101,8 @@ properties: description: The power states the engine needs, five on T8103, six on T6000 with ANE level control (including PMP report SRAM), eight on - T602x, seven on T8112 and one system domain on T8132 and T8140. + T602x, seven on T8112, five on T6041 and T8132 (system, CPU, MPM, TD + and base) and one system domain on T8140. T6041 may add a sixth, "perf", a performance floor (such as the SoC rail floor) that the driver holds only while requests are in flight. minItems: 1 @@ -355,7 +356,8 @@ allOf: - const: aux-2 - const: aux-4 power-domains: - maxItems: 1 + minItems: 5 + maxItems: 5 apple,ane-type: const: 0x100 apple,dapf-ranges: @@ -659,7 +661,8 @@ examples: interrupts = , ; iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>; - power-domains = <&ps_ane_sys>; + power-domains = <&ps_ane_sys>, <&ps_ane_cpu>, <&ps_ane_mpm>, + <&ps_ane_td>, <&ps_ane_base>; apple,ane-type = <0x100>; apple,firmware-preloaded; apple,dapf-ranges = /bits/ 64 <0x48d668000 0x48d668003>, From a4802c433e2a95cc79aaab378e528a0ec37aeb4f Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 14 Nov 2026 23:07:04 -0500 Subject: [PATCH 6/9] arm64: dts: apple: t8132: give the ANE its five power domains The H16 backend takes ANE_SYS, then the CPU, MPM, TD and base domains, in the T6041 order. The T8132 PMGR has the same five at the same offsets, with ANE_SYS at +0x570. Signed-off-by: Erik Bourget --- arch/arm64/boot/dts/apple/t8132-peripherals.dtsi | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi b/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi index 4e3522574613a..47cac2a1376e1 100644 --- a/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-peripherals.dtsi @@ -361,12 +361,9 @@ interrupts = , ; iommus = <&ane_dart0 0>, <&ane_dart1 0>, <&ane_dart2 0>; - /* - * Gate 292 (ANE-SYS-V) resolves to physical gate 155 (ANE_SYS). - * Gate 396 (ANE-SYS-V-PMP) is a virtual PMP notification, not a - * PMGR power state, and has no genpd provider yet. - */ - power-domains = <&ps_ane_sys>; + /* The T6041 order: ANE_SYS, then the CPU, MPM, TD and base. */ + power-domains = <&ps_ane_sys>, <&ps_ane_cpu>, <&ps_ane_mpm>, + <&ps_ane_td>, <&ps_ane_base>; apple,ane-type = <0x100>; apple,firmware-preloaded; /* ADT dapf-instance-0: inclusive CPU addresses, in record order. */ From 077d638ebb8fb246a887ed0ae49a18aeb349bb9c Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 14 Nov 2026 21:48:31 -0500 Subject: [PATCH 7/9] arm64: dts: apple: t8132-j713: give Linux the ANE power domains The ANE driver powers ANE_SYS and its CPU, MPM, TD and base domains through genpd, as on the T6041. Signed-off-by: Erik Bourget --- arch/arm64/boot/dts/apple/t8132-j713-pmgr.dtsi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8132-j713-pmgr.dtsi b/arch/arm64/boot/dts/apple/t8132-j713-pmgr.dtsi index a478286000654..3c292be99ed43 100644 --- a/arch/arm64/boot/dts/apple/t8132-j713-pmgr.dtsi +++ b/arch/arm64/boot/dts/apple/t8132-j713-pmgr.dtsi @@ -429,7 +429,7 @@ }; &ps_ane_sys { - status = "disabled"; + status = "okay"; }; &ps_jpg { @@ -517,19 +517,19 @@ }; &ps_ane_mpm { - status = "disabled"; + status = "okay"; }; &ps_ane_cpu { - status = "disabled"; + status = "okay"; }; &ps_ane_td { - status = "disabled"; + status = "okay"; }; &ps_ane_base { - status = "disabled"; + status = "okay"; }; &ps_disp_cpu { From ac4995129b0484aded47b0e83e33f38e51616134 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 14 Nov 2026 21:37:43 -0500 Subject: [PATCH 8/9] accel/ane: run the T8132 (M4) Neural Engine on the H16 backend The M4 has the M4 Pro's H16 engine and firmware interface with one engine: no aux-3 window, five DAPF records instead of four, and ANE_SYS at PMGR +0x570. Take the DAPF record count and the XL window from the platform, and describe the T8132: - Its own engine writes before the CPU starts: the AXI2AF set at engine +0x0, then its write-disable and lock bits. It has no XL or C1PPT set. With the T6041 values the firmware boots, but the first request never completes. - Its own firmware builds, never offered to the T6041 or the reverse. The J713's 26.6.2 preload has the T6041 25G83 layout 0x4f0 bytes later in DATA, plus two records (GKTS, ECAP) whose values change on every boot; both are normalized like the other mutable records. - System sleep cycles the engine cold, as on the T6041. - The F2H channels are polled. The engine, DARTs and DAPF bank match the T6041 tables: DART revision 0x2a2a0202, the same scratch, doorbell and interrupt offsets, and the same boot values. Tested on a J713 (16 GB) at 26.6.2 with a loader that hands off the preload: every bring-up stage, the pinned H16G add-128 program 1000 times bit exact (about 0.14 ms a request), and a 30 s suspend to RAM with the engine loaded, after which it boots again from the preload and the same program passes. Signed-off-by: Erik Bourget --- drivers/accel/ane/Kconfig | 2 +- drivers/accel/ane/ane_fw_cold.h | 3 +- drivers/accel/ane/ane_fw_platform.c | 40 +++++-- drivers/accel/ane/ane_fw_platform.h | 5 + drivers/accel/ane/ane_fw_platform_test.c | 20 ++-- drivers/accel/ane/ane_h16_backend.c | 13 ++- drivers/accel/ane/ane_h16_boot.h | 25 ++-- drivers/accel/ane/ane_h16_boot_data.h | 143 +++++++++++++++++++++++ drivers/accel/ane/ane_h16_boot_test.c | 105 ++++++++++++++++- drivers/accel/ane/ane_h16_preload_test.c | 31 ++++- 10 files changed, 345 insertions(+), 42 deletions(-) diff --git a/drivers/accel/ane/Kconfig b/drivers/accel/ane/Kconfig index 6b40340d69e30..9be3cd4777aba 100644 --- a/drivers/accel/ane/Kconfig +++ b/drivers/accel/ane/Kconfig @@ -16,7 +16,7 @@ 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 (A18 Pro) are recognized for firmware preflight + H16 (M4 and 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 diff --git a/drivers/accel/ane/ane_fw_cold.h b/drivers/accel/ane/ane_fw_cold.h index a9bea3958790c..0af12b6ca1bc8 100644 --- a/drivers/accel/ane/ane_fw_cold.h +++ b/drivers/accel/ane/ane_fw_cold.h @@ -2,11 +2,10 @@ #ifndef __ANE_FW_COLD_H__ #define __ANE_FW_COLD_H__ +#include "ane_fw_platform.h" #include "ane_fw_transport.h" #define ANE_FW_DARTS 3 -/* DAPF records: four on T8140, five on T6050. */ -#define ANE_FW_DAPF_MAX 5 struct ane_fw_cold_state { u32 sys, cpu, subblock, gate_request, gate_ack; diff --git a/drivers/accel/ane/ane_fw_platform.c b/drivers/accel/ane/ane_fw_platform.c index fa105ffedc2b7..219e4560ca0af 100644 --- a/drivers/accel/ane/ane_fw_platform.c +++ b/drivers/accel/ane/ane_fw_platform.c @@ -38,6 +38,11 @@ static const u32 ane_h16_power_words[] = { 0x3c0, 0xc008, 0xc000, 0xc010, 0xc018, }; +/* The same five domains; ANE_SYS sits at +0x570 in the T8132 PMGR. */ +static const u32 ane_t8132_power_words[] = { + 0x570, 0xc008, 0xc000, 0xc010, 0xc018, +}; + static const char * const ane_h17_reg_names[] = { "engine", "pmgr", "pwgate" }; static const u32 ane_h17_reg_sizes[] = { 0x2000000, 0x18000, 0x34 }; @@ -68,6 +73,8 @@ const struct ane_fw_platform ane_h16_platform = { .dapf_dart = 0, .dapf_offset = 0x10000, .dapf_size = SZ_16K, + .dapf_count = 4, + .has_xl = true, /* The DT compatible is t6041 on the M4 Max and the M4 Pro (T6040) alike. */ .soc = 0x6040, .chip_family = 16, @@ -106,30 +113,48 @@ const struct ane_fw_platform ane_h16_platform = { }; /* - * M4: resource metadata from the public T8132 J773/J604/J713 ADTs. - * The shared H16 path is selected, but T6041's firmware profiles, MMIO - * tables, power sequence and second-engine window are not qualified here. - * Keep boot_qualified false until an owner validates a T8132 preload and - * the backend handles its single engine, two IRQs and five DAPF records. + * M4: the H16 engine and firmware interface of the T6041, with one engine + * (no aux-3 window), its own engine writes and firmware builds, ANE_SYS at + * PMGR +0x570 and five DAPF records. The backend polls the F2H channels. */ const struct ane_fw_platform ane_t8132_platform = { + .h16_profiles = ane_t8132_profiles, + .h16_profile_count = ARRAY_SIZE(ane_t8132_profiles), + .h16_mmio = ane_h16_mmio_t6041, + .h16_mmio_count = ARRAY_SIZE(ane_h16_mmio_t6041), + .dart_params = 0x8, .soc = 0x8132, .chip_family = 16, .ane_type = 0x100, + .hwx_subtype = 7, + .task_generation = 17, .interrupt_count = 2, .irq_role = ANE_FW_IRQ_UNKNOWN, .owner = ANE_FW_OWNER_AP, .reg_names = ane_t8132_reg_names, .reg_sizes = ane_t8132_reg_sizes, .reg_count = ARRAY_SIZE(ane_t8132_reg_names), + .wrapper = 0x1600000, + .mailbox = 0x1608000, + .scratch = 0x1880020, + .doorbell = 0x1884000, + .irq_status = 0x188c000, + .irq_ack = 0x1890000, + .power_words = ane_t8132_power_words, + .power_count = ARRAY_SIZE(ane_t8132_power_words), .dapf_dart = 0, .dapf_offset = 0x10000, .dapf_size = SZ_16K, .dapf_count = 5, .preload_dva = { 0x10000000000, 0x100000c0000 }, .preload_size = { 0xc0000, 0x2ac000 }, - .boot_qualified = false, + .stream_mask = BIT(0) | BIT(11), + /* System sleep cycles the engine cold and replays every program, as on T6041. */ + .sleep_cold = true, + .boot_qualified = true, .firmware_preloaded = true, + .safe_reset = false, + .pmp_report = "apple,t8132-pmp-v2-report", }; const struct ane_fw_platform ane_h17_platform = { @@ -398,7 +423,8 @@ int ane_fw_platform_preflight(struct platform_device *pdev, "H16 requires bootloader-reserved no-map TEXT/DATA preload ranges\n"); if (!soc->h16_profile_count || !soc->h16_mmio_count || soc->dapf_dart >= 3 || - !soc->dapf_size || of_property_count_u64_elems(np, "apple,dapf-ranges") != 8) + !soc->dapf_size || !soc->dapf_count || soc->dapf_count > ANE_FW_DAPF_MAX || + of_property_count_u64_elems(np, "apple,dapf-ranges") != soc->dapf_count * 2) return -ENODATA; return 0; } diff --git a/drivers/accel/ane/ane_fw_platform.h b/drivers/accel/ane/ane_fw_platform.h index 1642a029edec8..6f4372e8ad3c7 100644 --- a/drivers/accel/ane/ane_fw_platform.h +++ b/drivers/accel/ane/ane_fw_platform.h @@ -9,6 +9,9 @@ #include #include +/* DAPF records: four on T6041 and T8140, five on T6050 and T8132. */ +#define ANE_FW_DAPF_MAX 5 + struct device_node; struct platform_device; struct ane_h16_profile; @@ -101,6 +104,8 @@ struct ane_fw_platform { u16 dart_revision; u8 dapf_count; const u8 *text_pin; + /* H16: an aux-3 window, which the build's XL tunables go to. */ + bool has_xl; }; /* Pure range check: the boot loader supplies the physical addresses. */ diff --git a/drivers/accel/ane/ane_fw_platform_test.c b/drivers/accel/ane/ane_fw_platform_test.c index 9105c224e72c1..6755523e7abe3 100644 --- a/drivers/accel/ane/ane_fw_platform_test.c +++ b/drivers/accel/ane/ane_fw_platform_test.c @@ -68,27 +68,29 @@ static void ane_platform_staged_bind_test(struct kunit *test) } #if IS_BUILTIN(CONFIG_DRM_ACCEL_ANE) && IS_BUILTIN(CONFIG_DRM_ACCEL_ANE_FW_KUNIT_TEST) -/* Even a manually enabled DT must not take the T6041 acquisition path. */ -static void ane_t8132_unqualified_test(struct kunit *test) +/* One engine: no aux-3, five DAPF records; a node without DT is refused. */ +static void ane_t8132_platform_test(struct kunit *test) { - struct platform_device *pdev = platform_device_alloc("ane-unqualified", -1); + struct platform_device *pdev = platform_device_alloc("ane-t8132", -1); KUNIT_ASSERT_NOT_NULL(test, pdev); - KUNIT_EXPECT_FALSE(test, ane_t8132_platform.boot_qualified); KUNIT_EXPECT_EQ(test, ane_t8132_platform.reg_count, 6U); KUNIT_EXPECT_STREQ(test, ane_t8132_platform.reg_names[5], "aux-4"); - /* No DT, resources or preload: refusal must precede their validation. */ + KUNIT_EXPECT_FALSE(test, ane_t8132_platform.has_xl); + KUNIT_EXPECT_TRUE(test, ane_h16_platform.has_xl); + KUNIT_EXPECT_EQ(test, ane_t8132_platform.dapf_count, 5); + KUNIT_EXPECT_EQ(test, ane_h16_platform.dapf_count, 4); + KUNIT_EXPECT_EQ(test, ane_t8132_platform.power_words[0], 0x570U); + /* No DT, resources or preload: refused before any of them is used. */ KUNIT_EXPECT_EQ(test, ane_fw_platform_preflight(pdev, &ane_t8132_platform), - -EOPNOTSUPP); - KUNIT_EXPECT_EQ(test, ane_fw_platform_probe(pdev, &ane_t8132_platform), - -EOPNOTSUPP); + -EINVAL); platform_device_put(pdev); } #endif static struct kunit_case ane_fw_platform_cases[] = { #if IS_BUILTIN(CONFIG_DRM_ACCEL_ANE) && IS_BUILTIN(CONFIG_DRM_ACCEL_ANE_FW_KUNIT_TEST) - KUNIT_CASE(ane_t8132_unqualified_test), + KUNIT_CASE(ane_t8132_platform_test), #endif KUNIT_CASE(ane_platform_staged_bind_test), KUNIT_CASE(ane_platform_sleep_path_test), diff --git a/drivers/accel/ane/ane_h16_backend.c b/drivers/accel/ane/ane_h16_backend.c index b47f45b64eb02..4b1ca924c1759 100644 --- a/drivers/accel/ane/ane_h16_backend.c +++ b/drivers/accel/ane/ane_h16_backend.c @@ -962,7 +962,7 @@ static int ane_h16_map(void *ctx) !(h->domain->pgsize_bitmap & SZ_16K)) return -EOPNOTSUPP; /* Never widen a finalized DART aperture by assigning geometry fields. */ - for (i = 0; i < 4; i++) { + for (i = 0; i < b->soc->dapf_count; i++) { u64 page = round_down(b->ranges[i][0], SZ_16K); if (!ane_fw_contains(h->domain->geometry.aperture_start, @@ -991,7 +991,7 @@ static int ane_h16_map(void *ctx) ret = ane_h16_map_heap_tail(h); if (ret) return ret; - for (i = 0; i < 4; i++) { + for (i = 0; i < b->soc->dapf_count; i++) { u64 page = round_down(b->ranges[i][0], SZ_16K); ret = ane_h16_map_range(h, page, page, SZ_16K, @@ -1657,6 +1657,8 @@ static int ane_h16_acquire(struct platform_device *pdev, struct ane_h16_device * for (i = 0; i < ARRAY_SIZE(names); i++) { struct resource *r = platform_get_resource_byname(pdev, IORESOURCE_MEM, names[i]); + if (i == ANE_H16_XL && !h->boot.soc->has_xl) + continue; if (!r) return -ENODEV; h->window[i] = ioremap_np(r->start, resource_size(r)); @@ -2061,11 +2063,14 @@ int ane_h16_backend_probe(struct platform_device *pdev, const struct ane_fw_plat h->boot.ctx = h; h->boot.ops = &ane_h16_ops; h->boot.transport_ops = &ane_h16_transport_ops; + ret = -EINVAL; + if (!soc->dapf_count || soc->dapf_count > ANE_FW_DAPF_MAX) + goto free; ret = of_property_read_u64_array(h->dev->of_node, "apple,dapf-ranges", - &h->boot.ranges[0][0], 8); + &h->boot.ranges[0][0], soc->dapf_count * 2); if (ret) goto free; - for (i = 0; i < 4; i++) { + for (i = 0; i < soc->dapf_count; i++) { u64 start = h->boot.ranges[i][0], end = h->boot.ranges[i][1]; ret = -EINVAL; diff --git a/drivers/accel/ane/ane_h16_boot.h b/drivers/accel/ane/ane_h16_boot.h index f12a8fb3d8e10..184e04648597c 100644 --- a/drivers/accel/ane/ane_h16_boot.h +++ b/drivers/accel/ane/ane_h16_boot.h @@ -4,6 +4,7 @@ #include +#include "ane_fw_platform.h" #include "ane_fw_transport.h" enum ane_h16_stage { @@ -156,7 +157,7 @@ struct ane_h16_boot { struct ane_fw_surface pool; struct ane_fw_surface ipc; struct ane_fw_surface heap; - u64 ranges[4][2]; + u64 ranges[ANE_FW_DAPF_MAX][2]; u32 requests[5]; u32 tick; /* The PMU aperture base for SET_SNE_PMU_BASE2 at startup; 0: not sent. */ @@ -331,7 +332,8 @@ static inline bool ane_h16_dapf_record(struct ane_h16_boot *b, unsigned int reco } /* - * Compare the four records with apple,dapf-ranges. Preflight only reports. + * Compare the platform's records with apple,dapf-ranges. Preflight only + * reports. * The bank loses its records whenever its power domain does, so map writes * every record that differs, in the order the t8110 bank takes them, and * reads it back. A bank whose lock word has bit 2 set and that differs is @@ -343,20 +345,20 @@ static inline int ane_h16_dapf(struct ane_h16_boot *b, bool program) enum ane_h16_window owner = ANE_H16_DART0 + b->soc->dapf_dart; u32 protect = b->ops->read32(b->ctx, owner, m->dart_protect); u32 lock = b->ops->read32(b->ctx, owner, m->dart_lock); - unsigned int record, matched = 0; - bool match[4]; + unsigned int record, matched = 0, count = b->soc->dapf_count; + bool match[ANE_FW_DAPF_MAX]; b->ops->log(b->ctx, "DAPF protect/lock", protect, lock); - for (record = 0; record < 4; record++) { + for (record = 0; record < count; record++) { match[record] = ane_h16_dapf_record(b, record); matched += match[record]; } - b->ops->log(b->ctx, "DAPF records matching", matched, 4); - if (!program || matched == 4) + b->ops->log(b->ctx, "DAPF records matching", matched, count); + if (!program || matched == count) return 0; if (lock & BIT(2)) return -EPERM; - for (record = 0; record < 4; record++) { + for (record = 0; record < count; record++) { u32 off = m->dapf_records + record * m->dapf_stride; if (match[record]) @@ -369,7 +371,7 @@ static inline int ane_h16_dapf(struct ane_h16_boot *b, bool program) if (!ane_h16_dapf_record(b, record)) return -EIO; } - b->ops->log(b->ctx, "DAPF records written/read back", 4 - matched, 4); + b->ops->log(b->ctx, "DAPF records written/read back", count - matched, count); return 0; } @@ -416,6 +418,11 @@ static inline int ane_h16_prepare(struct ane_h16_boot *b) if (group->c1ppt && !f->c1ppt) continue; + if (group->window == ANE_H16_XL && !b->soc->has_xl) { + b->ops->log(b->ctx, "tunables skipped: no XL window", group->window, + group->count); + continue; + } if (group->lock_mask && (b->ops->read32(b->ctx, group->window, group->base + group->lock_offset) & group->lock_mask)) { diff --git a/drivers/accel/ane/ane_h16_boot_data.h b/drivers/accel/ane/ane_h16_boot_data.h index 7a566e97d637e..71e82c3940b33 100644 --- a/drivers/accel/ane/ane_h16_boot_data.h +++ b/drivers/accel/ane/ane_h16_boot_data.h @@ -128,6 +128,80 @@ static const struct ane_h16_tunables ane_h16_tunables_26a428[] = { .c1ppt = true, .lock_offset = 0x3ffc, .lock_mask = 1 }, }; +/* + * T8132 (M4): the engine AXI2AF set at +0x0, then its write-disable and lock + * bits. The lock holds until ANE_SYS power is cycled, so a group that finds + * it set only checks its values. M4 has no XL or C1PPT writes. + */ +static const struct ane_h16_tunable ane_t8132_axi[] = { + { 0x0000, 0x800000ff, 0x8000001b }, + { 0x0004, 0x80ff00ff, 0x800d000d }, + { 0x0008, 0x80ff00ff, 0x800d000d }, + { 0x000c, 0x80ff00ff, 0x800d000d }, + { 0x0010, 0x80ff00ff, 0x80010003 }, + { 0x0014, 0x80ff00ff, 0x80010003 }, + { 0x0018, 0x800000ff, 0x80000014 }, + { 0x001c, 0x800000ff, 0x80000022 }, + { 0x0020, 0x80ff00ff, 0x8012000c }, + { 0x0024, 0x80ff00ff, 0x80180006 }, + { 0x0028, 0x80ff00ff, 0x80060002 }, + { 0x002c, 0x80ff00ff, 0x80060002 }, + { 0x0030, 0x800000ff, 0x80000016 }, + { 0x0034, 0x800000ff, 0x80000012 }, + { 0x0038, 0x800000ff, 0x80000012 }, + { 0x0100, 0x000000ff, 0x000000ff }, + { 0x0104, 0x00ff0000, 0x00010000 }, + { 0x0108, 0xffff0006, 0x00040000 }, + { 0x0304, 0x3f3f0000, 0x02020000 }, + { 0x0314, 0x80000000, 0x80000000 }, + { 0x031c, 0x80000000, 0x80000000 }, + { 0x0324, 0x80000000, 0x80000000 }, + { 0x0338, 0xffffffff, 0x00050020 }, + { 0x033c, 0xffffffff, 0x000a0030 }, + { 0x0408, 0xffff0020, 0x00130020 }, + { 0x0748, 0x07ff07ff, 0x00200030 }, + { 0x0848, 0x07ff07ff, 0x00100030 }, + { 0x0948, 0x07ff07ff, 0x01000100 }, + { 0x0b00, 0xffffffff, 0x7fffffff }, + { 0x0b04, 0x00000100, 0x00000100 }, + { 0x4008, 0x00000001, 0x00000000 }, + { 0x400c, 0x00000001, 0x00000000 }, + { 0x4014, 0x00000001, 0x00000000 }, + { 0x4018, 0x00000001, 0x00000000 }, + { 0x401c, 0x00000001, 0x00000001 }, + { 0x4020, 0xffff0000, 0x00000000 }, + { 0x4024, 0xffff0000, 0x00000000 }, + { 0x4028, 0xffff0000, 0x00000000 }, + { 0x402c, 0xffff0000, 0x00000000 }, + { 0x4030, 0xffff0000, 0x00000000 }, + { 0x4034, 0xffff0000, 0x00000000 }, +}; + +static const struct ane_h16_tunable ane_t8132_axi_wd[] = { + { 0x0df8, 0x00000001, 0x00000001 }, + { 0x0ef8, 0x00000001, 0x00000001 }, + { 0x0ff8, 0x00000001, 0x00000001 }, + { 0x10f8, 0x00000001, 0x00000001 }, + { 0x11f8, 0x00000001, 0x00000001 }, +}; + +static const struct ane_h16_tunable ane_t8132_axi_lock[] = { + { 0x0dfc, 0x00000001, 0x00000001 }, + { 0x0efc, 0x00000001, 0x00000001 }, + { 0x0ffc, 0x00000001, 0x00000001 }, + { 0x10fc, 0x00000001, 0x00000001 }, + { 0x11fc, 0x00000001, 0x00000001 }, +}; + +static const struct ane_h16_tunables ane_t8132_tunables[] = { + { .window = ANE_H16_ENGINE, .values = ane_t8132_axi, + .count = ARRAY_SIZE(ane_t8132_axi), .lock_offset = 0xdfc, .lock_mask = 1 }, + { .window = ANE_H16_ENGINE, .values = ane_t8132_axi_wd, + .count = ARRAY_SIZE(ane_t8132_axi_wd), .lock_offset = 0xdfc, .lock_mask = 1 }, + { .window = ANE_H16_ENGINE, .values = ane_t8132_axi_lock, + .count = ARRAY_SIZE(ane_t8132_axi_lock), .lock_offset = 0xdfc, .lock_mask = 1 }, +}; + /* * T6041 (J616s) ANE DARTs, revision 2.2 (PARAMS3 0x2a2a0202). The ADT * dart-ane0 node has one DAPF bank, the reg entry its instance property tags @@ -189,6 +263,40 @@ static const struct ane_h16_build ane_h16_build_26a428 = { .startup = { { 4, 12 }, { 0, 12 }, { 3, 16 }, { 0x22, 100 } }, }; +/* The J713 25G83 firmware takes the 26A428 boot values; M4 engine writes. */ +static const struct ane_h16_build ane_h16_build_t8132_25g83 = { + .cpu_control = 0x1600044, + .rvbar = 0x1050000, + .ce = 0x18a4000, + .ce_delays = 5001, + .ce_delay_us = 10, + .ready = 0x08042006, + .run = 0x10, + .scratch_polls = 1000, + .scratch_delay_us = 1000, + .command_timeout_ns = 3000000000ULL, + .pool_dva = 0x10000384000, + .ipc_dva = 0x100003d0000, + .heap_dva = 0x100003e4000, + .shared_dva = 0x10001300000, + .expected_rvbar = 0x10000000001, + .pool_size = 0x40000, + .init_offset = 0x180, + .init_size = 0x174, + .config_span = 0x380000, + .config_window = 0x10000000, + .template_count = 64, + .template_word = 0x12c, + .template_value = 4, + .max_channels = 0x21, + /* Host allocation policy, not a recovered firmware ceiling. */ + .max_heap = SZ_16M, + .native_free = true, + .tunables = ane_t8132_tunables, + .tunable_count = ARRAY_SIZE(ane_t8132_tunables), + .startup = { { 4, 12 }, { 0, 12 }, { 3, 16 }, { 0x22, 100 } }, +}; + /* * 27.0 (26A428) preload: ordered aether patchbay records in DATA (whose * firmware VM base is 0xc0000) and the range the bootloader rewrites. @@ -360,6 +468,41 @@ static const struct ane_h16_preload_rule ane_h16_preload_25g83_j614c = { }, }; +/* + * The M4 (J713) 26.6.2 (25G83) preload: the T6041 25G83 patchbay records and + * rewritten range 0x4f0 bytes later in DATA, plus two records whose values + * change on every boot (GKTS and ECAP). + */ +static const struct ane_h16_preload_cell ane_h16_patchbay_25g83_t8132[] = { + { "GKTS", 0x9eb0, 8, true }, + { "ECAP", 0x9fa3, 8, true }, + { "ABOI", 0xa0c9, 8, false }, + { "ZSOI", 0xa0d9, 4, false }, + { "ARcM", 0xa0e5, 4, true }, +}; + +static const struct ane_h16_preload_rule ane_h16_preload_25g83_j713 = { + .cells = ane_h16_patchbay_25g83_t8132, + .cell_count = ARRAY_SIZE(ane_h16_patchbay_25g83_t8132), + .zero_start = 0x1c0f0, + .zero_end = 0x1c790, + .digest = { + 0x14, 0x87, 0xde, 0x7a, 0x0e, 0x39, 0xd9, 0xa3, + 0x4f, 0xcb, 0xbf, 0x9b, 0x36, 0xa5, 0xbe, 0xe7, + 0xe6, 0x6e, 0x20, 0x72, 0x2f, 0xf5, 0xc1, 0x56, + 0x55, 0xb0, 0xee, 0x7a, 0x8a, 0x85, 0x86, 0xc6, + }, +}; + +/* T8132 firmware builds; never offered to the T6041, nor its builds here. */ +static const struct ane_h16_profile ane_t8132_profiles[] __maybe_unused = { + { + .identity = "H16 T8132 26.6.2 25G83 J713", + .preload = &ane_h16_preload_25g83_j713, + .build = &ane_h16_build_t8132_25g83, + }, +}; + /* Every supported H16 firmware build, matched against the live preload. */ static const struct ane_h16_profile ane_h16_profiles[] __maybe_unused = { { diff --git a/drivers/accel/ane/ane_h16_boot_test.c b/drivers/accel/ane/ane_h16_boot_test.c index 58bf09123d3ce..b4f5af3ec669f 100644 --- a/drivers/accel/ane/ane_h16_boot_test.c +++ b/drivers/accel/ane/ane_h16_boot_test.c @@ -23,6 +23,11 @@ struct ane_h16_sim { u32 command_count; u32 scratch_writes; u32 tuning_writes; + /* Tuning writes expected before the first scratch write; XL writes seen. */ + u32 expect_tuning; + u32 xl_writes; + /* Engine registers below 0x5000 keep what is written, like the AXI block. */ + u32 engine[0x5000 / 4]; u32 dapf_writes; u32 mailbox_polls; u32 maps; @@ -94,7 +99,8 @@ static void sim_check_dapf(struct ane_h16_sim *s, u32 off, u32 width) KUNIT_ASSERT_NOT_NULL(s->test, m); KUNIT_EXPECT_GE(s->test, off, m->dapf_records); - KUNIT_EXPECT_LE(s->test, off + width, m->dapf_records + 4 * m->dapf_stride); + KUNIT_EXPECT_LE(s->test, off + width, + m->dapf_records + s->soc.dapf_count * m->dapf_stride); KUNIT_EXPECT_LE(s->test, off + width, s->soc.dapf_size); } @@ -130,6 +136,8 @@ static u32 sim_read32(void *ctx, enum ane_h16_window w, u32 off) return s->scratch[(off - s->soc.scratch) / 4]; if (off == s->soc.irq_status) return s->irq; + if (off < sizeof(s->engine)) + return s->engine[off / 4]; } return 0xa5a5a5a5; } @@ -233,7 +241,7 @@ static void sim_write32(void *ctx, enum ane_h16_window w, u32 off, u32 value) if (s->scratch_writes < 8) { KUNIT_EXPECT_EQ(s->test, cell, s->scratch_writes); KUNIT_EXPECT_EQ(s->test, value, 0U); - KUNIT_EXPECT_EQ(s->test, s->tuning_writes, 103U); + KUNIT_EXPECT_EQ(s->test, s->tuning_writes, s->expect_tuning); } s->scratch_writes++; s->scratch[cell] = value; @@ -307,6 +315,10 @@ static void sim_write32(void *ctx, enum ane_h16_window w, u32 off, u32 value) /* The selected AXI and XL tables must finish before scratch writes. */ KUNIT_EXPECT_TRUE(s->test, !s->boot.ran || s->reset); s->tuning_writes++; + if (w == ANE_H16_XL) + s->xl_writes++; + else if (off < sizeof(s->engine)) + s->engine[off / 4] = value; } static void sim_write64(void *ctx, enum ane_h16_window w, u32 off, u64 value) @@ -541,7 +553,7 @@ static void sim_program_dapf(struct ane_h16_sim *s) { unsigned int i; - for (i = 0; i < 4; i++) { + for (i = 0; i < s->soc.dapf_count; i++) { u32 *p = &s->dapf[(s->mmio.dapf_records + i * s->mmio.dapf_stride) / 4]; u64 end = s->boot.ranges[i][1] & s->mmio.dapf_end_mask; @@ -574,6 +586,8 @@ static int sim_init(struct kunit *test) s->soc.dapf_dart = 0; s->soc.dapf_offset = 0x10000; s->soc.dapf_size = SZ_16K; + s->soc.dapf_count = 4; + s->soc.has_xl = true; s->soc.scratch = 0x1880020; s->soc.doorbell = 0x1884000; s->soc.irq_status = 0x188c000; @@ -585,10 +599,11 @@ static int sim_init(struct kunit *test) s->boot.ops = &sim_ops; s->boot.transport_ops = &sim_transport_ops; s->boot.ctx = s; - for (i = 0; i < 4; i++) { + for (i = 0; i < ANE_FW_DAPF_MAX; i++) { s->boot.ranges[i][0] = 0x500000000ULL + i * SZ_16K; s->boot.ranges[i][1] = s->boot.ranges[i][0] + 3; } + s->expect_tuning = 103; /* The J616s bank after iBoot: power-on values, flags 0. */ for (i = 0; i < ARRAY_SIZE(s->dapf); i++) s->dapf[i] = i % 16 ? 0x5a5a0000 | i : 0; @@ -1224,6 +1239,83 @@ static void ane_h16_foreign_free_test(struct kunit *test) KUNIT_EXPECT_FALSE(test, s->boot.transport.shared_retired[0]); } +/* The T8132: five DAPF records, no XL window, its own engine writes. */ +static void sim_use_t8132(struct ane_h16_sim *s) +{ + s->build = ane_h16_build_t8132_25g83; + s->soc.dapf_count = 5; + s->soc.has_xl = false; + s->expect_tuning = ARRAY_SIZE(ane_t8132_axi) + ARRAY_SIZE(ane_t8132_axi_wd) + + ARRAY_SIZE(ane_t8132_axi_lock); +} + +/* Map programs and reads back all five T8132 records. */ +static void ane_h16_dapf_five_test(struct kunit *test) +{ + struct ane_h16_sim *s = test->priv; + unsigned int i; + + sim_use_t8132(s); + KUNIT_ASSERT_EQ(test, ane_h16_run(&s->boot, ANE_H16_MAP), 0); + KUNIT_EXPECT_EQ(test, s->dapf_writes, 25U); + for (i = 0; i < 5; i++) + KUNIT_EXPECT_TRUE(test, ane_h16_dapf_record(&s->boot, i)); +} + +/* A fifth record that does not read back fails map before RUN. */ +static void ane_h16_dapf_five_readback_test(struct kunit *test) +{ + struct ane_h16_sim *s = test->priv; + + sim_use_t8132(s); + s->dapf_stuck = 4; + KUNIT_EXPECT_EQ(test, ane_h16_run(&s->boot, ANE_H16_MAP), -EIO); + KUNIT_EXPECT_EQ(test, s->dapf_writes, 25U); + KUNIT_EXPECT_FALSE(test, s->boot.ran); +} + +/* A platform without the XL window skips the build's XL tunables. */ +static void ane_h16_no_xl_test(struct kunit *test) +{ + struct ane_h16_sim *s = test->priv; + + s->soc.has_xl = false; + s->expect_tuning = 103 - ARRAY_SIZE(ane_h16_xl); + KUNIT_ASSERT_EQ(test, ane_h16_run(&s->boot, ANE_H16_STARTUP), 0); + KUNIT_EXPECT_EQ(test, s->xl_writes, 0U); +} + +/* The T8132 boots with its own engine writes only: no XL or C1PPT. */ +static void ane_h16_t8132_tunables_test(struct kunit *test) +{ + struct ane_h16_sim *s = test->priv; + + sim_use_t8132(s); + KUNIT_ASSERT_EQ(test, ane_h16_run(&s->boot, ANE_H16_STARTUP), 0); + KUNIT_EXPECT_EQ(test, s->xl_writes, 0U); + KUNIT_EXPECT_EQ(test, s->engine[0], 0x8000001bU); + KUNIT_EXPECT_EQ(test, s->engine[0xdfc / 4], 1U); +} + +/* + * Within one power cycle the T8132 engine set stays locked: a second + * preparation writes nothing when the values match and refuses a changed one. + */ +static void ane_h16_t8132_locked_test(struct kunit *test) +{ + struct ane_h16_sim *s = test->priv; + u32 writes; + + sim_use_t8132(s); + KUNIT_ASSERT_EQ(test, ane_h16_prepare(&s->boot), 0); + writes = s->tuning_writes; + KUNIT_EXPECT_EQ(test, writes, s->expect_tuning); + KUNIT_EXPECT_EQ(test, ane_h16_prepare(&s->boot), 0); + KUNIT_EXPECT_EQ(test, s->tuning_writes, writes); + s->engine[0x4 / 4] ^= 0x10000; + KUNIT_EXPECT_EQ(test, ane_h16_prepare(&s->boot), -EPERM); +} + static struct kunit_case ane_h16_boot_cases[] = { KUNIT_CASE(ane_h16_alloc_reuse_test), KUNIT_CASE(ane_h16_happy_test), @@ -1231,6 +1323,11 @@ static struct kunit_case ane_h16_boot_cases[] = { KUNIT_CASE(ane_h16_dapf_program_test), KUNIT_CASE(ane_h16_dapf_partial_test), KUNIT_CASE(ane_h16_dapf_readback_test), + KUNIT_CASE(ane_h16_dapf_five_test), + KUNIT_CASE(ane_h16_dapf_five_readback_test), + KUNIT_CASE(ane_h16_no_xl_test), + KUNIT_CASE(ane_h16_t8132_tunables_test), + KUNIT_CASE(ane_h16_t8132_locked_test), KUNIT_CASE(ane_h16_unknown_revision_test), KUNIT_CASE(ane_h16_heap_overlap_test), KUNIT_CASE(ane_h16_native_free_test), diff --git a/drivers/accel/ane/ane_h16_preload_test.c b/drivers/accel/ane/ane_h16_preload_test.c index 184b444a539e1..2c023d8308250 100644 --- a/drivers/accel/ane/ane_h16_preload_test.c +++ b/drivers/accel/ane/ane_h16_preload_test.c @@ -295,14 +295,15 @@ static void preload_layout_select_test(struct kunit *test) * records frame cleanly when written at their offsets, and an identity no * other profile shares. Synthetic bytes never authenticate as a profile. */ -static void preload_profiles_test(struct kunit *test) +static void preload_profiles_check(struct kunit *test, const struct ane_h16_profile *profiles, + unsigned int count) { struct preload_fixture *f = test->priv; unsigned int i, j, k; - KUNIT_ASSERT_GT(test, ARRAY_SIZE(ane_h16_profiles), 0); - for (i = 0; i < ARRAY_SIZE(ane_h16_profiles); i++) { - const struct ane_h16_profile *p = &ane_h16_profiles[i]; + KUNIT_ASSERT_GT(test, count, 0); + for (i = 0; i < count; i++) { + const struct ane_h16_profile *p = &profiles[i]; const struct ane_h16_preload_rule *r = p->preload; u8 digest[SHA256_DIGEST_SIZE]; @@ -323,9 +324,27 @@ static void preload_profiles_test(struct kunit *test) ANE_H16_PRELOAD_DATA_SIZE), -ENOEXEC); for (j = 0; j < i; j++) { - KUNIT_EXPECT_NE(test, memcmp(r->digest, ane_h16_profiles[j].preload->digest, + KUNIT_EXPECT_NE(test, memcmp(r->digest, profiles[j].preload->digest, + SHA256_DIGEST_SIZE), 0); + KUNIT_EXPECT_STRNEQ(test, p->identity, profiles[j].identity); + } + } +} + +static void preload_profiles_test(struct kunit *test) +{ + unsigned int i, j; + + preload_profiles_check(test, ane_h16_profiles, ARRAY_SIZE(ane_h16_profiles)); + preload_profiles_check(test, ane_t8132_profiles, ARRAY_SIZE(ane_t8132_profiles)); + /* The T6041 and the T8132 never accept each other's firmware. */ + for (i = 0; i < ARRAY_SIZE(ane_t8132_profiles); i++) { + for (j = 0; j < ARRAY_SIZE(ane_h16_profiles); j++) { + KUNIT_EXPECT_NE(test, memcmp(ane_t8132_profiles[i].preload->digest, + ane_h16_profiles[j].preload->digest, SHA256_DIGEST_SIZE), 0); - KUNIT_EXPECT_STRNEQ(test, p->identity, ane_h16_profiles[j].identity); + KUNIT_EXPECT_STRNEQ(test, ane_t8132_profiles[i].identity, + ane_h16_profiles[j].identity); } } } From d569982326bdb06e98b559834df4ac6b7b3d0240 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 14 Nov 2026 21:37:43 -0500 Subject: [PATCH 9/9] arm64: dts: apple: j713: enable the Neural Engine The loader fills the ANE's firmware preload reservations from the ADT. Without them the driver reports that the preload was not handed off and leaves the engine alone. Signed-off-by: Erik Bourget --- arch/arm64/boot/dts/apple/t8132-j713.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8132-j713.dts b/arch/arm64/boot/dts/apple/t8132-j713.dts index cfaa76f22c4a7..440ecff14d4a1 100644 --- a/arch/arm64/boot/dts/apple/t8132-j713.dts +++ b/arch/arm64/boot/dts/apple/t8132-j713.dts @@ -293,3 +293,19 @@ phys = <&atcphy1 PHY_TYPE_USB3>; phy-names = "cio"; }; + +&ane_dart0 { + status = "okay"; +}; + +&ane_dart1 { + status = "okay"; +}; + +&ane_dart2 { + status = "okay"; +}; + +&ane { + status = "okay"; +};