Skip to content

kboot, dapf: hand off second AVE encoder (ave1) with per-encoder firmware CRCs - #538

Merged
RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/t6041-ave1-handoff
Nov 27, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/t6041-ave1-handoff

Conversation

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor

What: Add /arm-io/dart-ave1 to dapf_entries[] (under the ave1 DT alias, with tracking array headroom expanded from 8 to 16) and export aurora,ave-{text,data}-crc32 directly on each handed-over encoder DT node instead of disabling subsequent encoders whose preloaded firmware CRCs differ from /chosen.
Tested: J616c M4 Max at 5522f109 (paired with the companion Linux dual-encoder ave1 + per-node CRC series): both ave0 (video16) and ave1 (video17) hand over, probe, and pass H.264/HEVC 8-bit and 10-bit Main10 encode + 3 concurrent streams with 0 DART/IOMMU faults; test_ave_handoff.py (38/38 checks including J616c ave0+ave1 and dart-ave1 DAPF states), test_ave_text_dapf.py, and Stage 1 + ESP Stage 2 builds pass.
Risk: two-way door · M1 Max/Ultra, M4 Max (T6041), and other multi-encoder Macs; single-encoder Macs continue receiving /chosen CRCs unchanged.
Not yet: Live hardware test on M1 Max/Ultra or J614c (14" M4 Max); covered by unit tests in test_ave_handoff.py.

Details
  • src/dapf.c: registers /arm-io/dart-ave1 (DAPF aperture reg index 3, alias ave1) alongside /arm-io/dart-ave0 and widens dapf_programmed_paths/dapf_failed_paths from 8 to 16 entries. On boards without an enabled ave1 alias or without /arm-io/dart-ave1 in the ADT, dapf_init_fdt() skips it as before.
  • src/kboot.c: on T6041 (M4 Max), iBoot preloads independent firmware copies for /arm-io/ave0 and /arm-io/ave1 whose DATA CRC32s differ per instance and per boot. Removing the /chosen mismatch refusal and writing aurora,ave-<seg>-crc32 onto each handed-over encoder DT node lets every valid encoder come up while keeping the first handed-over encoder's CRCs mirrored in /chosen (without overwriting) for SMBIOS firmware inventory and older kernels that only read /chosen.
  • Cross-dependency: Works independently with existing kernels (which continue reading /chosen for ave0). Paired with the companion aurora-silicon/linux PR (pr/t6041-ave1-dual-encoder), Linux reads each encoder's per-node CRCs and enables both ave0 and ave1 on T6041.
Evidence
  • Commits on origin/main (8521ad7cf949):
    • 6b74964f2349 dapf: add dart-ave1 for the M4 Max second video encoder
    • 5522f1093c95 kboot: export per-encoder AVE firmware CRCs instead of disabling ave1
  • Offline checks:
    • USE_CLANG=1 pytest -v tests/python/test_ave_handoff.py tests/python/test_ave_text_dapf.py tests/python/test_dart_tunables.py tests/python/test_smp_handoff_gate.py: 4 passed (38/38 PASS: assertions in test_ave_handoff).
    • sh tests/run-pmp-boot-data.sh, sh tests/run-fdt-disable.sh, sh tests/run-aop-os-ram.sh, sh tests/run-t8122-gpu26-identity.sh: all pass.
    • make -j12 USE_CLANG=1 CHAINLOADING=1 and make -j12 USE_CLANG=1 ESP_STAGE2=1 CHAINLOADING=1: both build cleanly with 0 warnings in dapf.c/kboot.c.
  • Live hardware run (M4 Max J616c, Aura 1.0.0b17-g5522f109):
    • Both /video-codec@283100000 (ave0) and /video-codec@285100000 (ave1) handed over with distinct per-node aurora,ave-data-crc32 values while /chosen retained ave0's CRCs.
    • Both video16 (ave0) and video17 (ave1) passed H.264/HEVC 8-bit and 10-bit Main10 encode + 3 concurrent streams with 0 DART/IOMMU faults.

M4 Max (T6041) exposes a second AVE encoder (/arm-io/ave1) backed by
/arm-io/dart-ave1 with its DAPF aperture at reg index 3 (two 52-byte
slices, matching dart-ave0, verified against the J616c ADT).

Add /arm-io/dart-ave1 to dapf_entries[] under the ave1 DT alias so
dapf_init_fdt() programs its filter when the kernel DT enables ave1,
and expand the programmed/failed tracking arrays from 8 to 16 entries
so all eight dapf_entries[] have headroom.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
dt_set_ave_node() previously assumed every video encoder shared a single
pair of preloaded segment CRCs in /chosen and disabled any subsequent
encoder whose raw CRC32 differed from the first encoder handed over.

On M4 Max (T6041 / J616c), iBoot preloads independent firmware copies for
/arm-io/ave0 and /arm-io/ave1 whose DATA (and potentially per-load TEXT)
CRC32s vary per instance and per boot. As a result, dt_set_ave_node()
always disabled /video-codec@285100000 (ave1) before reserving its
memory-region segments, leaving only ave0 enabled for Linux.

Remove the /chosen CRC mismatch refusal and export aurora,ave-<seg>-crc32
directly on each handed-over encoder DT node. Continue mirroring the first
handed-over encoder's CRCs into /chosen when absent so SMBIOS firmware
inventory and kernels that only read /chosen remain compatible without
later encoders clobbering /chosen.

Update the differing-CRC scenario in test_ave_handoff.py and add a J616c
(T6041) regression scenario covering ave0+ave1 per-node CRCs and
dart-ave1 DAPF handoff states.

Signed-off-by: AxxzyWasTaken <axxzytte@gmail.com>
@AxxzyWasTaken
AxxzyWasTaken requested review from a team as code owners November 26, 2026 19:53
@github-actions github-actions Bot added blast:m1 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge readiness at 5522f109: not ready yet

Check Detail
CI at head ok 16 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 5522f109
Conflicts ok none
PR text ok Risk: two-way · M1 Max/Ultra, M4 Max (T6041), and other multi-encoder Macs; single-encoder Macs continue receiving /chosen CRCs unchanged.

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at 5522f1093c95

Blockers: none

Checked: Read the whole diff, both commits and the description. Nothing is gated on chip, board or firmware: dart-ave1 is a plain dapf_entries[] row under the ave1 alias (skipped when the alias or the ADT node is absent), and the per-node CRC export runs for every encoder dt_set_ave_node() hands over. Dropping the /chosen mismatch refusal is safe for the kernel: ave-fw.c still checks TEXT and DATA against a loader CRC before it runs anything, and an encoder whose copy differs from the /chosen one just fails that check on a kernel that only reads /chosen (no memory is lost: the reservations are made either way). /chosen is written only for the first encoder handed over and is never overwritten, so single-encoder Macs see the same /chosen as before plus the new per-node properties. The node offset is re-fetched by phandle before each fdt_setprop_string(), so the property writes do not use a stale offset. The tracking arrays grow from 8 to 16 with the existing bounds checks at dapf.c:890/894. Test 4 is changed to the new behaviour and test 13 covers the J616c layout (both encoders, differing DATA CRCs, dart-ave1 programmed/skipped/failed); the updated harness fails on main's kboot.c (negative control below), so it tests the change. DCO: human Signed-off-by on both commits, no AI trailers. No Apple binary/tuning data; the CRCs are checksums of the preloaded images as the existing tests already use. CI: all 16 checks green at this head.

Hardware: the J616c (M4 Max) row is at this head. dt_set_ave_node() is shared by every Mac with an encoder, so merge also wants one no-change regression boot at this head on a single-encoder Mac (our M1 Pro or M4 Air would do: encoder handed over, /chosen CRCs unchanged, encoder probes). Merge order: on a kernel without the per-node CRC lookup (linux#3304 is still open), a T6041 ave1 that is now handed over fails probe with "firmware data is not in its boot state", an error-level line it did not print before; landing linux#3304 first or together avoids that.

Non-blocking nits:

  • src/kboot.c (new export block): if the first encoder's /chosen export fails half-way (text written, data not), it is disabled but /chosen keeps its text CRC, and every later encoder then skips /chosen because one property exists. Only reachable with a full FDT, so cosmetic; checking both names, or writing /chosen only after all per-node props succeed, would close it.
  • src/dapf.c: with no ave1 alias in today's trees the new dart-ave1 row is skipped and dt_set_ave_dapf() programs that filter anyway (your test covers both); fine, but the commit message could say the row is only for trees that carry the alias.
Evidence
  • Local pytest 9.1.1 at 5522f109: test_ave_handoff.py, test_ave_text_dapf.py, test_dart_tunables.py pass; full tests/python (-n 6): 1222 passed, 27 skipped, 0 failed.
  • Negative control: this head's test_ave_handoff.py on an origin/main tree fails at its first per-node check (!strcmp(node_prop(0, M1_ENC0, "aurora,ave-text-crc32"), "460c7a7c")).
  • git merge-tree --write-tree origin/main pr538: clean.
  • Kernel side read on aurora-silicon/linux main: drivers/media/platform/apple/ave/ave-fw.c ave_fw_chosen_crc() reads only /chosen for aurora,ave-text-crc32 / aurora,ave-data-crc32.
  • gh pr checks 538: 16/16 pass.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Regression row, M1 Pro (T6000 / J316s, single AVE encoder), PASS. This head runs unchanged in a combined trial image.

  • Build: aura main bb66ebf + this PR 5522f10 + kboot: copy this Mac's PMP values onto aliasless PMP nodes and harden handoff #506 58dc33f, merged without conflicts. This PR's hunks are applied unchanged. ESP Stage 2 label 1.0.0b17-g242427d0, run as an aura-try one-shot on the M1 Pro's own DTB/U-Boot tail. Installed Stage 1 and the configured Stage 2 were not written.
  • Kernel: 7.3.0-aurora-fleet89 with its default command line, i.e. a kernel without linux#3304.
  • Result, booted twice: Enforcing, 0 failed units, 0 AVC denials, 0 kernel errors, 0 DART faults. apple-ave bound, 0 AVE errors. 120-frame H.264 and HEVC encodes are md5-identical to production (34097fe5c65d / 3f2914fa1277).
  • Device tree vs production: identical apart from per-boot values and the trial mark, plus this PR's new aurora,ave-text-crc32 on video-codec@40d100000. On this kernel the single-encoder path is unaffected, so this aura change alone is safe without #3304 on M1. The M4 Max second-encoder error noted in review still needs #3304 to land with or before this PR.
  • Production restored afterwards and verified.

Evidence (buildbox): traces/boot/20261127-merge-blitz-aura/ (README, rows, DT property hashes, Stage 1/2 logs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:m1 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants