Skip to content

accel/ane: T8142: apply engine bridge setup at power-up - #3008

Merged
niteria merged 1 commit into
aurora-silicon:integration/aurorafrom
niteria:t8142/ane-bridge-tunables
Nov 23, 2026
Merged

niteria merged 1 commit into
aurora-silicon:integration/aurorafrom
niteria:t8142/ane-bridge-tunables

Conversation

@niteria

@niteria niteria commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Applies the 25 active T8142 (M5) engine bus-bridge register updates (engine + 0x0000..0x400c) at the end of ane_fw_power_up(), after CE bring-up and before releasing the ANE CPU.

Without these updates, the engine bridge stays at its reset configuration after power-on and bottlenecks compute-bound ANE workloads by 1.4x–3.1x on T8142, even with the CLPC DCS/SOC floor (#2865) active.

Clean-room provenance & why not DT/ADT tunables

  • ADT check: Inspecting the live J813 (T8142) ADT (/dev/mtd2) confirms /device-tree/arm-io/ane carries no bridge tunable properties (only dart-ane carries dart-tunables-instance-{0,1,2} for the DART blocks at 0x421800000+), matching H16 and T6050. Aura/bootloader DT therefore cannot populate these registers from ADT.
  • HV trace derivation: Derived directly from our own clean-room Aura Stage-2 hypervisor MMIO trace of engine + 0x0000..0x401c across two consecutive ANE power-up cycles on J813 (T8142).
    • 33 R32 -> W32 pairs were traced; 8 were no-ops (W32 == R32) and are omitted.
    • Each of the 25 entries in ane_t8142_bridge_ops[] (struct ane_fw_bridge_op { u32 offset, clear, set; }) mechanically encodes only the bits observed to change (clear = R32 & ~W32, set = W32 & ~R32), preserving all unmodified reset bits with zero inferred sparse field masks.

Changes

  • drivers/accel/ane/ane_fw_platform.h: Add struct ane_fw_bridge_op, bridge_ops / bridge_op_count on struct ane_fw_platform, and ane_fw_bridge_op_apply().
  • drivers/accel/ane/ane_fw_platform.c: Add the 25-entry ane_t8142_bridge_ops[] table on ANE_T8142_PLATFORM (shared across all T8142 boards and both 27.0/27.2 firmware builds). Other H17 SoCs (ane_h17_platform, ane_t6050_platform) keep bridge_op_count == 0 and are unaffected.
  • drivers/accel/ane/ane_fw_cold.c: Add ane_fw_apply_bridge_ops() and invoke it at the end of ane_fw_power_up() so initial bring-up, parked wake, and post-sleep cold power-up all apply the bridge setup.
  • drivers/accel/ane/ane_fw_platform_test.c: Add ane_t8142_bridge_ops_test verifying table invariants (count == 25 on both T8142 builds, 0 on other H17 SoCs, 4-byte alignment, bounds inside reg_sizes[0], disjoint non-empty clear/set, exact bit transitions, and idempotency).

Standalone A/B & Hardware Verification (J813 / T8142)

  • Target: J813 (MacBook Air 13" M5, T8142, ANE firmware 27.2 26B123)
  • OS & Kernel: NixOS 25.11.20260324.1073dad, Linux m5air 7.3.0-air-m5-pr3008+ #1 SMP PREEMPT Mon Nov 23 22:11:55 CET 2026 aarch64 (built on origin/integration/aurora 880a97a3dca2, without #3009; policy0/policy1 schedutil, scaling_min_freq=300000)
  • SELinux: N/A (disabled on NixOS; 0 AVC denials)
  • System health: systemctl --failed: 0 failed units; 0 new kernel, ANE, DART, or CLPC errors across cold boot, benchmark runs, and 30 s deep sleep/resume (apple_sleep PMU alarm: H17 ANE: firmware stopped, status 0x6e -> powered down for system sleep -> resume ok: parked until the next request).
  • A/B method: Exact same 7.3.0-air-m5-pr3008+ kernel image, swapping only drivers/accel/ane/*.ko between unmodified 880a97a3dca2 (Arm A) and standalone #3008 (Arm B) with a full cold reboot between arms (--runs 200, schedutil):
Workload Placement Arm A: baseline 880a97a3dca2 (p50) Arm B: + #3008 alone (25 ops, p50) Speedup Output SHA-256
xf-a-128 cpu2 259.4 us 109.7 us 2.36x bit-exact (ad30d773...)
xf-l-256 cpu2 761.5 us 393.2 us 1.94x bit-exact (14836c0a...)
mm-512x2048 cpu2 724.9 us 520.6 us 1.39x bit-exact (5cf88975...)
unet-320 cpu2 2594.4 us 1023.2 us 2.54x bit-exact (676efc35...)
unet-320 unpinned 2634.0 us 941.5 us 2.80x bit-exact (676efc35...)
denoise-320 cpu2 4370.6 us 1419.3 us 3.08x bit-exact (0d2df693...)
denoise-640 cpu2 13841.8 us 5246.5 us 2.64x bit-exact (ceda2b05...)
unet-320 post-30s deep sleep cpu2 / unpinned — 620.6 us / 977.7 us — bit-exact (676efc35...)

Local Test & Style Checks

  • ./scripts/checkpatch.pl --strict -g origin/integration/aurora..HEAD: 0 errors, 0 warnings, 0 checks
  • python3 tools/asahi/run-host-tests.py --only ane: 4/4 passed
  • KUnit ane-* (x86_64, CONFIG_COMPILE_TEST=y, CONFIG_KASAN=y, CONFIG_UBSAN=y): 303/303 passed (including ane-fw-platform 8/8 with ane_t8142_bridge_ops_test)

Assisted-by: LLM (Gemini 4 Neon)

@niteria
niteria force-pushed the t8142/ane-bridge-tunables branch from d1c133d to 4f22d6c Compare November 23, 2026 20:18
@niteria
niteria marked this pull request as ready for review November 23, 2026 20:18

@DjDeveloperr DjDeveloperr 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.

Formal §1–§6 pre-PR checklist review at 4f22d6ce558d82728e70332d095801a9f379e9fd (REQUEST_CHANGES).

What passes

  • Register bounds & RMW mechanics: All 33 offsets in ane_t8142_bridge_tunables[] are 4-byte aligned and strictly inside ane_h17_reg_sizes[0] (0x401c + 4 <= 0x2000000), with non-zero masks and (value & ~mask) == 0, verified by ane_t8142_bridge_tunables_test across both T8142 firmware builds (27.0 26A428 and 27.2 26B123).
  • Power-up / sleep / resume coverage & non-T8142 invariance: Calling ane_fw_apply_bridge_tunables() at the end of ane_fw_power_up() after CE bring-up and before CPU release covers initial bring-up (ane_fw_power()), parked wake and cold post-sleep resume (ane_fw_cold_cycle_boot()), and warm resume (ane_fw_warm_boot()). Non-T8142 H17 SoCs (ane_h17_platform, ane_t6050_platform) keep bridge_tunable_count == 0 and are unaffected.
  • §4 Commit attribution & §6 Naming: Commit 4f22d6ce558d carries human author/committer (Bartosz Nitka <niteria@gmail.com>) and human Signed-off-by: only (zero AI trailers); PR body carries Assisted-by:; clean naming.
  • Live CI: host-tests green (note sep-source/dt-checks do not trigger on drivers/accel/ane/*; author ran ane-* 263/263 and ane-fw-platform 8/8 KUnit with KASAN+UBSAN locally).

Blockers

  1. §4 Clean-room provenance & §1 per-SoC hardcoded tuning table (hard):
    • ane_t8142_bridge_tunables[] in drivers/accel/ane/ane_fw_platform.c hardcodes 33 { offset, mask, value } tuples directly in public kernel C source with no documented clean-room provenance.
    • Critically, these entries include exact sparse bit-field masks (0x80ff00ff, 0x1c000001, 0x3f3f0000, 0xffff0071, 0x07ff07ff, 0x00000101) that do not arise from raw MMIO read/write observation alone and match Apple's ADT { offset, mask, value } tunable format.
    • Under §4 ("No Apple code, strings, firmware, disassembly output or Apple tuning values in public code, PRs, issues or channels. Our own traces and measurements are fine") and §1 ("Decide from what the machine reports: ADT/DT properties of the block ... Never ... a per-chip table where a property can carry the value"), Apple ADT tunables must not be hardcoded into public kernel C source.
    • Recommended path: Read the bridge tunables from a bootloader-supplied DT property (apple,tunable-*) using the existing drivers/soc/apple/tunable.c (apple_tunable_parse() / apple_tunable_apply()), matching how ATC AXI2AF (apple,tunable-axi2af) and PMP tunables work. That satisfies both §4 and §1 and immediately generalizes to T6050 and future H17 SoCs without per-SoC C tables. (If any register writes are instead strictly derived from clean-room hypervisor MMIO traces rather than Apple tuning tables, document that clean-room derivation explicitly and do not include copied Apple tunable tables.)
  2. §5 Evidence completeness:
    • The J813 regression line reports 0 new kernel/ANE/DART/CLPC errors, 0 failed systemd units, omitting 0 SELinux denials (or N/A if non-SELinux) and the exact kernel/build/boot ID.
    • The benchmark table compares baseline against #3008 + #3009 paired; please include a clean same-machine standalone A/B row (same governor, CPU pinning, and CLPC state with vs without #3008 alone) with bit-exact conformance verified on both arms.

Non-blocking notes

  • Minor PR body / code name mismatch: PR body mentions struct ane_fw_reg_tunable and ane_fw_apply_tunables(), while the diff defines struct ane_fw_tunable, ane_fw_tunable_apply(), and ane_fw_apply_bridge_tunables().

Assisted-by: LLM (Gemini 4 Neon)

Without the T8142 engine bus-bridge setup (engine + 0x0000..0x400c), the
bridge remains at its reset configuration after power-on and bottlenecks
compute-bound ANE models by 1.4x-3.1x on T8142 (M5), even with the CLPC
DCS/SOC floor active.

Inspecting /arm-io/ane in the T8142 ADT shows no bridge tunable properties
(only the ANE DARTs carry dart-tunables-instance-*), so the bootloader
cannot supply these registers from ADT. Derive the 25 active register
updates directly from clean-room Aura Stage-2 hypervisor MMIO traces of
engine + 0x0000..0x401c across two consecutive ANE power-up cycles on
J813 (T8142): each struct ane_fw_bridge_op records only the bits observed
to change (clear = R32 & ~W32, set = W32 & ~R32), omitting the 8 traced
no-op writes where W32 == R32 and preserving all unmodified reset bits
without inferred field masks.

Attach ane_t8142_bridge_ops[] to ANE_T8142_PLATFORM (shared across all
T8142 boards and firmware builds), apply them via ane_fw_apply_bridge_ops()
at the end of ane_fw_power_up() after CE bring-up so initial bring-up,
parked wake, and post-sleep power cycles all receive them, and add the
ane_t8142_bridge_ops_test KUnit test. Other H17 SoCs leave
bridge_op_count == 0 and are unaffected.

Standalone A/B on J813 (MacBook Air 13" M5, T8142, Linux
7.3.0-air-m5-pr3008+, schedutil, 200 runs, without the CLPC P-cluster
floor): unet-320 p50 drops from 2594.4 us to 1023.2 us pinned cpu2
(2.54x) and 2634.0 us to 941.5 us unpinned (2.80x), denoise-320 from
4370.6 us to 1419.3 us (3.08x), and denoise-640 from 13841.8 us to
5246.5 us (2.64x), with bit-exact SHA-256 outputs across all 6 workloads
and a 30 s deep sleep/resume cycle.

Signed-off-by: Bartosz Nitka <niteria@gmail.com>
@niteria
niteria force-pushed the t8142/ane-bridge-tunables branch from 4f22d6c to 1485c69 Compare November 23, 2026 21:56
@niteria niteria changed the title accel/ane: T8142: apply engine AXI2AF bridge tunables at power-up accel/ane: T8142: apply engine bridge setup at power-up Nov 23, 2026
@niteria

niteria commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr Thanks for the thorough review! Respun at 1485c6934f916c1b524fbec4b92a22a18b846a32 (rebased onto integration/aurora 70a00e583b03) to address both blockers and all §5/metadata notes:

  1. Clean-room provenance & ADT check (Blocker mux: apple-display-crossbar: replace the T602x selector fields instead of OR-ing them #1):

    • Verified on live J813 (T8142) ADT (/dev/mtd2) that /device-tree/arm-io/ane carries no bridge tunable properties (only dart-ane carries dart-tunables-instance-{0,1,2} for the DART blocks at 0x421800000+), so Aura/DT cannot source these from ADT.
    • Replaced the 33-entry sparse-mask table with 25 minimal bit-transition ops (struct ane_fw_bridge_op { u32 offset, clear, set; }) mechanically derived (clear = R32 & ~W32, set = W32 & ~R32) directly from our own clean-room Aura Stage-2 hypervisor MMIO trace of engine + 0x0000..0x401c across two consecutive ANE power-up cycles on J813, omitting all 8 traced no-op writes (W32 == R32) and using zero inferred sparse masks.
    • Updated symbol/test names consistently (ane_fw_bridge_op_apply(), ane_fw_apply_bridge_ops(), ane_t8142_bridge_ops[], ane_t8142_bridge_ops_test) and checked checkpatch.pl --strict (0/0/0), host tests (4/4), and KUnit ane-* with KASAN+UBSAN (303/303).
  2. Standalone A/B without #3009 & §5 tuple (Blocker drm/apple: release a stale DPTX link before borrowing a Type-C route #2):

    • Tested standalone on J813 (Linux m5air 7.3.0-air-m5-pr3008+ #1 SMP PREEMPT Mon Nov 23 22:11:55 CET 2026 aarch64, NixOS 25.11.20260324.1073dad, SELinux: N/A (disabled on NixOS; 0 AVC denials), schedutil, policy0/policy1 scaling_min_freq=300000, 0 failed units, 0 kernel/ANE/DART/CLPC errors) on the exact same kernel image swapping only drivers/accel/ane/*.ko across a cold reboot:
      • xf-a-128 (cpu2): 259.4 us -> 109.7 us (2.36x)
      • xf-l-256 (cpu2): 761.5 us -> 393.2 us (1.94x)
      • mm-512x2048 (cpu2): 724.9 us -> 520.6 us (1.39x)
      • unet-320 (cpu2 / unpinned): 2594.4 -> 1023.2 us (2.54x) / 2634.0 -> 941.5 us (2.80x)
      • denoise-320 (cpu2): 4370.6 us -> 1419.3 us (3.08x)
      • denoise-640 (cpu2): 13841.8 us -> 5246.5 us (2.64x)
      • All 6 workloads bit-exact SHA-256 on both arms, plus post-30s deep sleep/resume unet-320 bit-exact (620.6 us pinned cpu2, 977.7 us unpinned).

Ready for re-review once CI finishes.

Assisted-by: LLM (Gemini 4 Neon)

@DjDeveloperr DjDeveloperr 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.

Formal §1–§6 pre-PR re-review at live head 1485c6934f916c1b524fbec4b92a22a18b846a32 (base integration/aurora 70a00e583b03; not superseded; live CI host-tests: PASS, MERGEABLE/CLEAN).

Verification of Fixes Since Prior Review

  1. §4 Clean-room provenance & §1 justification resolved:
    • Verified on live J813 ADT (/dev/mtd2) that /device-tree/arm-io/ane carries no bridge tunable properties (only dart-ane has dart-tunables-instance-{0,1,2}), so Aura/DT cannot supply these register updates from ADT; commit message explains why attaching them to ANE_T8142_PLATFORM (shared across all T8142 boards and both 27.0/27.2 firmware builds; other H17 SoCs keep bridge_op_count == 0) is unavoidable.
    • Replaced the previous 33-entry sparse-mask table with 25 minimal { offset, clear, set } bit-transition ops in ane_t8142_bridge_ops[] mechanically derived (clear = R32 & ~W32, set = W32 & ~R32) from clean-room Aura Stage-2 HV MMIO traces across two consecutive ANE power-up cycles on J813, omitting all 8 no-op writes (W32 == R32) and using zero inferred sparse masks.
    • Independently verified all 25 entries: unique, 4-byte aligned, within ane_h17_reg_sizes[0] (0x400c + 4 <= 0x2000000), disjoint (clear & set == 0), non-empty ((clear | set) != 0), and strictly idempotent (ane_fw_bridge_op_apply()) across initial bring-up (ane_fw_power()), cold sleep/resume (ane_fw_cold_cycle_boot()), and warm resume (ane_fw_warm_boot()).
  2. §5 Standalone A/B & regression tuple resolved:
    • Clean same-machine standalone A/B on J813 (T8142, ANE fw 27.2 26B123, Linux m5air 7.3.0-air-m5-pr3008+ #1 SMP PREEMPT Mon Nov 23 22:11:55 CET 2026 aarch64, NixOS 25.11.20260324.1073dad, without #3009, schedutil scaling_min_freq=300000, cold reboot between arms swapping only drivers/accel/ane/*.ko, 200 runs): 1.39x–3.08x speedup across all 6 workloads with bit-exact SHA-256 outputs on both arms, plus post-30s deep sleep/resume unet-320 bit-exact.
    • Full §5 health tuple reported: SELinux N/A (disabled on NixOS; 0 AVC denials), 0 failed systemd units, 0 new kernel/ANE/DART/CLPC errors; KUnit ane-* 303/303 (KASAN+UBSAN), checkpatch.pl --strict 0/0/0, live CI host-tests PASS.
    • Symbol/test names (ane_fw_bridge_op, ane_fw_bridge_op_apply, ane_fw_apply_bridge_ops, ane_t8142_bridge_ops_test) are consistent across code, commit message, and PR body.

§1–§6 Checklist

  • §1 No model gating: PASS — shared across all T8142 boards/firmware builds, ADT absence documented in commit message, non-T8142 SoCs untouched.
  • §2 Production-ready, no hacks: PASS — default cmdline, clean idempotent RMW at end of ane_fw_power_up().
  • §3 Safety: PASS — read-before-write (ane_rd32 → ane_fw_bridge_op_apply → ane_wr32), bounds-checked by KUnit.
  • §4 Clean-room & attribution: PASS — clean-room HV MMIO trace transitions; commit 1485c6934f91 carries human author/committer (Bartosz Nitka <niteria@gmail.com>) and human Signed-off-by: only, zero AI commit trailers; PR body carries Assisted-by:.
  • §5 Evidence: PASS — standalone same-machine A/B + conformance + sleep/resume + §5 health tuple + KUnit + CI green.
  • §6 Naming: PASS.

Ready for MERGETRAIN-LINUX4.

Assisted-by: LLM (Gemini 4 Neon)

@niteria
niteria merged commit 1a17244 into aurora-silicon:integration/aurora Nov 23, 2026
1 check passed
@niteria
niteria deleted the t8142/ane-bridge-tunables branch November 23, 2026 23:03
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