Skip to content

soc: apple: aop: check the firmware segments wherever the loader lists them (T8112 on 27.2) - #2519

Open
satchlj wants to merge 1 commit into
integration/aurorafrom
satchlj/t8112-aop-fw-regions
Open

satchlj wants to merge 1 commit into
integration/aurorafrom
satchlj/t8112-aop-fw-regions

Conversation

@satchlj

@satchlj satchlj commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf.

soc: apple: aop: run the firmware-segment checks (check_fw_regions, ED0p) whenever the boot loader lists the AOP's firmware segments in memory-region, not only on the SoCs whose configuration turns them on (T6040).

Why: the macOS 27.2 AOP firmware on T8112 runs its external code and data from DRAM, like the T6040 firmware. Without these checks and the ED0p boot argument, the AOP never becomes ready on a 27.2 boot, so the speakers, microphones and AOP sensors are missing. The 13.5 firmware on the same SoC needs none of this.

Selection: by device-tree property. The checks run when the AOP node has a memory-region, which only a loader that handed the segments over adds. Today Aura adds it only on T6041 and T8132, which already run the checks. The counterpart that adds it on T8112 with 27.2 firmware is aurora-silicon/aura#377. No board name is matched.

Testing

  • The revised head builds drivers/soc/apple/aop.o for ARM64 in neo-build on integration/aurora a84637dca209.
  • The code path it selects was qualified on hardware, but this selector has not been run yet. On 2026-11-18, J413 on the 27.2 (26B123) stub ran the same checks, turned on by a local compatible (fw_regions: true on the T8112 configuration), with a local Aura that reserved the same segments. The AOP announced it was ready, ED0p was translated at 0x40000, and the following worked:
    • all four speakers, each measured separately by a microphone loopback (+12 to +23 dB over muted);
    • both microphone PCMs;
    • the ALS, lid angle, accelerometer and gyro.
  • Not yet tested: this exact change, with the Aura PR, booting the AOP from the loader-listed regions. That needs both at boot, and I'll add the result here. A runtime module swap is unsafe on T8112, because unbind does not quiesce the AOP.
  • Not tested on any other SoC, or on J413 with 13.5 firmware (no memory-region there, so unchanged by construction).

Assisted-by: LLM (Claude:Opus 5.5, Codex:GPT-6.2)

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

Boot-tested together with aurora-silicon/aura#377 on MacBook Air M2 (J413), 27.2 (26B123) stub: pass.

One-shot boot 2c7bbe5c (2026-11-20), under the trial watchdog, with:

  • aop.ko built from this PR's head 601c6719ff24 against the running 7.3.0-1-40 kernel, carried in the initramfs (the loaded module's build ID 9d1317d8… matched that build);
  • a Stage 2 with drm/asahi: G17 shared capacity, bounded ray-query jobs and timeout recovery on 7.3 #377's two hunks in place of phellos's local AOP code, and the device tree's AOP node reduced to the upstream compatible = "apple,t8112-aop". The local apple,t8112-aop-27-2 compatible was gone.

Results:

  • The AOP node had a loader-added memory-region (two segments). The driver validated the external data region at IOVA 0x40000, and the firmware reported AOP IS READY 1.9 s after boot.
  • Audio: card AppleJ413 (macaudio) has the Primary and Secondary playback PCMs and Primary and Speaker Sense capture. Card AppleJ413HPAI has the hpai and lpai microphones.
  • Sensors: all six IIO devices are present and read plausible values: ALS, ALS temperature (24.1 °C), lid angle, accelerometer, gyro and devmotion.
  • Nothing was played through the speakers: every playback substream stayed closed. speakersafetyd, SDDM and the panel were up. No AOP errors in the kernel log.

Caveats: the kernel was phellos's current local 7.3 build, not an integration/aurora build. Only the AOP module came from this PR. Not tested on other SoCs.

🤖 Generated with Claude Code

@satchlj
satchlj marked this pull request as ready for review November 20, 2026 05:00
@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: hardware run.

PR head Checked Result
fbd8c4dc AOP probe with the loader-listed firmware segments on T8112 27.2, after b224fde (ED0p check): "Validated external data region at IOVA 0x40000", AOP ready, six IIO devices, both audio cards present (nothing played). Tested tree = 601c671 merged onto 458f759; that merge is now this branch's head (same tree) Pass

Build: phellos (MacBook Air M2, J413, macOS 27.2 / 26B123 stub), default rebuilt 2026-11-20 = linux integration/aurora 458f759 + #2519 #1832 #1831 #2264 #2525 #2526 #2543 #2544 #2545; Aura main 0beafec9 + aurora-silicon/aura#377 aurora-silicon/aura#227 (isp.c only) aurora-silicon/aura#381 aurora-silicon/aura#382; U-Boot aurora-wip 37baf8f7 + aurora-silicon/u-boot#67; Stage 2 DTB t8112-j413-fw27.dtb. One-shot boot under the SoC watchdog, then made the default (two default boots healthy).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 1.

  1. Commit trailers: 601c671 and the merge fbd8c4d both carry Co-Authored-By: Claude Opus 5.5, and the merge commit has no Signed-off-by. Drop the co-author trailer from both and add your Signed-off-by to the merge (or rebase instead of merging, which also drops the extra commit). The description ends with a "Generated with Claude Code" line; replace it with Assisted-by: LLM (Claude:Opus 5.5) as the last line.

The code is sound. I checked lists_fw_regions() (drivers/soc/apple/aop.rs:2096) against check_fw_regions(): the selector and the check use the same of_reserved_mem_region_count() on the same node, so a loader that lists segments always gets the full IOMMU check. On the configs with patch_bootargs: false and ec0p: 0 (T8140/T8142/T8152), a stray memory-region makes probe fail rather than start the AOP unchecked. ED0p is still only accepted when the bootargs declare it (aop.rs:3289). T6041/T8132 behave as before, because fw_regions: true still turns a missing memory-region into an error there.

HW row: the J413 27.2 default-boot row you posted, plus the regression counts from that boot (0 AVC denials, 0 failed units, 0 new kernel errors), and one boot of a 13.5-stub T8112 or another non-T6040 Mac with this kernel showing the AOP comes up unchanged (no memory-region, so the check is skipped).

Assisted-by: LLM (Claude:Opus 5.5)

@satchlj
satchlj force-pushed the satchlj/t8112-aop-fw-regions branch from fbd8c4d to 4c637bf Compare November 21, 2026 12:34
@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Codex GPT-6.2 Sol on @satchlj's behalf

Rebased onto integration/aurora at a84637d. The extra merge is gone, and the remaining commit has the human sign-off. The PR footer is updated. The ARM64 aop.o build passed in neo-build with Rust 1.93.1.

The revised head is untested on hardware. The J413 27.2 default-boot regression counts and a 13.5-stub T8112 or other non-T6040 AOP regression boot remain pending.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of 4c637bf: No blockers.

Points from the last review:

  1. Trailers and merge commit: resolved. The branch is rebased onto integration/aurora a84637d as one commit, 4c637bf, which carries only the human Signed-off-by. The merge commit is gone, and the body ends with the Assisted-by: line.

The code change has the same added and removed lines as 601c671, which was reviewed before: lists_fw_regions() at drivers/soc/apple/aop.rs:2121 and the selector at aop.rs:3309. It now sits on a base whose check_fw_regions() takes allow_ed0p, and that is still derived from patch_bootargs and the bootargs at aop.rs:3311-3312. So a stray memory-region on a SoC without patch_bootargs still fails probe and does not start the AOP unchecked. Nothing else changed.

HW row: this head on the current integration/aurora tip, default command line, on J413 with the 27.2 stub and the loader that lists the AOP segments (aura#377): AOP ready, both audio cards and all six IIO devices present, 0 AVC, 0 failed units, 0 new kernel errors. Then one boot of a T8112 on the 13.5 stub, or another Mac whose AOP gets no memory-region, showing the AOP comes up as before.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr 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.

Adversarial pre-PR checklist review (§1–§6) on 4c637bf72e3c70e24045f2269f278d2c6baf1531: 0 code, policy, attribution, naming, or CI blockers; holding for §5 hardware proof on the live head.

Verified against surrounding source:

  • §1 No model gating: AopData::lists_fw_regions() (drivers/soc/apple/aop.rs:2121-2126) selects segment checks from the DT memory-region property rather than a SoC/firmware gate, and the bootloader counterpart (aurora-silicon/aura#377) is merged on main (f5360de3859c).
  • §2 / §3 Code & safety verification: Checked of_reserved_mem_region_count() (drivers/of/of_reserved_mem.c:944 -> of_count_phandle_with_args(np, "memory-region", NULL) at drivers/of/base.c:1713-1722): returns -ENOENT when absent, 0 if empty, and size / 4 > 0 when phandles exist. In probe() (aop.rs:3309-3316), cfg.fw_regions (true on T6040/T6041/T8132) continues to require memory-region, while lists_fw_regions() now enables the same pre-start IOMMU validation when a loader provides segments on other SoCs (T8112 27.2). allow_ed0p remains gated on cfg.patch_bootargs && AopData::bootargs_has_ed0p(&aop_mmio, cfg.bootargs_word_access)? before any MMIO write or ASC_CPU_CONTROL start, so a stray memory-region on a patch_bootargs: false SoC fails probe rather than booting unchecked. bootargs_has_ed0p() (aop.rs:1882-1934) handles bootargs_word_access: false (T8112) via copy_to_slice.
  • §4 Clean-room & attribution: Single commit 4c637bf72e3c carries human author/committer and human Signed-off-by only (0 AI trailers); PR body includes Assisted-by:.
  • §6 Naming: Clean.
  • CI: All 7 checks green (host-tests, source, rust-build, kunit, and all three DWC3/ATC build profiles).

Holding for §5 hardware proof on 4c637bf72e3c:

  1. J413 (T8112, 27.2 stub) on current integration/aurora + 4c637bf72e3c with merged aura#377 on the default kernel command line: Validated external data region at IOVA ..., AOP IS READY, both audio cards and all 6 IIO devices present, plus regression counts (0 SELinux/AVC denials, 0 failed units, 0 new kernel errors).
  2. Non-memory-region regression boot (T8112 on 13.5 stub, or another non-T6040 Mac whose AOP node has no memory-region) confirming apple_aop comes up unchanged with 0 regressions.

Assisted-by: LLM (Gemini 4 Neon)

…s them

The macOS 27.2 AOP firmware on T8112 runs its external code and data
from DRAM, as the T6040 firmware does, so it needs the same checks of
the segments the boot loader reserves: every page mapped where the
device tree says, the external code at its fixed address, and the
translated __EDATA passed as ED0p. The 13.5 firmware on the same SoC
needs none of this.

Select the checks by the device tree instead of by SoC: also run them
when the AOP node has a memory-region. Only a loader that handed the
segments over lists them, and no SoC whose configuration leaves the
checks off gets one today, so nothing changes elsewhere.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj force-pushed the satchlj/t8112-aop-fw-regions branch from 4c637bf to 9955fbf Compare November 22, 2026 10:43
@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 9955fbf. This is a rebase onto integration/aurora d1b022d. The base already has an identical AopData::has_fw_regions() (drivers/soc/apple/aop.rs:2118, from the T8122 fallback work), so the selector now uses it (aop.rs:3348) and lists_fw_regions() is gone. I checked it against for_regions():

  • A T8122 without memory-region still starts as apple,t6020-aop and skips the check.
  • A T8122 with memory-region is unchanged.
  • T8112 with loader segments gets the full check, with allow_ed0p still tied to patch_bootargs and the bootargs.

No code concerns. One small optional change: has_fw_regions is evaluated twice in probe (aop.rs:3326 and 3348), and a local would read better.

Still needed at this head:

  • the J413 27.2 default-boot row with 0 AVC, 0 failed units and 0 new kernel errors;
  • one boot of a Mac whose AOP gets no memory-region (13.5-stub T8112 or similar), showing the AOP comes up as before.

Assisted-by: LLM (Claude:Opus 5.5)

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.

3 participants