Skip to content

iommu/apple-dart: honor a common scanout aperture before intersecting stream defaults - #2145

Merged
RyanTheTide merged 5 commits into
aurora-silicon:mainfrom
scottjones:upstream/dart-scanout-aperture
Nov 26, 2026
Merged

RyanTheTide merged 5 commits into
aurora-silicon:mainfrom
scottjones:upstream/dart-scanout-aperture

Conversation

@scottjones

@scottjones scottjones commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A display consumer can already give its own apple,dma-range, but of_xlate intersects the DARTs' default windows before that override is read. On T8122 the internal and external display DARTs have disjoint defaults, so the shared display subsystem fails configuration before its domain is allocated.

 of_xlate(consumer, dart stream)
-  window = intersect(window, dart default)
+  window = consumer apple,dma-range if it has one
+           else intersect(window, dart default)

The binding documents the optional aperture and the T8122 display subsystem compatible, and t8122-dcp.dtsi describes the common scanout aperture. Consumers without an override keep their windows.

Evidence

  • Built on integration/aurora a7dd26e6d60e with the 7.3 package config, LLVM 18 and Rust 1.85:
    • make W=1 drivers/iommu/: builds
    • W=1: no warnings the base does not have
    • make dtbs: builds, no warnings
    • scripts/dtc/apple-dt-check.sh (CHECK_DTBS base vs head): 0 new warnings, 7 fewer; dt_binding_check passes on the 1 changed binding
    • run-host-tests.py: every tools/asahi test is registered
    • KUnit on arm64 QEMU (stacked tree, PR-related Apple suites): apple-dart 27 pass, 1 skip (base: 25 pass, 1 skip); no failures.
    • Stacked with the other 12 PRs on the same base, the full kernel, modules and DTBs build and package (linux-aurora 7.3.0-0testastip2-1-ARCH, 137 DTBs).
  • Booted as part of the full set: a kernel built from integration/aurora a7dd26e6 plus all 13 branches of this set (before the three small fix-up commits) booted on an M3 MacBook Air (J613), a Neo (J700) and an M1 Pro with no regressions against their baselines (on the M1 Pro, only the checks already known to differ: GPU name and DRAM OPP), and a 25-minute GPU soak was clean on all three. No M3 Pro, M3 Max, J504, J615 or M4 Pro ran this kernel.
  • KUnit cases in the commit cover the J613 high scanout alias across internal and external DART defaults, a low PIODMA window, malformed overrides and bad five-cell specifiers. The author notes external-display qualification on hardware is still pending.

Merge Danger

Door: two-way

Blast Radius: DART

Touches every DART consumer, but only changes behaviour for one that sets apple,dma-range. Later PRs in this set (M3 Max boards) build on the binding change.

Document the display consumer's optional DMA aperture, which can differ
from the defaults of individual scanout DARTs. Include the T8122 display
subsystem compatible so its shared aperture is checked by this binding.

Signed-off-by: DjDeveloperr <[email protected]>
Signed-off-by: Scott Jones <[email protected]>
Domain allocation already lets a consumer specify apple,dma-range, but
of_xlate intersects the provider defaults before that override is read.
A consumer with a common scanout alias and DARTs with disjoint defaults
therefore fails configuration before its domain can be allocated.

Apply the same consumer aperture while parsing each specifier, retaining
validation of both explicit five-cell windows and the override. Share the
alignment, overflow and alias-width checks. Consumers without an override
keep their existing windows.

Add KUnit cases for the J613 high scanout alias across internal/external
DART defaults, independent low PIODMA, malformed overrides and invalid
five-cell specifiers. An ASAN/UBSAN fixture executing the production parser
and of_xlate reproduces the old rejection and accepts the common window.

Signed-off-by: DjDeveloperr <[email protected]>
Signed-off-by: Scott Jones <[email protected]>
The display gate adds the external display DART to the shared display
subsystem. Its low PIODMA default does not overlap the internal display's
inherited 1 TiB alias, so their defaults cannot be intersected for scanout.

Describe the subsystem's common scanout aperture explicitly, matching the
internal DART. The external PIODMA consumer retains its existing low
aperture and the external processor still requires the firmware-ready
gate. This is a software-validated candidate; hardware external-display
qualification remains pending.

Signed-off-by: DjDeveloperr <[email protected]>
Signed-off-by: Scott Jones <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 3.

  1. drivers/iommu/apple-dart.c:3910-3917: when the consumer has apple,dma-range, each DART's own window is now replaced, not intersected, so the shared domain can use DVAs that a member DART's node excludes. On T8122 the external display DART's window is <0x0 0x0 0xf 0xffff0000> (arch/arm64/boot/dts/apple/t8122-dcp.dtsi:124), which leaves out the top 64 KiB, while the new aperture is the full 64 GiB <0x10000000000 0x1000000000> (t8122-dcp.dtsi:37). The mapping paths mask the IOVA to the DART's address bits ((iova + dma_offset) & mask, e.g. apple-dart.c:2965), so the last 64 KiB of the aperture lands in the range the external DART excludes. Compare the low ias bits instead: keep the consumer's alias bits, intersect window & DMA_BIT_MASK(ias) with each DART's masked window, and fail with "non-overlapping" as of_xlate does today when nothing is left. A smaller DT aperture (0xfffff0000) would also avoid it here, but only as long as the two DART nodes do not change.
  2. All three commits carry Assisted-by: OpenAI Codex (gpt-6.1-sol). Drop it from the commits (keep the human Signed-off-by lines) and end the PR body with Assisted-by: LLM (<Vendor>:<Model>) instead of the "Generated with Claude Code" line.
  3. Nothing in the evidence runs the case this change exists for. The boots listed (J613, J700, M1 Pro) are with the full set and say nothing about an external display, and the last commit says external-display qualification is still pending. The KUnit cases exercise the parser only; they don't show that the shared domain scans out on both DARTs.

HW row: J613 (or J615) on integration/aurora plus this branch, default command line, internal panel plus an external display through the display gate: both outputs scan out, no DART faults and no "non-overlapping DMA windows" in dmesg, hotplug the external display 5 times; plus 0 AVC denials, 0 failed units and 0 new kernel errors against the same base without the branch.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at 4e33348: BLOCKERS.

Not merging until the blockers below are fixed or answered; the details give file:line and a failure case.

Full review

#2145 iommu/apple-dart: honor a common scanout aperture before intersecting stream defaults @4e333487

VERDICT: BLOCKERS

Blockers:

  1. drivers/iommu/apple-dart.c:3910-3917 (apple_dart_parse_dma_window()): when the consumer has apple,dma-range, each member DART's own window is thrown away instead of intersected. Domain allocation already did this (apple-dart.c:3759-3770 sets has_dma_range, and __apple_dart_finalize_domain() at :3237-3238 then ignores cfg->dma_min/max). So once of_xlate stops refusing, the shared domain's aperture is the consumer window and nothing else checks it.
    • The PR's own KUnit case shows the result (apple-dart-test.c, apple_dart_test_consumer_window). The external DART's window ends at 0xffffeffff (t8122-dcp.dtsi:124, <0x0 0x0 0xf 0xffff0000>), yet the result for that stream is 0x10000000000..0x10fffffffff.
    • The mapping paths mask the IOVA to the DART's address bits ((iova + dma_offset) & mask, apple-dart.c:2965). The top 64 KiB of the aperture (0x10fffff0000..) therefore lands at 0xfffff0000.., which the external DART's node excludes.
    • iommu-dma hands out IOVAs from the top of the aperture down, so the first buffers mapped once the external stream joins display go exactly there.
    • Latent today: in this tree display has only iommus = <&disp0_dart 0> (t8122-dcp.dtsi:35). But making that addition possible is the whole point of the PR, and the DT comment at :36 says so.
    • Fix: keep the consumer's alias bits and intersect window & DMA_BIT_MASK(ias) with each DART's masked window. Fail with "non-overlapping" when the intersection is empty.
  2. All three commits carry Assisted-by: OpenAI Codex (gpt-6.1-sol) (1ccee5b, 130cd47, 4e33348). Commits must have only the human Signed-off-by lines (DjDeveloperr, Scott Jones are present). The PR body also ends with the "Generated with Claude Code" line instead of Assisted-by: LLM (...).

Nits:

  • apple-dart.c:3910: of_xlate now validates every consumer's apple,dma-range against each DART's pgsize and ias. Before, it was checked only when a paging domain was allocated. A consumer whose default domain is identity/bypass and whose property is malformed now fails probe in of_xlate. I found no such node in the touched DTs, but this applies to every DCP, AOP, JPEG and PCIe consumer that has the property (t600x-pciec, t602x-dieX, t6021-display2, t6030/t6031-dcp, t6040 extdisp, ...), not only T8122.
  • The 5-cell specifier window is now silently overridden when the consumer has the property (the test "Domain allocation gives the consumer priority over five-cell args too"). No node in this tree has both, but nothing logs that it happened.
  • t8122-dcp.dtsi:37: the aperture equals disp0_dart's window (<0x100 0x0 0x10 0x0>, :70), so the internal-only domain does not change. That is good, and it also means the DT commit changes nothing on J613/J615 today.

Missing rows:

  • No run exercises the shared internal+external domain this exists for (the commit says external-display qualification is pending).
  • The full-set boots (J613, J700, M1 Pro) don't cover it, and the change touches of_xlate for every DART consumer with apple,dma-range. That needs a boot row on M1 Pro/Max (t600x PCIe), M2 Pro/Max (t602x), M3 Pro/Max (t6030/t6031 DCP) and J616s (t6040 extdisp) showing all DART consumers probe, with 0 new "Invalid DMA window"/"non-overlapping" lines.
  • Needed: J613 or J615 with an external display wired into display, both outputs scanning out, 5 hotplugs, no DART faults.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Clarification to my merge-train review above: the commit-trailer point is a nit, not a blocker (already-pushed history stays as it is, no force push). The other blockers listed there still stand.

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

Formal §1–§6 pre-PR review at verified live head 4e3334872df8d6e618c7089ab7e87a3c68760508 (base integration/aurora 70a00e583b03; not superseded by #2189 or other recent apple-dart.c commits; MERGEABLE/clean; live CI 2/2 PASS: Host tests run 44113747350, Device tree checks run 44113747443).

Blockers Before APPROVE

  1. §2 / §3 DMA aperture safety bug — consumer apple,dma-range discards each member DART's own window instead of intersecting masked offsets (drivers/iommu/apple-dart.c, arch/arm64/boot/dts/apple/t8122-dcp.dtsi:38,129):
    • In apple_dart_parse_dma_window(), when dev->of_node has apple,dma-range, *dma_min/*dma_max are overwritten outright with the consumer property instead of intersecting its low dart->ias-bit range against the DART stream's own masked window (dart->dma_min..dart->dma_max or 5-cell specifier window). Furthermore, in live apple-dart.c, apple_dart_domain_alloc_paging() (:4039-4051) sets dart_domain->has_dma_range = true, causing __apple_dart_finalize_domain() (:3506-3507) to ignore cfg->dma_min/cfg->dma_max altogether and use the raw consumer window.
    • Concrete failure case (confirmed by the PR's own apple_dart_test_consumer_window test and t8122-dcp.dtsi):
      • dispext0_dart (t8122-dcp.dtsi:129) defines apple,dma-range = <0x0 0x0 0xf 0xffff0000>; (0x0..0xffffeffff), excluding the top 64 KiB (0xfffff0000..0xfffffffff).
      • display (t8122-dcp.dtsi:38) sets apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>; (full 64 GiB 0x10000000000..0x10fffffffff).
      • Mapping paths mask IOVAs to dart_domain->mask ((iova + dart_domain->dma_offset) & dart_domain->mask, live apple-dart.c:3234,3264,3299,3361). Thus the top 64 KiB of the shared aperture (0x10fffff0000..0x10fffffffff) maps directly into dispext0_dart's excluded 0xfffff0000..0xfffffffff range — and because iommu-dma allocates top-down, the very first buffers allocated once dispext0_dart joins display will land there.
    • Fix: Preserve the consumer's alias bits (alias = consumer_min & ~mask), intersect (consumer_min & mask)..(consumer_max & mask) with the stream's (stream_min & mask)..(stream_max & mask) (failing with -EINVAL if empty), return [alias | low_min, alias | low_max] from apple_dart_parse_dma_window(), and ensure __apple_dart_finalize_domain() respects the intersected cfg->dma_min..cfg->dma_max rather than widening it back to an un-intersected dart_domain->dma_min/dma_max. Update apple_dart_test_consumer_window to assert 0x10000000000..0x10ffffeffff for the external DART and add a non-overlapping masked-window negative test.
  2. §4 Attribution — AI commit trailers present (hard rule):
    • All three commits (1ccee5b0b157, 130cd47bac10, 4e3334872df8) carry Assisted-by: OpenAI Codex (gpt-6.1-sol) inside the commit message. Per §4, commits must carry human identity and human Signed-off-by: only, with zero AI commit trailers. Replace the PR body's Generated with [Claude Code] footer with a plain Assisted-by: line.
  3. §5 Exact-head hardware & regression evidence missing:
    • Commit 4e3334872df8 and the PR body state external-display qualification is still pending, and t8122-dcp.dtsi:35 currently lists only <&disp0_dart 0> so the stacked boot did not exercise the multi-DART shared scanout path and omitted the §5 regression triad.
    • After fixing the aperture intersection above, please provide exact-head hardware evidence on default cmdline exercising the shared internal+external scanout domain (e.g., J613/J615 with internal panel + external display, hotplug, 0 DART faults, 0 "non-overlapping DMA windows" / "Invalid DMA window" errors) and confirming zero regressions across existing apple,dma-range DART consumers (with the §5 regression triad: 0 SELinux denials [or N/A], 0 failed units, 0 new kernel errors).

@scottjones
scottjones force-pushed the upstream/dart-scanout-aperture branch from 4e33348 to 36a5f13 Compare November 23, 2026 23:25
The display subsystem's apple,dma-range was described as overriding the
aperture of each referenced DART stream. The DART driver now keeps the
bits above a DART's address width as the alias and intersects the rest
with each stream's window, so the aperture never extends past any of
them. Describe that.

Signed-off-by: Scott Jones <[email protected]>
A consumer's apple,dma-range replaced the window of every DART stream it
used, and domain allocation then used the raw consumer window again. The
DART translates only the low ias bits of an IOVA, so the consumer window
could reach addresses that one of its streams excludes.

On T8122 the display subsystem's aperture is 0x10000000000..0x10fffffffff
and dispext0_dart excludes its top 64 KiB (0xfffff0000..0xfffffffff).
Once dispext0_dart joins the display, the top 64 KiB of the shared
aperture masks into that excluded range, and iommu-dma allocates
top-down, so the first buffers land there.

Keep the consumer's bits above ias as the alias, intersect its low bits
with the stream's window masked the same way, and refuse a consumer
window that does not overlap a stream's window. of_xlate already
intersects the streams, so finalize the domain with that master window
and drop the separate consumer window kept by domain allocation.

Every other in-tree consumer with apple,dma-range sits on a DART whose
window is the full ias range, or one that covers the consumer window
(the T6041 JPEG DARTs, which need ias >= 42 to probe), so its window
does not change.

Update the J613 consumer case to expect 0x10000000000..0x10ffffeffff
for the external DART and for a five-cell stream window, and add cases
for disjoint and single-page overlaps.

Fixes: 6245efd ("iommu/apple-dart: honor consumer apertures before intersecting streams")
Signed-off-by: Scott Jones <[email protected]>
@scottjones
scottjones force-pushed the upstream/dart-scanout-aperture branch from 7773a1b to 7e60426 Compare November 24, 2026 05:06
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026

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

Verdict: FINISH, then merge at 7e604265b39b: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: this changes which DMA apertures the display DARTs accept, so it needs one J613 or J615 boot at this head, with the internal panel and an external display scanning out and no DART faults. Thanks for the quick fix.

Because apple-dart.c runs on every Mac, it also needs one boot at this head on another generation with its displays scanning out and no DART faults before it merges.

Checked: no Apple material, no gates. 7e604265 fixes the point from my last review: a consumer's apple,dma-range is now intersected with each member DART's own window instead of replacing it, and the binding says so. CI green.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 25, 2026 05:08

Superseded by the review at 7e60426

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at 7e604265: ready to merge

Check Detail
CI at head ok 3 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 7e604265
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:platform
Merge: gh pr merge 2145 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@RyanTheTide

Copy link
Copy Markdown
Contributor

7e604265b39b (batched cleanly in J616s Batch #3 cc59e9b94d16 over main 7c0c2fc25ffc, 0 merge-tree diffs across all 4 changed files) J616s (MacBook Pro 16" M4 Pro, T6040, Apple M4 Pro (G16S B1), macOS 26.6.2 fw, guarded one-shot 7.3.0-aurora-pr2905+, default cmdline, stock Stage 2 1.0.0b17, boot_id=01629efb) PASS: 0 failed units, Enforcing, 0 new AVC (1 matching baseline), 0 GPU faults, 0 subsystem errors, real rtc1 s2idle 2/2 (success=2 fail=0), eDP connected pre/post-sleep, 406600000.sep + 514600000.mtp RTKit v12 clean, Borealis VK dEQP-VK.api.smoke.* 8/8 (pre & post-sleep) + glsl.loops.* 624/624, Wi-Fi 3/3 ping pre/post-sleep; stock 7.3.0-aurora-fleet89 restored & verified (946097c2).

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 26, 2026
@github-actions github-actions Bot added the ready-to-merge Meets the merge policy: merge it (bot) label Nov 26, 2026
@RyanTheTide
RyanTheTide merged commit 6f84f56 into aurora-silicon:main Nov 26, 2026
6 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merged into main. Thank you! It went through the J616s batch row at this head (0 failed units, 0 GPU faults, s2idle 2/2), and Dj's review.

@scottjones

Copy link
Copy Markdown
Contributor Author

These runs were done before the merge, so they apply to what's on main now.

J613 (13-inch M3 Air) results: the display crashes at the current head 7e604265, and is clean without it

Every run was built on main 8b0a3832, with the fleet config, and judged on the internal display:

Tree Display
main + all five commits (head 7e604265) crash: DART 28d304000 NO PMD FOR IOVA at 0x10007800000 2.8 s into boot, then RTKit: co-processor has crashed; brightness unreadable, s2idle fails
main + a02fd54e, 6245efd7, 36a5f137 clean: 0 DART faults, no DCP crash, brightness reads back, s2idle 1/1
main + those three + f3c1254b clean, same as above (the J613 DTBs are byte-identical)

So 7e604265 is what brings the crash back on the J613. 6245efd7 alone fixes it. A bisect of a carry stack based on plain 00cbc67d also lands on that same patch as the fix.

Details
  • With all five commits, the non-overlapping DMA windows warning is gone, but the fault and the crash remain.
  • 7e604265 narrows the J613 display window to 0x10000000000..0x10ffffeffff. The first fault is inside that range, so its cause is something other than the excluded top 64 KiB. I haven't found what yet.
  • GPU checks were not part of this run, because main doesn't have the M3 runtime yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) door:two-way Revertible or not, from Merge risk (bot) needs-template PR body lacks Tested or Risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants