Skip to content

media: apple: avd: Program the T8132 AXI2AF bridge at power-up - #2696

Draft
IronsideXXVI wants to merge 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604-avd-axi-daisy
Draft

IronsideXXVI wants to merge 1 commit into
aurora-silicon:mainfrom
IronsideXXVI:j604-avd-axi-daisy

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What: On T8132 (M4), program the AVD AXI-to-fabric bridge at every power-up, before the decoder CPU starts, in the same order macOS uses (flow-control groups, then the AXI2AF table with read-back, then a check). Left at its reset credits, the bridge holds 10-bit 4K decode back. Only T8132 maps the bridge, so other SoCs are untouched. There is no module parameter.

Tested: J604 (M4 MacBook Pro 14") on the J604 release tree 1.1143, which carries the same tables behind a parameter (this head 57eb00b was not booted). One boot, alternating runs, median of six ffmpeg VA-API runs of 1500 frames each: HEVC Main10 went from 550.2 to 712.8 fps (+29.6 %, now 97.8 % of native macOS) and AV1 10-bit from 512.3 to 623.0 fps (+21.6 %); 8-bit moved by noise only. Hardware and software frame md5 matched, with no decoder errors or resets. This head builds, and KUnit avd-pm passes 42/42.

Risk: two-way · T8132 (M4) Macs with AVD. Only the J604 was run. Other SoCs do not map the bridge, so the new code does not run there.

Not yet: This head has not booted on the J604. The read-back check with bit 31 masked has not run on hardware. No other T8132 machine has run this. Draft until the read-back check runs on the J604.

Full description

On the M4 (T8132) the AVD's AXI-to-fabric bridge powers up with its reset
credits, and 10-bit 4K decode is write-bound behind them: HEVC Main10 ran at
about 75 % of native macOS on the same machine and clip. macOS reprograms the
bridge at every power-up from AppleAVD's Daisy loadTunables (flow-control
groups, then the AXI2AF table with read-back, then a check). This does the
same, in the same order, before the decoder CPU starts. Only T8132 maps the
bridge; other SoCs are untouched. No module parameter.

Measured on a J604 (M4 MacBook Pro 14), one boot, alternating runs with and
without the tables, median of six ffmpeg VA-API runs, 1500 frames each:

4K clip without with change
HEVC Main10 550.2 fps 712.8 fps +29.6 %
HEVC Main 724.3 fps 721.9 fps -0.3 %
AV1 10-bit 512.3 fps 623.0 fps +21.6 %
AV1 8-bit 615.1 fps 624.1 fps +1.5 %

Hardware and software frame md5 matched on 60 frames each of the HEVC Main10,
HEVC Main and AV1 10-bit clips with the tables in. No run had decoder errors
or resets. CPU and GPU benchmarks did not move beyond noise (-0.5 %, +0.2 %,
+0.8 %). HEVC Main10 is now 97.8 % of native macOS (728.8 fps) on the same
clip.

Tested

  • J604, tables and decode numbers: pass, but on our J604 release tree
    (1.1143), not on this head. That tree carries the same tables in the same
    order behind a parameter, which is how one boot could alternate. This patch
    has no parameter.
  • This head on integration/aurora: not booted. It builds and KUnit avd-pm
    passes 42/42. I do not have a J604 tree on current integration/aurora yet.
  • Read-back check with bit 31 left out: not run on hardware. On the J604
    run the 15 flow-control entries that did not read back differed in bit 31
    only (a load strobe that reads back as 0), so I expect all 47 to read back
    with it masked. That needs a boot to confirm.
  • Other T8132 machines: not tested, none here.
  • Other SoCs: not tested. They do not map the bridge, so the new code does
    not run there.

Draft until the read-back check has run on the J604.

On T8132 the decoder's AXI-to-fabric bridge comes back from every
power-down with its reset credits (AXI2AF +0x0848 reads 0x01000040
after power-up). With them the decoder cannot write 10-bit 4K frames
fast enough.

macOS 26 on a J604 runs this decoder as its Daisy generation (AppleAVD
logs deviceType 416 and constructs CAvdApCommDaisy). Daisy's
loadTunables reprograms the bridge at each power-up: 13 upstream and 2
downstream flow-control entries written without read-back, then the
decoder entries our CM3 firmware already applies, then 32 AXI2AF
entries with read-back, then a check of both flow-control groups.

Map the bridge on T8132 and write the same tables in the same order at
every power-up, before the decoder CPU starts. Bit 31 of each
flow-control entry loads the count beside it and reads back as 0, so
the check leaves it out. If entries still do not read back, the first
two power-ups that miss log one warning with the count and name the
entries at debug level. Other SoCs do not map the bridge and are not
affected.

Measured on a J604 (M4, T8132), one boot, with and without the tables
in alternating runs, median of six ffmpeg VA-API runs each:

  4K clip       without      with         change
  HEVC Main10   550.2 fps    712.8 fps    +29.6 %
  HEVC Main     724.3 fps    721.9 fps     -0.3 %
  AV1 10-bit    512.3 fps    623.0 fps    +21.6 %
  AV1 8-bit     615.1 fps    624.1 fps     +1.5 %

Hardware and software frame md5 matched on 60 frames each of the HEVC
Main10, HEVC Main and AV1 10-bit clips with the tables in. No run had
decoder errors or resets. GPU and CPU benchmarks did not move beyond
noise.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@RyanTheTide

Copy link
Copy Markdown
Contributor

The performance result is clear: +30 % on HEVC Main10 and +22 % on AV1 10-bit, flat on the 8-bit clips, which fits write credits as the bottleneck.

The design point is where the values come from. The three tables (avd_daisy_flow_up, avd_daisy_flow_dn, avd_daisy_axi2af) are fixed in the driver for T8132. Elsewhere in this tree, per-SoC bridge and fabric tunables are taken from the ADT and handed to the kernel by the boot loader (as apple,tunable-* properties) rather than written into a driver. If the AVD's ADT node carries these, reading them the same way would cover the next SoC without a new table, and keep the values matched to the firmware the machine actually runs. Could you check whether they're in the J604's ADT?

Assisted-by: LLM (Claude:Opus 5.5)

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

I checked, and they aren't there. On the J604 the avd node has 18 properties and none of them is a tunable: no *tunable*, no AXI2AF, no flow-control entry. I looked in two places: the raw ADT the boot loader gets on this machine, and the IODeviceTree plane under macOS 27.2. No other node carries an AVD-named property either.

The tree does use that scheme for other blocks. 60 nodes have tunables, including apcie (apcie-axi2af-tunables) and each atc-phy (tunable_ATCAXI2AF), and dart-avd has its dart-tunables-instance-0. So the AXI2AF bridges for PCIe and the Type-C PHYs are described in the ADT, and the AVD one is not. macOS gets the AVD values from tables inside AppleAVD itself (the Daisy loadTunables path), which is why they ended up in the driver here.

That does leave the values tied to the driver and not to the firmware, as you say. Two things I can do about it in this PR:

  • hang the three tables off the of_device_id match data instead of a T8132 check in the code, so the next SoC is a table and a compatible, with no new logic;
  • if a later SoC's ADT does carry them, the boot loader can hand them over and the driver can prefer the property over the built-in table.

Tell me if you want the first one now and I'll push it.

@RyanTheTide

Copy link
Copy Markdown
Contributor

integration/aurora at daa9e2d has no AXI2AF programming in the AVD driver, and 57eb00b still merges onto it without conflicts. @IronsideXXVI three things before this can leave draft. First, please state in the commit how the three tables were obtained: values read out of Apple's driver binary cannot go into this tree, values observed on your own machine (register reads or an MMIO trace of the running system) can, and the text currently only says they are what AppleAVD's loadTunables writes. Second, the bridge is mapped by a fixed offset from the control window behind an apple,t8132-avd check; describing the window as a reg entry on the node and hanging the tables off the match data, as you offered, removes that check. Third, the read-back check with the load bit masked still needs one boot on a J604 on this head.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks Ryan.

  1. How the tables were obtained: they were read out of AppleAVD's Daisy tunables, not observed on the machine. So under the rule you describe they can't go in as written. I'll take them again from an MMIO trace of macOS powering the decoder up on our J604, keep only what the trace shows, and say exactly that in the commit. If the traced values differ from these anywhere, the decode rows get rerun on the traced values before this leaves draft.

  2. Window and match data: done locally. The bridge is now an axi2af reg entry on the T8132 node (binding updated, the entry is optional), and the tables hang off the T8132 match data with no compatible check left. Doing this showed a bug in the current head: the T6041 node lists apple,t8132-avd as its fallback, so the of_device_is_compatible() check would also have mapped the bridge on T6041 and written T8132's tables there. With the reg entry, only a node that describes the window gets the writes. This goes up together with the traced tables.

  3. The read-back boot with the load bit masked: that runs on the J604 on the respun head, and I'll post the count here.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@IronsideXXVI checking open drafts today. To come out of draft, this still needs:

  • It conflicts with main. Merge main in or rebase (no force push needed: a merge commit is fine).
  • Then a test run at the final head on a Mac with the hardware it touches, and mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Review note (hardware-facts rule, same stance as #2650). Thanks for chasing the T8132 decoder bring-up; the read-back ordering and the KUnit case are useful.

  1. Where the tables come from. avd_daisy_flow_up[], avd_daisy_flow_dn[] and avd_daisy_axi2af[] are per-register values. The comment describes them as the vendor driver's power-up table. I checked a live T8132 ADT (J713, 27.2): the avd node carries no AXI2AF tunables, so the ADT can't supply them. Rebuild the rows from our own MMIO trace of the bridge coming up on T8132 hardware, the way the existing ProRes T6041/T8142 rows were made. Cite the trace in the commit message (it can be public: our own captures are not tainted). Name each field as our own register description, as you already do for the credit and token allocations. If any value turns out to vary by board or firmware, it has to come from the loader or ADT, not a table.
  2. Comments. Lines describing "macOS's Daisy generation" and "loadTunables" name the vendor driver and its routine. Describe only what this driver does: which window, which order, and why the read-back. Keep vendor symbol names out of the source and commit text.
  3. The power-up hook and avd_pm_map_axi2af() placement look fine. Once (1) and (2) are done, a T8132 decode row plus one non-T8132 AVD row would cover it.

Checklist line: https://github.com/aurora-silicon/agent-guidelines/blob/main/pre-pr-checklist.md ("No hardware fact as a literal").

This branch has not been deployed

No deployments
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.

2 participants