Repository navigation
Conversation
T6000 and T8112 run the 6070.11.1 Start and Process commands that were qualified on hardware byte for byte. Nothing tests that those bytes stay the same when the shared 6070 writer changes for another chip. Add a KUnit case that builds Start and the first two Process commands for H.264 and HEVC, at 1280x720 30/1 and 1920x1080 30000/1001, with default session parameters, and compares their CRC32 with the values the builder produces at this commit. Assisted-by: Grok 4.7 Assisted-by: Claude Opus 5.5 Signed-off-by: Lucas Goossen <[email protected]>
Every instance creates the debugfs directory apple-ave. On a machine with two encoders the second one fails to create it and has no lifecycle_test, inject_wedge or last-command files. Name the directory apple-ave-<device name>, for example apple-ave-40d100000.video-codec, and update the two documents that give the old path. The path changes on every chip. Assisted-by: Grok 4.7 Assisted-by: Claude Opus 5.5 Signed-off-by: Lucas Goossen <[email protected]>
|
Thanks for the T6021 encoder bring-up. The pinned-bytes KUnit case is a nice way to show T6000 and T8112 are untouched. One convention point. We select behaviour by a hardware or firmware property, not by the list of machines it was run on. If the two-session capacity comes from the larger T6021 firmware build (its bigger DATA, for example), please say so in a comment at A small note: the quarantine growth while one session stays open has no cap. A bound or a log line would help. |
|
Thanks, this is careful work. The parts that let one driver serve several encoders are general: a debugfs directory per device, a CRC and an
We will run no-regression rows for commits 2-4 on M1 Pro and M2: bind on today's loader, |
A boot loader that hands over two encoders cannot name both DATA images with the one /chosen aurora,ave-data-crc32 property, and the encoders share one TEXT reservation, so its iommu-addresses property carries one tuple per encoder. Read aurora,crc32 from each memory-region reservation and fall back to the /chosen property when it is absent. Accept several iommu-addresses tuples and use the one whose phandle is this device; a reservation with none, or with two for this device, is refused as before. Describe the reservation property in the admin guide, next to the /chosen ones. Every chip goes through this code. With today's boot loader (no aurora,crc32, one tuple per reservation) it does what it did before; only T6021 was run. Assisted-by: Grok 4.7 Assisted-by: Claude Opus 5.5 Signed-off-by: Lucas Goossen <[email protected]>
The driver requires the extra0 register window to start on a 16 KiB boundary. On T6021 neither encoder's window does: ave0's is 0x7c44 bytes at 0x2902803e0, ave1's 0x3dfc bytes at 0x28e680228. dma_map_resource() maps the pages that contain an unaligned range and returns the IOVA of its first byte, which is the address Config takes. Drop the alignment check, and map the larger of the resource size and the variant size, so that the whole window is covered: with the variant size alone, the last 0x24 bytes of ave0's window would be unmapped. T6000's window is 0x24 bytes at a 16 KiB aligned address and T8112's is page aligned and exactly its variant size, so both map 0x4000 bytes as before. The alignment check goes for every chip: an unaligned window is now mapped, not refused. The only such window outside T6021 is on the second M1 Max encoder, which the device trees leave disabled. Assisted-by: Grok 4.7 Assisted-by: Claude Opus 5.5 Signed-off-by: Lucas Goossen <[email protected]>
The M2 Max runs a larger build of the 6070.11.1 firmware the T6000 and T8112 support uses, AppleAVE2FW_H14C: TEXT 0xf0000 and DATA 0x134000, with the link cell at TEXT 0x423c. Its two encoders share TEXT and each has its own DATA. The coprocessor registers, boot argument and timebase are T8112's. With boot device ID 20 and device type 17 both encoders of a J475c boot, answer the handshake and encode. The identity CRC, TEXT with the link cell cleared, is 0x0d56db87; select the 6070.11.1 layout for it. Config on T6021 needs a shared area. With the pointer and size at +0x60 and +0x68 left zero, as on T8112, the firmware never answers Config. With a 64 KiB, 16 KiB-aligned area both encoders answer Config, Open and Start. Allocate it at the first boot, keep it until the device is removed, and pass it for a variant with config_shared. That is a property of the H14C build rather than of 6070.11.1: the T8112 build answers Config with both words zero. The 6070 sessions on T6021 run the T6000/T8112 commands unchanged in this commit: one constant-quality session per encoder. abi.rst said 6070 streams H.264 without B pictures; the 6070 path already offers HEVC Main and B pictures, so describe that, and say what T6021 adds and what each value was checked against. The Kconfig help now says what each chip offers. Assisted-by: Grok 4.7 Assisted-by: Claude Opus 5.5 Signed-off-by: Lucas Goossen <[email protected]>
A session the firmware saw keeps its buffers until the coprocessor is proved to have lost power, and that happens only after the last session closes. With two sessions per boot, one long-lived stream and a second that is opened and closed again and again keep every closed session's buffers, a full set per session, with no bound. Count the sessions waiting for the reap. Once four wait, refuse a new session that would join the running firmware with EBUSY and a rate-limited warning. The refused session was never handed to the firmware, so it is freed at once. When the last stream closes, the power cycle frees all of them and resets the count. This holds for every layout; 9003 already ran two sessions per boot. Assisted-by: Claude Opus 5.5 Signed-off-by: Lucas Goossen <[email protected]>
The 6070.11.1 layout allows one session per firmware boot, while the driver already keeps the process buffers per session. Allow two, on every SoC that runs this firmware. On a J475c, four H.264 sessions, two on each encoder, ran in real time for five minutes at their target rates, and a fifth STREAMON got EBUSY. T6000 and T8112 were not run with two sessions. When the first of two sessions closes, its buffers stay quarantined until the last session closes and the encoder is power cycled, as on 9003. Assisted-by: Claude Opus 5.5 Signed-off-by: Lucas Goossen <[email protected]>
|
Thanks for the review. The updates are pushed; replies to each of your comments below. Re: There is no T6021-specific reason, so the cap is now on the layout: The quarantine is now bounded (new commit 6, Measured on the J475c (
So four stopped sessions cap the quarantine at ~130 MiB per encoder; KUnit also covers the count. Also run on the J475c: Re: two requests; no-regression rows for commits 2-4
Thanks for the commit 2-4 rows. The debugfs path in those rows is now |
|
Thanks for round 4. Putting |
|
@ludagoo, a tidy-up pass over the open PRs here. These of yours need something:
If any of these are no longer needed, closing them helps; otherwise a merge or rebase onto integration/aurora is usually all they need. Thanks! |
RyanTheTide
left a comment
There was a problem hiding this comment.
Review at 9aadf56. The T6021 variant expands the shared AVE layout and includes a new reference/boot contract. Please document provenance for the new layout fields and all expected test bytes, and make sure complete encoded mailboxes are assembled from named interface fields. The existing T8112 variant must keep its own boot and slot behavior. Include exact-head H.264/HEVC runs on a T8112 control and both T6021 encoders, including one stream per engine and session exhaustion.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: HOLD at 9aadf56a25ad
Blockers:
- Merge conflicts + superseded commit (
mergeable: CONFLICTING,mergeStateStatus: DIRTY): Base0abc2f385e54conflicts with currentmain(037f7bca6822) inDocumentation/admin-guide/media/apple-ave.rst,drivers/media/platform/apple/ave/Kconfig,drivers/media/platform/apple/ave/abi.rst,drivers/media/platform/apple/ave/ave-abi-test.c,drivers/media/platform/apple/ave/ave-drv.c,drivers/media/platform/apple/ave/ave-fw.c,drivers/media/platform/apple/ave/ave.h, anddrivers/media/platform/apple/ave/tests/README. Commit 2 (dce6e177789b, per-device debugfs directory) is superseded onmainby12402d0cef54(#2778, which also qualifies the workqueue name). Fix: rebase ontomain, dropdce6e177789b, and resolve conflicts against the newer AVE builds and #2778. - §4 attribution (commits and PR body): All 7 commits include AI-assistance trailers and the PR body includes a tool-generation footer. Fix: strip those trailers from every commit message during rebase (keep only the human author/committer and human
Signed-off-by:) and remove the footer from the PR body. drivers/media/platform/apple/ave/ave-fw.c:773-775,ave-fw.c:544(§3 firmware state isolation):ave->config_shared(64 KiB DMA buffer passed toConfigat+0x60/+0x68) is allocated once inave_fw_boot(), is not zeroed before subsequent cold boots (unlikeave->ipcandave->heap), and is freed only inave_fw_remove()rather thanave_fw_release_boot(), leaving prior firmware state across cold restarts and keeping it mapped across clean system suspend. Fix: moveave_free(ave, &ave->config_shared)intoave_fw_release_boot()(matchingave->heap/ave->ipc) and addif (ave->config_shared.cpu) memset(ave->config_shared.cpu, 0, ave->config_shared.alloc);besideave->heap.cpuinave_fw_boot().- §5 exact-head hardware evidence and PR structure: The PR body omits the required
Tested:(exact head SHA, Macs, result) andRisk:(door + affected Macs) lines and still states the current revision has not run on hardware; the round-4 J475c comment ran stacked with #2375 (one frame in flight) without exact SHA, standalone HEVC encode, or health counts (0SELinux denials,0failed units,0new kernel errors). No non-T6021 regression row exists for shared paths (ave_fw_expect_crc,ave_fw_iommu_tuple,ave_fw_map_extra0,AVE_QUARANTINE_MAX), anddrivers/media/platform/apple/ave/ave-layout.c:567enablesmax_sessions = 2onave_layout_6070_11_1where two pipelined sessions with B-frames (this PR standalone) have not been run on any chip. Fix: after rebasing, addTested:andRisk:lines and post exact-head hardware rows for T6021/M2 Max (both encoders, standalone H.264 + HEVC, single-stream per engine, two concurrent sessions + session exhaustionEBUSY+ quarantine cap,0DART faults,0SELinux denials,0failed units,0new kernel errors) and a non-T6021 6070.11.1 control (T8112 or T6000 covering/chosenfallback,extra0, H.264/HEVC, and two-session concurrency).
Checked: §1–§6 of pre-pr-checklist.md, full diff (12 files, +310/-40), all 7 commits, PR body/comments, mergeability against main, CI checks (all 7 passing at 9aadf56a25ad; fork workflows untouched), and alignment with #2376 and aura#341.
Evidence
- State / head:
OPEN, head9aadf56a25ad8b3b9bb30bdbadc9598f5d39b438(forkludagoo/linuxave/t6021),mergeable: CONFLICTING(DIRTY) againstmain(037f7bca6822). - CI at
9aadf56a25ad:host-tests,source,rust-build,kunit,DWC3/ATC builtin-no-atc,DWC3/ATC modular-no-atc,DWC3/ATC builtin-modular-atcallSUCCESS(from 2026-11-19; will need to re-run after rebase, includingpr-text). - §1 (model gating): Pass.
ave_t6021matches"apple,t6021-ave"via DT,config_sharedis a firmware-build property of H14C,max_sessions = 2lives onave_layout_6070_11_1, andaurora,crc32falls back cleanly to/chosen. - §2 (production-ready): Pass. No new module/cmdline parameters, sleeps, or hacks.
- §3 (safety): Blocker #3 (
config_sharednot zeroed on restart / not released inave_fw_release_boot()). Quarantine accounting (ave_sess_destroy()/ave_sess_reap()/ave_session_attach()) and DART/IOMMU segment validation (ave_fw_iommu_tuple()rejects missing, misaligned, or duplicate tuples) are otherwise sound. - §4 (clean-room / attribution): Clean-room pass (T6021 constants verified behaviorally on J475c and documented in
abi.rst;ave_6070_qualified_byteshashes our own command builder output). Fails attribution check (blocker #2). - §5 (evidence): Missing exact-head standalone T6021 and T8112/T6000 regression rows and
Tested:/Risk:lines (blocker #4). - §6 (naming): Pass. Uses Aurora Stage 2 loader terminology cleanly across diff and prose.
- Relation to #2376 (
t6021: enable the video encoders) andaura#341: #2374 can land ahead of #2376 andaura#341(chicken-and-egg safe:t6021nodes remain disabled onmain, andave_fw_expect_crc()falls back to/chosen).#2376'sm2_ave0/m2_ave1nodes (apple,t6021-ave,regindex 3"power-control"0x7c44/0x3dfc,m2_aveN_dmakept disabled sops_venc_sys/ps_venc1_syspower-cycle) align with#2374. - Non-blocking nits:
drivers/media/platform/apple/ave/ave-fw.c:535-536:dma_map_resource()already aligns mappings to the IOMMU granule, so passingresource_size(res)directly (instead ofmax_t(size_t, resource_size(res), ALIGN(ave->variant->extra0_size, SZ_16K))) avoids mapping an adjacent MMIO page if a future unaligned window fits within one page (offset_in_page(start) + size <= SZ_16K). On current T6000/T8112/T6021 trees both map the same pages.drivers/media/platform/apple/ave/ave-fw.c:75-78: callof_node_put(np)afterkstrtou32(str, 16, crc)finishes readingstr, and only fall back to/chosenwhenret == -EINVAL(property absent) so a malformedaurora,crc32fails closed.drivers/media/platform/apple/ave/ave-fw.c:96: check!phandleinave_fw_iommu_tuple()so a node without a phandle cannot match a zero cell.drivers/media/platform/apple/ave/ave-v4l2.c:842:ave->quarantined >= AVE_QUARANTINE_MAXonly runs on theelse ifbranch (joining a running firmware); if a 9003 device ever hitswitness_unusable(whereave_sess_reap()skips reaping), single-session starts would not hit the cap.
Both video encoders of the M2 Max, constant-quality H.264 and HEVC, and two sessions per firmware boot on every 6070.11.1 encoder.
Base:
integration/aurora0abc2f385e54. Seven commits on branchave/t6021(ludagoo/linux), tip9aadf56a25ad. Needs aurora-silicon/aura#341 (the boot loader hand-off). The encode-quality changes are #2375, on top of this one, and the device tree is #2373 and #2376.9a4f94ef751e). A KUnit case builds Start and the first two Process commands from the 6070.11.1 layout with default parameters and compares their CRC32 with the base. Every later commit here and in media: apple: ave: 6070.11.1 encode quality: H.264 references, CBR/VBR, VUI timing #2375 passes it.dce6e177789b).apple-ave-<device>, because the second encoder could not createapple-ave. The path changes on every chip; the two documents that give it are updated.851ad30ab202).aurora,crc32on eachmemory-regionreservation, with/chosenas the fallback, and severaliommu-addressestuples (the encoders share TEXT); the admin guide describes the reservation property. Every chip goes through this code. With today's boot loader (noaurora,crc32, one tuple per reservation) it does what it did before; only T6021 was run.aa930a5963ae). Neither T6021 window is (ave0 0x7c44 bytes at 0x2902803e0, ave1 0x3dfc at 0x28e680228). The mapping covers the larger of the resource and the variant size. T6000's and T8112's mappings do not change (both windows are 16 KiB aligned). The alignment check is dropped for every chip; see arm64: dts: apple: t6001, t6002: enable every video encoder #2295 for the one other unaligned window, on a disabled node.805c89fc6e67). AppleAVE2FW_H14C, a larger build of 6070.11.1 (TEXT 0xf0000, DATA 0x134000) with T8112's registers, boot argument and timebase. Sessions run the T6000/T8112 commands unchanged: one constant-quality session per encoder at this commit.b4de0709d3f8, new). A session the firmware saw keeps its buffers until the encoder is power cycled, which happens only after the last session closes. Once four wait, a session that would join the running firmware gets EBUSY with a rate-limited warning; the count resets at the power cycle. This holds for every layout (9003 already runs two sessions per boot).9aadf56a25ad).max_sessionsis 2 on the 6070.11.1 layout, so T6000, T8112 and T6021 all get it. Four on an M2 Max; a fifth STREAMON gets EBUSY.The lifecycle is upstream's, unchanged: Halt after every session, VENC power cycle before the next.
What each T6021 value was checked against on the J475c (also in
abi.rst):config_shared, because it belongs to the H14C build: T8112's build of 6070.11.1 answers Config with both words zero. The area is allocated at the first boot and kept until the device is removed.Overlap: #2218 and #1900 (T8142) and #1990 (Neo) conflict textually with this PR if they merge first (
ave.h; #1990 alsoave-abi-test.c). A rebase needs KUnit again, not hardware. #1861 merges cleanly.Tested
apple-ave(arm64, LLVM) at every commit: 44 at the base, 45 at commits 1-5, 46 at commits 6 and 7 (ave_quarantine_count: four handed sessions and one never handed, the count is four, and the reap frees them and clears it). All pass, no compiler warnings.checkpatch.pl --strict: 0 errors, 0 warnings, 0 checks on every commit.tools/asahi/run-host-tests.py --only ave: 6/6 at the base and at this tip./dev/video11= 40d100000,/dev/video12= 507100000). All VENC domains are off after boot and again a few seconds after each session.lifecycle_test10 times per encoder: 10/10 each, and the encoders encode afterwards./proc/vmallocinfolines whose caller containsdma): 393 mappings, 199901184 bytes, both times, so the quarantine is emptied. That output was read in the session; no log file was kept.echo platform > /sys/power/pm_test; echo freeze > /sys/power/state, idle after use and again while a paced H.264 session streamed: both returned, the streaming session finished all 300 pictures, both encoders encoded afterwards, and the VENC domains powered off again.The lifecycle depends on the device tree. With the
apple,t6000-ave-dmablocks next to each encoder enabled,apple-ave-dmabinds them,ps_venc_sysandps_venc1_sysstay on, the power cycle no longer resets the coprocessor, and after the first session every boot goes unanswered (10 tries, then EAGAIN). #2376 leaves them disabled.Not done yet
rmmodof the driver were not exercised on T6021.pm_test=platformwas.🤖 Generated with Claude Code