Repository navigation
media: apple: ave: run the M1 (T8103) encoder, across deep sleep - #3284
Conversation
On an M1 booted with the macOS 27.2 stub, such as the MacBook Air (J313), the bootloader preloads and hands over an encoder firmware build (TEXT 0x114000, DATA 0x128000), but no variant matches the apple,t8103-ave compatible, so the encoder never registers. Add a T8103 variant for that build. It is the M1 encoder's build of encoder firmware 9013.55.1, the version the M2 and M3 run on 27.2, and starts the same way: the boot configuration handshake as device 7 with handshake type 7, the 26B123 command layout, the codec clocks ungated by clearing the mailbox idle word, the bootloader's code base left as it is, and DATA restored from the boot snapshot before every start. The coprocessor and mailbox registers are the M2's, but its timebase frequency register counts in MHz, as the M1 Pro's does. As for the M1 Pro's and M2's 6070 builds, the loader fills the 64-bit cell at TEXT 0x423c with the firmware's alias of DATA (0xf00114000 on the J313; its low 32 bits are DATA's DART address). With the cell zeroed the TEXT CRC is b6616340, which selects the 26B123 layout. TEXT starts the DART window at address 0, as on every M1-family encoder. The code base the loader sets is TEXT's physical address, with VALID and bits 49 and 56 set, so the driver checks it against TEXT's physical address rather than its DART address. The variant is chosen by the compatible and the command layout by the TEXT CRC; other segment sizes and CRCs are refused. KUnit covers the variant's start fields, the link cell, the code base, the size check and the layout lookup. Signed-off-by: Erik Bourget <erik@ebourget.net>
Every M1 Mac has the encoder, and the driver now runs the firmware the macOS 27.2 bootloader preloads. Enable the encoder and both of its DARTs in the T8103 SoC tree, as the M3's are in theirs. The DARTs keep their ps_venc_sys power domain. The AVE DMA fault reporter stays disabled: while it is bound, ps_venc_sys stays on and the power cycle the firmware needs between sessions does not happen. Whether the encoder runs is still decided at boot from the hardware and its firmware: the bootloader hands the firmware over only when the ADT encoder is preloaded with valid segments and disables the node otherwise, and without a handoff the driver fails probe before it powers anything. Signed-off-by: Erik Bourget <erik@ebourget.net>
…ocessor
On the M1 the coprocessor's CPU reaches memory through the address filter
of its CPU DART. The loader points the code base at TEXT's physical
address, and the firmware reaches DATA at its own alias, the address in
the TEXT link cell (0xf00114000 on the J313), which the filter passes on
to the DART. Only the bootloader programs that filter, from the ADT
(dart-ave filter-data-instance-0). A core started behind a filter that
does not admit its code cannot fetch its first instruction.
When a DART of the encoder names its filter window ("dapf"), map it
read-only. Before every start, before any coprocessor or mailbox write,
read the filter's entries and refuse to start unless a programmed entry
admits TEXT (where the code base is physical) and one admits the DATA
alias over DATA's size. An entry counts only with its low control bits
set: a deep sleep clears them and keeps the range (0x11 and 0x33 read
back as 0x10 and 0x30 on the J313), and a coprocessor started behind
such a filter reset the SoC. The refusal logs the entries the filter
holds.
The dart_audit debugfs file shows the same entries and verdict without
starting anything.
The filter is never written here. Encoders whose device tree names no
filter are unchanged.
Signed-off-by: Erik Bourget <erik@ebourget.net>
The M1 family's DARTs filter what a coprocessor's CPU reaches through
them with an address filter the loader programs from the ADT
(filter-data-instance-0). Its entries are a control word, whose low
four bits enable the entry, a word at +0x04 and an inclusive range.
A deep sleep clears the enable bits and keeps the rest: on the J313
the video encoder's CPU DART reads 0x11 and 0x33 after boot and 0x10
and 0x30 after a wake, and the encoder's coprocessor started behind
that filter reset the SoC.
The write-back the driver has for a filter is described by the device
tree (apple,dapf-ranges) in the T8110 entry form, and it decides that
a filter holds by its first range alone, which a T8020 filter keeps
through a sleep.
For a T8020-layout DART that names its filter window ("dapf") without
apple,dapf-ranges, read the entries the loader left at probe, while
the DART is powered: those through the last enabled one. After a
power-off, where the driver already writes a filter back, compare the
live entries with them, control words included, and write them back
in the loader's order, each entry's control word last, when they
differ. A filter nothing programmed keeps nothing and is left alone,
as is every DART without a "dapf" window and every T8110-layout one.
KUnit covers the entries kept, the comparison (enable bits, the end's
low bits, control bits that do not read back) and the write-back on a
memory-backed window as a sleep leaves it.
Signed-off-by: Erik Bourget <erik@ebourget.net>
…ilter The ADT gives dart-ave four register windows: the CPU DART (0x267040000), the DART (0x267030000), the SMMU (0x267020000) and, after them, the CPU DART's address filter (0x267044000), whose entries it gives as filter-data-instance-0. The bootloader programs the filter from them. Add the filter window to ave_dart0 as its "dapf" region. The DART driver then keeps the entries the bootloader programmed and writes them back after a deep sleep, and the encoder driver checks the filter before it starts the coprocessor. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Signed-off-by: Erik Bourget <erik@ebourget.net> # Conflicts: # drivers/iommu/apple-dart-test.c
…pping Include ave_fw_code_base() in the ave-recovery host test extraction list after ave_fw_prepare_restart() switched to it, and update the ave_map_darts() stub in ave-probe-pm-tests.py to return int. Signed-off-by: Erik Bourget <erik@ebourget.net>
ave_fw_text_id_crc() accepts a zero link cell so image CRC calculation works on unlinked buffers, which leaves ave->data_alias zero on an unlinked handoff. ave_fw_filter_gap() then skipped the DATA check, allowing a TEXT-only filter to pass ave_fw_check_filter(). In addition, ave_fw_check_filter() returned success when no dapf window was mapped, allowing coprocessor start on variants whose code base is physical without an active filter check. Require a nonzero, non-wrapping DATA alias in both ave_fw_probe() (on filter-dependent or physical-code-base paths) and ave_fw_filter_gap(), return -ENODEV from ave_fw_check_filter() when vcbar_text_phys requires the filter but dapf is unmapped, and cover unmapped dapf, mapped unprogrammed dapf, zero, wrapping, and excluded DATA cases in both the apple-ave-abi KUnit suite and the ave-recovery host tests. Signed-off-by: Erik Bourget <erik@ebourget.net>
There was a problem hiding this comment.
Verdict: MERGE at 69ef8fc5
Blockers: none (note: companion PR aurora-silicon/aura#537 is still open; as verified by the negative test, this kernel fails closed cleanly without aura#537 so landing order is safe).
Checked: no Apple material, no AI attribution, no new chip/board/firmware gates (uses DT dapf reg-name and apple,t8103-ave compatible / variant data table), no cmdline hacks, human Signed-off-by, T8020 DART DAPF save/restore across deep sleep (apple-dart.c, loader write order with ctrl word last), AVE DATA alias validation and filter audit refusal, KUnit tests (apple-dart-test.c, ave-abi-test.c), exact-head J313 hardware row PASS (H.264/HEVC 720p/1080p/4K, 3 deep sleeps with byte-identical post-wake encodes, negative test without aura#537), all 27/27 CI checks green.
Evidence
- Inspected
drivers/iommu/apple-dart.c,drivers/media/platform/apple/ave/, andarch/arm64/boot/dts/apple/t8103-peripherals.dtsi. apple_dart_dapf_t8020_save()activates only on T8020-layout DARTs naming a"dapf"window withoutapple,dapf-ranges, reads through the last enabled entry (DART_T8020_DAPF_ENABLE), andapple_dart_dapf_t8020_replay()restoresr4/start/end/ctrl(control word last) on resume when entries differ.- Hardware row at exact head
69ef8fc5e313on J313 (M1 MacBook Air, default cmdline, paired withaura#537f6dcad16): H.264/HEVC 720p/1080p/4K clean (44.4–46.4 dB), 3 deep sleeps withaddress filter: 2 entries written back after the sleepand byte-identical post-wake encodes; negative run withoutaura#537cleanly refuses start. - CI at
69ef8fc5: 27/27 checks PASS (apple-build,dt-checks,host-tests,rust-build, all KUnit suites,pr-text,readiness).
|
code-owner ping @DjDeveloperr: closeout merge at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
|
Merged. Thanks @erikwb: the M1 encoder now runs across deep sleep. Other M1 boards and the GStreamer v4l2 encoders are fine as follow-ups. |
…nel PIODMA Enable safe ADT-present peripheral blocks in shared t8103-peripherals.dtsi, t8103.dtsi, t8103-jxxx.dtsi, and per-board control files across all five T8103 boards (J274, J293, J313, J456, J457), reducing disabled nodes from 372 to 155 (-217): - Move apciec0_piodma and apciec1_piodma into &usb4_0_pcie_tunnel and &usb4_1_pcie_tunnel as enabled dma@ nodes so the ACIO router driver populates and tears them down strictly with an active PCIe tunnel. - Enable shared ADT-present peripherals in t8103-peripherals.dtsi: MCC, 19 die temperature sensors, AES, PWM0, AIC timebase, DWI, nub_spmi1, aop_spmi1 + stockholm NFC, JPEG0/JPEG1 and their standalone DARTs, ave_dma (renamed to dma@ for schema compliance), ATC0/ATC1 DP inputs, soc_errors, soc_events, and battery_monitor. - Enable dpaudio0 in shared t8103-jxxx.dtsi and move AOP core enablement into shared t8103.dtsi while keeping aop/aop_mbox/aop_dart/aop_admac disabled on J274 Mac mini (iBoot does not boot AOP firmware on Mac mini). - Enable board-verified control clients in t8103-j*-control.dtsi (J274 ethernet-sideband@32, J293 touchbar-driver@4c and touchbar-calibration@50, J313 i2c2 + retimer@18/@19, J456/J457 hcpm@8). Keep unsafe, loader-gated, unbacked-provider, and open-PR-owned nodes disabled: simetra (unvalidated apple,spmi-nvmem bounds), dockchannel_uart, primary_spmi_monitor (unbacked interrupt-controller referenced by pmic1), peripheral_clocks (unbacked clock provider referenced by scaler0), spi4 (depends on peripheral_clocks and absent on J274), pmp/pmp_dart/pmp_mbox (firmware-owned without T8103 handoff), sio (loader-gated), and ave/ave_dart0/ave_dart1 (owned by open PR aurora-silicon#3284). Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
What: Run the M1 (T8103) video encoder on the preloaded firmware build (TEXT
0x114000, DATA0x128000, normalized TEXT CRCb6616340,26B123command layout), and keep it working across deep sleep. The M1's encoder coprocessor fetches its code through its CPU DART's address filter, which a deep sleep half-clears: the DART driver now keeps the filter the bootloader programmed and writes it back on resume, and the encoder requires a valid nonzero DATA alias and refuses to start behind a filter that does not admit its firmware. Needs aurora-silicon/aura#537, which programs that filter at boot.Tested: J313 (M1 MacBook Air) at
69ef8fc5e313withaurora-silicon/aura#537atf6dcad16(one-shotaura-try, default command line):dart_auditadmits the firmware (0x11TEXT,0x330xfwindow) right after boot; H.264 and HEVC 720p/1080p/4K encodes decode cleanly (44.4-46.4 dB, 1080p reruns byte-identical); 3 deep sleeps (rtcwake, outputs DPMS-off first) with the filter written back each time (address filter: 2 entries written back after the sleep) and post-wake encodes byte-identical to the pre-sleep ones; negative: the same kernel on the default Stage 2 (noaura#537) readsdoes NOT admit the firmware's TEXTand refuses an encode with-ENODEVbefore starting the coprocessor (coprocessor ctrl 0x0, the Mac stays up); 0 failed units, 0 AppArmor denials, 0 encoder/DART kernel errors (the Mac was on its USB4 dock with an external display; the 5 boot-timeerrlines equal a control boot). Earlier row atdbe14bd380c8withaurora-silicon/aura#537at5c56263b(on Stage 2 basef5ddfff2): H.264 and HEVC 720p/1080p/4K encode, every frame decodes, 44.4–46.4 dB, reruns byte-identical; 2 deep sleeps (rtcwake), the filter written back each time, post-wake encodes clean and byte-identical, no reset. Head69ef8fc5e313mergesmain(fcb124279183), updates theave-recoveryandave-probe-pm-testshost harnesses, requires a nonzero non-wrapping DATA alias inave_fw_probe()andave_fw_filter_gap(), and refuses unmappeddapfinave_fw_check_filter()whenvcbar_text_physis set, with negative KUnit and host tests; AVE KUnit (51/51), AVE host tests (10/10),checkpatch --strict, andW=1drivers/media/platform/apple/ave/builds pass at69ef8fc5e313.Risk: two-way door · M1 (T8103) Macs: the encoder and its DARTs are enabled in the T8103 SoC tree; the DART change acts only on T8020-layout DARTs that name a
dapfwindow, which today is only this encoder's CPU DART. Other Macs unchanged.Not yet: the other M1 boards (J274, J293, J456, J457); GStreamer
v4l2h264enc/v4l2h265encrows (plugin not installed on the J313; ffmpeg*_v4l2m2mcovered both codecs).Details
Commits:
e67e9f48583f): T8103 variant for the preloaded build (TEXT0x114000, DATA0x128000,26B123command layout): boot-configuration handshake as device 7 with handshake type 7, the bootloader's code base left as it is. The loader fills the TEXT link cell at0x423cwith the firmware's alias of DATA (0xf00114000); with it zeroed the normalized TEXT CRC isb6616340. The code base is TEXT's physical address (VALID plus bits 49 and 56), so it is checked against TEXT's physical address. The M1's timebase frequency register counts in MHz, as the M1 Pro's does.dapf), the driver maps it read-only and, before any coprocessor or mailbox write, requires an enabled entry that admits TEXT (physical code base) and one that admits the DATA alias. Otherwise it returns-ENODEVand logs the entries.dart_auditin debugfs shows the filter and the verdict without starting anything.apple,dapf-ranges, judged intact by its first range) cannot serve it. For a T8020-layout DART with adapfwindow and noapple,dapf-ranges, the driver reads back the entries the loader programmed at probe, compares control words and ranges after a power-off, and writes them back in the loader's order, control word last. Nothing programmed: nothing kept. T8110 DARTs and DARTs without adapfwindow are untouched.ave_dart0gets its filter page, ADTdart-avereg[3], asdapf).main(fcb124279183) resolving thedrivers/iommu/apple-dart-test.ctest-case merge conflict.ave_fw_code_base()indrivers/media/platform/apple/ave/tests/run-recovery.pyand updateave_map_darts()intools/asahi/ave-probe-pm-tests.pyto returnint.data_aliasinave_fw_probe()(on filter-dependent or physical-code-base paths) andave_fw_filter_gap()so an unlinked handoff cannot passave_fw_check_filter()on a TEXT-only filter, and return-ENODEVfromave_fw_check_filter()whenvcbar_text_physrequires the filter butdapfis unmapped; cover unmappeddapf, mapped unprogrammeddapf, zero, wrapping, and excluded DATA in KUnit (ave_t8103_cpu_dart_filter) andave-recovery(cpu_dart_filter).The addresses handed to the firmware stay plain DART addresses; the firmware maps them into its own view.
Evidence
At
69ef8fc5e313:LLVM=1):drivers/media/platform/apple/ave/.kunitconfig51/51 passed (incl.ave_t8103_26b123_build,ave_t8103_cpu_dart_filternegative unmapped-dapf, unprogrammed-filter, zero/excluded/wrapping DATA cases); at2651cc1729ef(drivers/iommu/apple-dart*unchanged since):apple-dart4K config (apple-dart*) 33 passed, 2 skipped (apple-dart32/34 with 2PAGE_SIZE < 16Kskips +apple-dart-firmware-leaf1/1), and 16K config (CONFIG_ARM64_16K_PAGES=y,CONFIG_APPLE_DART_J713_DCP=y) 44/44 passed (apple-dart43/43 incl.apple_dart_test_dapf_t8020_used,_same,_replay+apple-dart-firmware-leaf1/1).python3 -I -B tools/asahi/run-host-tests.py --only ave10/10 passed (ave-host,ave-recoveryincl.cpu_dart_filter,ave-input,ave-ipc,ave-pm-tests,ave-pm-tests --old-ref 4db3a5a22c43,ave-probe-pm-tests,ave-probe-pm-tests --negative-control,pmu-rtc-tests,g17-traversal-admission-tests).checkpatch --strict --git origin/main..HEAD --ignore GIT_COMMIT_ID: 0 errors, 0 warnings, 0 checks on all 7 non-merge commits.W=1build (ARCH=arm64 LLVM=1,defconfig+asahi.configwithoutRUST):drivers/media/platform/apple/ave/built with no new warnings (drivers/iommu/apple-dart.oandapple/t8103-j313.dtbunchanged since2651cc1729ef).DT checks at
d9411c646eeavsorigin/main(fcb124279183, no DT files changed since):CHECK_DTBS=yacross all 139 Apple DTBs exited 0 with 0 new warnings in AVE or DART nodes;scripts/dtc/apple-adt-coverage.py0 new missing/broken entries;scripts/dtc/apple-dart-pd-check.py0 new DARTs without a usable power domain.J313 (
M1 Air, T8103) trial at69ef8fc5e313(default command line) +aurora-silicon/aura#537atf6dcad16(Stage 21.0.0b17-gf6dcad16, one-shotaura-try; kernel, initramfs and Stage 2 installed next to the defaults and removed afterwards). The Mac was on its USB4 dock with an external 4K display attached.After boot, before any encode:
dart_auditEncode matrix (ffmpeg
h264_v4l2m2m/hevc_v4l2m2m, software decode,testsrc2NV12), before sleep and again after each of the first two wakes; the numbers matched every time and the 1080p outputs after each wake were byte-identical to the pre-sleep ones:Deep sleeps (
rtcwake -d rtc1 -m mem -s 30, both outputs DPMS-off first as the desktop does):suspend_statssuccess=3 fail=0,boot object resumes 0 -> 1 -> 2 -> 3,dart_auditunchanged after each wake, and withapple-dartdynamic debug on the third wake:A deep sleep started with the external display still active is refused by that display's processor (
apple-dcp 271c00000.dcp: PM: failed to suspend: error -16), on the default kernel too.Negative, same kernel on the default Stage 2 (
1.0.0b17-gf5ddfff2, noaura#537, one-shot):dart_auditreadsCPU DART filter 0x0000000267044000: does NOT admit the firmware's TEXT (0x800a20000-0x800b33fff)withcoprocessor ctrl 0x0 boot_arg 0x0 fw_state 0, and the driver logsapple-dart 267040000.iommu: address filter not programmed: nothing to keep across sleep. Starting an encode fails at once, without touching the coprocessor:dart_auditafterwards still showscoprocessor ctrl 0x0 boot_arg 0x0 fw_state 0; the Mac stayed up and the next boot returned to the default.Regression counts after the sleeps:
0failed units,0AppArmor denials (SELinux N/A on Arch ARM),0Oops/BUG/WARNING/SError,0apple-ave/apple-dartfault or error lines. The kernelerrlines are the 5 of a control boot at boot (apple-dcp ... failed to extract init props,DCPDP2XService admission failed, and the dock bridge's and Ethernet'sof_irq_parse_pci), plus the deep-sleep resume lines already seen onmainin soc: apple: sep: report a refused identity unlock, and stop aurora-sep-load on it #3274's row (brcmfmac/hci_bcm4377Unable to change power state from D3hot to D0,PS fpwm1: Failed to reach power state) and moreDCPDP2XService admissionlines of the dock's display processor.Earlier J313 trial at
dbe14bd380c8(default command line) +aurora-silicon/aura#537at5c56263b(on Stage 2 basef5ddfff2), one-shot boot.dart_auditafter boot, and again after each wake:Each wake:
Source: ffmpeg
testsrc2NV12, encoded withh264_v4l2m2m/hevc_v4l2m2m, decoded in software; 1080p reruns byte-identical. Noapple-aveerrors, SError or DART faults in the kernel log; no failed units at the end of the run.Before the write-back (earlier trial of the same series without commit 4): after a wake the filter read
ctrl 0x10/0x30with unchanged ranges, and starting the encoder reset the SoC. Commit 3 now refuses that state.