Repository navigation
media: apple: ave: run the M2 encoder's macOS 27.2 firmware build - #2904
Conversation
On an M2 Mac with the macOS 27.2 (26B123) stub, as on the Mac mini
(J473), the bootloader preloads a newer encoder firmware build than the
one the T8112 variant knows: TEXT 0x11c000 instead of 0xd0000, DATA
0x128000. The driver refused it at probe ("unexpected firmware segment
sizes"), so the encoder never registered. Like the M4's 27.2 loaders,
the Mac mini's sets the word at TEXT 0x4224 on every boot; with it
zeroed the TEXT CRC is 077a3444.
That build is the M2 encoder's build of the firmware version the M3
already runs on 27.2, and it starts the way the M3's does: the boot
configuration handshake as device 12 with handshake type 12, the 26B123
command layout and its reference buffer sizing (lfs_ref_scale 2, as on
the M3 and M4), the codec clocks ungated by clearing the mailbox idle
word, the bootloader's code base (marked valid) left in place, and DATA
restored from the boot snapshot before every start. None of the 13.5
build's start (device 18/type 15, the TEXT link cell, the extra0 window)
applies to it.
Describe it as its own variant and let a variant name the variant of a
later build of the same encoder (next_build). At probe the firmware
reservations the bootloader made select the build by their segment
sizes; the TEXT CRC then has to be that build's. Like the command
layouts, which the TEXT CRC already selects, this keys on the firmware
build because it must: the start and the command protocol belong to the
build the bootloader handed over, and only its segments identify it. The
13.5 build keeps its variant and start, other sizes are still refused,
and no other variant changes.
KUnit covers the selection (13.5 sizes, 27.2 sizes, near misses), the
27.2 variant's start fields, its per-boot TEXT word (any value gives the
zeroed-word CRC) and its layout lookup.
Signed-off-by: Ryan Murray <[email protected]>
|
Review at 4d459a4. Thanks, this reads well. The build is picked from what the bootloader handed over (reserved segment sizes, then the TEXT CRC), inside the one
Testing: I checked that the driver code at this head matches the tested 9842c441 apart from comments and KUnit, so the J473 and M2 Air rows carry over. Two rows would round it off: an encode on the J473 after a system suspend/resume (only runtime suspend is listed), and, since the shared 26B123 layout condition was edited (ave-layout.c:997-999), a probe plus one encode at this head on a J615 or J713. If another M2 board gets a 27.2 stub later (J413/J493), a probe row there would confirm the path where the loader leaves the 0x4224 word at zero. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR checklist (§1–§6) review at 4d459a41e9f9e5723f49cb61f2a2dceef83614e1.
Code & safety audit
drivers/media/platform/apple/ave/ave-drv.c:559-589&ave-fw.c:239-290: Verifiedave_probe()does not read any field ofave->variantbeforeave_fw_probe(), andave_fw_probe()callsave->variant = ave_fw_select_build(ave->variant, ave->text.size, ave->data.size)before readingtext_crc,boot_qualified,build_count, or segment sizes.ave_fw_select_build()walks the staticnext_buildchain (ave_t8112 -> ave_t8112_26b123 -> NULL) by bootloader-reservedTEXT/DATAsizes and falls back to the head variant on near-misses, so unexpected sizes still fail closed with-EINVAL.ave_t8112_26b123(TEXT 0x11c000,DATA 0x128000, device/type 12,lfs_ref_scale = 2,text_boot_word = 0x4224,vcbar_flags = AVE_COPROC_VCBAR_VALID,mbox_idle = 0x38,restore_data_first = true,extra0_size = 0) andave_layout_for_crc(AVE_FW_TEXT_CRC_T8112_26B123) -> &ave_layout_26b123are consistent with the M3 27.2 build andave_fw_text_boot_crc()bounds checks.ave-abi-test.c:ave_t8112_26b123_buildcovers 13.5 selection, 27.2 selection, near-miss rejection, variant fields, per-boot word zeroing at0x4224, and layout lookup.
Checklist summary (§1–§6)
- §1 No model gating: Pass — selects strictly from bootloader-reserved firmware segment sizes + TEXT CRC (not chip/board/macOS-version checks); commit message documents why per §1.
- §2 Production-ready: Pass — default command line, no module parameters, delays, or workarounds.
- §3 Safety: Pass — fail-closed on unknown sizes/CRCs, bounds-checked
text_boot_word, DATA snapshot restored cleanly. - §4 Clean-room & attribution: Pass — single commit
4d459a41e9f9has human author/committer and humanSigned-off-by:only, no AI trailers in commit,Assisted-by:at end of PR body. - §5 Evidence: Pass — J473 (M2, 27.2 stub, default fleet82 cmdline) 12/12 H.264/HEVC encodes (including 4K, 720p, B-frames, post-runtime-suspend) with 120/120 bit-exact AVD decodes, 0 DART faults, 0 encoder errors, 0 AVC denials (Enforcing); M2 Air (13.5 firmware) 6/6 md5-identical no-regression proof vs stock module; 47/47 arm64 KUnit + host ABI tests +
checkpatch --strictclean at this head (driver code unchanged from9842c441). - §6 Naming: Pass.
- CI (holding approval here only):
host-testsis currentlyin_progresson4d459a41e9f9.
Zero code or policy blockers; holding APPROVE strictly until host-tests completes green on 4d459a41e9f9.
Assisted-by: LLM (Gemini 4 Neon)
DjDeveloperr
left a comment
There was a problem hiding this comment.
host-tests is now green (SUCCESS) on 4d459a41e9f9e5723f49cb61f2a2dceef83614e1. All §1–§6 checklist gates pass (firmware-selected 27.2 build by reserved segment sizes + TEXT CRC, no chip/board gate, KUnit coverage, human-only commit trailers, strong J473 27.2 + M2 Air 13.5 HW proof). Approving for MERGETRAIN-LINUX4.
Assisted-by: LLM (Gemini 4 Neon)
|
Review at 4d459a4: no blockers. Re-checked the single commit at this head. None of the four points from the earlier 4d459a4 review has an answer on the PR or a change in the tree (the head is the same commit), and none of them is a blocker:
Other checks: ave_fw_select_build() returns the variant it was given for every variant without next_build, and the ave_layout_for_crc() edit only adds a CRC to the 26B123 OR, so the T8122 and T8132 CRCs map to the same layout as before. Selection is by bootloader-reserved segment sizes and then the TEXT CRC, inside the apple,t8112-ave match: no board, chip or version gate, no parameter, default cmdline. No pointer-identity checks on ave->variant elsewhere. mergeable_state clean, host-tests green at this head. Rows still owed (none posted on the PR since the earlier review):
Assisted-by: LLM (Claude:Opus 5.5) |
|
Follow-up for the review at 4d459a4, pushed as e3cad61 (one commit on top, no force push):
arm64 KUnit for Rows at e3cad61. The module was built from this head's
Still to run: the J473 encode after s2idle at this head. It's queued behind two other rows on that Mac. Detail
Assisted-by: LLM (Claude:Opus 5.5) |
|
J473 row at e3cad61, the last one owed. Mac mini J473 (M2, macOS 27.2 stub), default fleet82 boot, default cmdline, one module swap built from this head:
With this row, every row asked for in review is posted at this head: J473 27.2 (encode + s2idle), M2 Air 13.5 (stock-identical + s2idle), J615 26B123 (stock-identical). @DjDeveloperr, your approval was at 4d459a4. e3cad61 only adds the review follow-ups (comment, predicate reuse with the same expression, sizes in the refusal message, KUnit), so please re-check it at this head. Assisted-by: LLM (Claude:Opus 5.5) |
|
Correction to my two comments above: this PR was merged at 4d459a4 before e3cad61 reached the branch, so the follow-up commit is not in integration/aurora. It's now #2938 (the same commit, with the rows above). The merged code here is unchanged by it apart from the refusal message, which now prints sizes. Assisted-by: LLM (Claude:Opus 5.5) |
Problem
On an M2 Mac booted with the macOS 27.2 (26B123) stub, such as the Mac mini (J473), the encoder never registers. The bootloader preloads a newer AVE firmware build (TEXT 0x11c000, DATA 0x128000), and the T8112 variant only knows the 13.5 build (TEXT 0xd0000), so probe stops with "unexpected firmware segment sizes".
Change
The 27.2 build gets its own T8112 variant, and
ave_t8112points to it through a newnext_buildlink. The 27.2 build starts the way the M3's 27.2 build does: device 12 / type 12 handshake, the 26B123 command layout, lfs_ref_scale 2, a per-boot word at TEXT 0x4224 left out of the CRC, DATA restored before every start. The segment sizes of the firmware reservations the bootloader made pick the build, and the TEXT CRC must then match that build. The 13.5 build's variant and start do not change, other sizes are still refused, and no other variant changes. KUnit covers the selection, the new variant's start fields, the per-boot word and the layout lookup.Behaviour comes from the firmware the bootloader handed over (its reserved segment sizes and TEXT CRC), the same way the command layouts are already chosen. There is no board or chip gate and no new parameter.
Testing
v4l2h264enc/v4l2h265encand ffmpegh264_v4l2m2m/hevc_v4l2m2mgave 12/12 encodes, and two runs gave byte-identical bitstreams. The AVD hardware decode of every bitstream matched a software decode bit for bit (120/120 frames, 6/6 streams). PSNR at 8 Mb/s 1080p30: H.264 45.0 dB, HEVC 45.9 dB. Also tested: 4K, 720p (Main and Baseline), 1366x768, H.264 High with B-frames, and an encode after runtime suspend. No DART faults, no encoder errors, no AVC denials.drivers/media/platform/apple/ave: 47/47 pass at this head. The host ABI tests (run.py, run-recovery.py) pass. checkpatch --strict is clean.Still to run
Row detail
video/x-h264,profile=highwithvideo_b_frames=2gave 86 B / 5 I / 29 P frames, has_b_frames=2, 40.7 dB. High with b=0 gave 40.6 dB. ffmpeg-profile:v 100gave 45.0 dB. All three streams decode bit-exact on the AVD (120/120).-f framemd5software decodes on an x86 build host. PSNR is raw NV12 against raw NV12 at the same frame rate.Assisted-by: LLM (Claude:Opus 5.5)