Skip to content

accel/ane: send both custom BARs of a scratch-backed H16 program - #1061

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
ane/h16-mixed-custom-bars
Nov 7, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
ane/h16-mixed-custom-bars

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What

A scratch-backed H16 program (the 0x8c0 descriptor form, used when the compiler spills L2 intermediates to DRAM) declares two custom-BAR relocation tuples: the prefetch tuple that the linear 0x8a0 form also has, and an intermediate-spill tuple in the kind-3 payload. ane_h16_custom_bars() returned no record for this form, so its EXECUTEs carried no custom BAR.

The first request of a program is queued through EXELOOP, which sets up a fresh BAR context; later requests go direct and reuse it. Without the records, the direct second request of a scratch-backed program reads through an unrelocated selector. On the J616s (T6041, M4 Pro) that showed up as DART read faults at 0x21_xxxx_xxxx followed by a firmware program quarantine.

This change:

  • decodes both tuples and sends two records, both on BAR 4 with the program's DSID;
  • lets two records overlap when their mcache value types differ (the two records here overlap in bit range but use type 0 and type 1);
  • drops the info message on the first request of each program (each load already logs).

One commit, 3 files under drivers/accel/ane/, +73/-17. KUnit cases cover both decoded records and the two-record EXECUTE tail on the queued and direct paths.

Hardware evidence (J616s, T6041, kernel 7.3.0-aurora-fleet17 with these modules, one-shot boots)

  • Two-task scratch-backed program with one DRAM spill: 2/2 runs bit-exact against the CPU reference (458752/458752 outputs, 0 ulp). The second execution takes the direct path, 0 DART faults. The firmware log shows both custom-BAR records on the queued first EXECUTE and on the direct second one.
  • Two-task L2-resident program: 2/2 runs bit-exact, 0 DART faults.
  • Regression, MobileNet v2 package currently in use: 5 runs, 16/16 correct each. p50 latency 0.566 / 0.654 / 0.568 / 0.678 / 0.602 ms against 0.649 / 0.596 / 0.565 / 0.651 / 0.571 ms on the unpatched driver the same day, i.e. at parity (both show the engine's usual fast/slow batch modes). Submit to ack 0.14-0.15 ms against 0.09 ms, which is the queued first request.
  • ANE gate: 3 s2idle cycles, resume 13-14 ms, a fresh LOAD after resume gives identical output.
  • 0 DART faults, 0 quarantines, no new -p3 messages, 33 kernel log lines per 5 runs against 30 unpatched, SELinux enforcing with 0 AVCs.

The full 28-task MobileNet L2-spill program is still wrong with this change. The sentinels above show the BAR setup is now right, so that remaining fault is in the compiler's program and is tracked there, not in this driver.

Checks

  • checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks.
  • ANE KUnit (kunit.py, x86_64 QEMU, KASAN+UBSAN), base f9ce365 vs this commit: transport config 205/205 on both, boot config 205/205 with the patch; all 35 ane-h16-program cases pass.
  • W=1, arm64 clang 22, fleet config: drivers/accel/ane compiles with 0 warnings.

🤖 Generated with Claude Code

A scratch-backed H16 program uses the 0x8c0 descriptor form. Besides
the prefetch relocation tuple that the linear 0x8a0 form also has, it
carries a second tuple for the intermediate-spill stream in the kind-3
payload at +0x890. ane_h16_custom_bars() returned no record for that
form, so an EXECUTE of such a program carried no custom BAR at all.

The first request of a program takes the queued EXELOOP path, which
sets up a fresh BAR context; later requests go direct and reuse it.
Without the BAR records, the direct second request of a scratch-backed
program reads through an unrelocated selector: on a T6041 (M4 Pro) the
engine raised DART read faults at 0x21_xxxx_xxxx and the firmware
quarantined the program.

Decode both tuples and send two records, both on BAR 4 with the
program's DSID. Their bit ranges overlap but they use different mcache
value types, so the request validator now treats two records as
conflicting only when they also share the value type.

Drop the info message on the first request of each program. Each load
already logs, and the line added nothing.

Tested on a T6041 (J616s) on a 7.3 kernel with this change: a two-task
scratch-backed program with one DRAM spill and a two-task L2-resident
program both run bit-exact on two executions each, the second one on
the direct path, with no DART faults. A MobileNet v2 program ran 16/16
correct in five runs with p50 latency at parity with the unpatched
driver, the suspend/resume gate passed, and there were no new SELinux
denials.

Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide merged commit d79428c into integration/aurora Nov 7, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the ane/h16-mixed-custom-bars branch November 7, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant