Skip to content

iommu/apple-dart: import a locked four-level root before the core's reservations - #3686

Merged
satchlj merged 1 commit into
mainfrom
fix/dart-four-level-live-import
Dec 1, 2026
Merged

satchlj merged 1 commit into
mainfrom
fix/dart-four-level-live-import

Conversation

@satchlj

@satchlj satchlj commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

A boot loader that hands a running display co-processor over on a locked four-level DART stream (T6050: the external DCPs' firmware DARTs, TCR four-level, firmware mapped under root entry 16 at 1 TiB) re-exports the firmware's RTKit system buffers as iommu-addresses on the DCP. Their DVAs sit in the root slot the firmware holds.

The domain imported a locked root at finalize only for a three-level table. For a four-level one, iommu_create_device_fw_mappings() found nothing at those DVAs and copied the buffers into Linux's own table, in that same root slot. The first attach then refused to publish the slot (apple_dart_publish_root(): a firmware slot with no recorded three-level leaf), so iommu_setup_default_domain() warned (iommu.c:3242, MUST_SUCCEED attach) and the DART failed to probe:

apple-dart 2b2340000.iommu: params 1e313020 31122087 2a2a0204 00010020, version 0204, 32 streams, AS 42 -> 42, protect 000000ff/000000ff, ...
platform 2b2e00000.dcp: Adding to iommu group 3
WARNING: drivers/iommu/iommu.c:3242 at iommu_setup_default_domain+0x30c/0x538
 iommu_device_register+0x10c/0x200
 apple_dart_probe+0x277c/0x3898
apple-dart 2b2340000.iommu: probe with driver apple-dart failed with error -16
platform 2b2e00000.dcp: deferred probe pending: platform: supplier 2b2340000.iommu not ready

The other external DCP's DART on the same machine, with the same parameters and also handed off but without a live RTKit session (so no re-exported buffers), registers.

This imports the four-level root at finalize too, on a DART that records the firmware's four-level subtrees (fw_tree). iova_to_phys then resolves the re-exported buffers through those subtrees, so the core leaves them to the firmware; apple_dart_get_fw_resv_regions() keeps the slot out of IOVA allocation; and the attach publishes nothing into it. A four-level root without recorded subtrees is left to the attach as before, and three-level roots are unchanged.

Two KUnit cases build such a stream (a firmware page under root entry 16): the finalized domain resolves the page, the attach-time sync leaves the firmware slot alone, a Linux copy of the page in that slot is still refused with -EBUSY (the boot failure), and a DART without recorded subtrees does not import early.

Tested: KUnit apple-dart suite on arm64 QEMU with 16K pages (CONFIG_APPLE_DART_KUNIT_TEST): 38/38 pass at the PR head; with only apple-dart.c reverted to main, apple_dart_test_four_level_live_import fails (the domain does not resolve the firmware page, as on the boot above). checkpatch --strict clean. On hardware: an M5 Max Mac Studio (J775c) kernel of main + this head + #3689 + #3682, with the HDMI handoff from aura#605, has booted about 30 times since Nov 30 on the default command line: the dcpext0 DART registers (no iommu.c warning, no probe failure), the DCP binds, and the HDMI display shows the console and the greeter.

Regression: J773g (M4, three-level DARTs), a boot of #3689's head (which contains this head): all 17 DART instances register, no iommu.c warning, display, NVMe and GPU as on main, 0 failed units (#3686 (comment)).

Not yet: nothing.
Risk: two-way door. Changes when a locked four-level root is imported on DARTs with fw_tree (T6050 display DARTs); other DARTs and three-level roots are unchanged.

…eservations

A boot loader that hands over a running co-processor on a locked
four-level stream re-exports the firmware's own buffers (its RTKit
system buffers) as iommu-addresses. Their DVAs sit in the root slot the
firmware holds, as every DVA the firmware placed does.

The domain imported a locked root at finalize only for a three-level
table. For a four-level one the core's iommu_create_device_fw_mappings()
found nothing at those DVAs, copied the buffers into Linux's own table
in the same root slot, and the first attach then refused to publish that
slot (apple_dart_publish_root(): a slot firmware holds that has no
recorded three-level leaf), so iommu_setup_default_domain() warned and
the DART failed to probe with -EBUSY. The co-processor's consumer then
defers on it for good.

Import the four-level root at finalize too, on a DART that records the
firmware's four-level subtrees (fw_tree). iova_to_phys then resolves the
re-exported buffers through those subtrees, the core leaves them to the
firmware, apple_dart_get_fw_resv_regions() keeps the slot out of IOVA
allocation, and the attach publishes nothing into it. A four-level root
without recorded subtrees is left to the attach as before.

The KUnit cases build such a stream (a firmware page under root entry
16) and check that the finalized domain resolves the page, that the
attach-time sync leaves the firmware slot alone, and that a Linux copy
of the page in that slot is still refused; and that a DART without
recorded subtrees does not import early.

Signed-off-by: Satya Benson <[email protected]>
@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

J775c trial row at this head (3be2702b): kernel linux f8a75324b0 (main + this PR), DTB main + #3682 (sha256 620119c2…), Stage 2 aura 36e85e1a (#602 stack), monolithic config, firmware 27.2.

The DART fix works. dcpext0's DART (2b2340000) now probes with no warning and no -EBUSY, and apple-dcp reaches dcp@2b2e00000. Boot has 0 failed units, Wi-Fi up, and returned to the default unaided.

Next stop: apple-dcp refuses the live session:

apple-dcp 2b2e00000.dcp: DCP index:1 dptx target phy: 4 dptx die: 0
apple-dcp 2b2e00000.dcp: error -EINVAL: Invalid live RTKit handoff
apple-dcp 2b2e00000.dcp: external display processor unusable (bind failed: -22); the other displays go on without it
apple-drm display-subsystem: 2b2e00000.dcp: external display processor unusable, skipped
platform 2220000000.memory-controller: deferred probe pending: apple-mcc: waiting for /soc/dcp@2b2e00000 to retire boot scanout

Stage 2 printed FDT: dcpext0: live RTKit session v12, 3 system buffer(s), epmap 0000011d 00823f3f. Linux reserved only two of them (dcpext0-rtkit-ep4@1000e5c0000 and dcpext0-rtkit-ep2@1000e5d0000), so the third buffer is the first thing to check. dcpext1 (no live session) initializes RTKit itself and exposes DP-1..4, all disconnected. HDMI is not in DRM, so simpledrm still owns the framebuffer and SLC stays off (GPU bandwidth 554/556 GB/s at depth 4/8).

@satchlj

satchlj commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

J775c end-to-end row with this PR + #3689 + #3682: #3689 (comment)

@satchlj
satchlj marked this pull request as ready for review November 30, 2026 20:55
@satchlj
satchlj requested review from a team as code owners November 30, 2026 20:55
@satchlj
satchlj requested review from Acelogic and maralcbr November 30, 2026 20:55
@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merge readiness at 3be2702b: ready to merge

Check Detail
CI at head ok 25 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 3be2702b
Conflicts ok none
PR text ok Risk: two-way · . Changes when a locked four-level root is imported on DARTs with fwtree (T6050 display DARTs); other DARTs and three-level roots are unchanged.

Areas: area:platform
Merge: gh pr merge 3686 --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.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: HOLD at 3be2702b

Blockers:

  1. Apple build and KUnit CI is still queued at 3be2702b. Host tests, pr-text, and pr-readiness passed, while Apple build and KUnit is still queued.
  2. Missing second-generation Mac regression row (Not yet). drivers/iommu/apple-dart.c is shared across all Apple Silicon Macs; please post a regression boot row on a non-T6050 Mac alongside the J775c 30-boot HDMI proof (confirming 3-level and non-fw_tree DARTs are unaffected).

Checked:

  • Full 2-file diff (drivers/iommu/apple-dart.c, drivers/iommu/apple-dart-test.c, +160/-3), MERGEABLE against main.
  • __apple_dart_finalize_domain() extends root import to n_levels == 4 strictly when stream->dart->locked && (fw_handoff || fw_mirror) && stream->dart->fw_tree, leaving 3-level and non-fw_tree DARTs unchanged; apple_dart_test_four_level_live_import exercises the locked 4-level root import path.
Evidence
  • Code is minimal, well-gated (four && !stream->dart->fw_tree), and backed by ~30 J775c boots with #3689+#3682+aura#605; awaiting queued Apple build and KUnit CI and a second-generation regression boot row.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

PASS — J773g (M4 Mac mini, three-level DARTs) one-shot boot of #3689 head 91ed6a22ef5e3ce34831ad7e8fc083a9738c9b14, which includes this PR's 3be2702b. Every apple-dart instance registers, and display, NVMe and the GPU come up as on main.

  • Kernel: the exact drm/apple: dcp: take a firmware-placed live OSLog buffer sized in bytes #3689 head (source tree checked equal to the head's tree), built with the current main J773g config. Release 7.3.0-ARCH-m4k3689-91ed6a22, booted with its own DTB and the default lab cmdline (no IOMMU options).
  • DART:
    • All 17 apple,t8132-dart instances bound to apple-dart: 17 IOMMU groups, 0 "probe with driver apple-dart failed", and 0 WARNs from iommu.c / iommu_setup_default_domain.
    • The DT's one apple,t8132-dart-smmu node stays unbound, which is expected: apple-dart doesn't claim that compatible.
    • The saved stock kernel (older main, its own DTB) binds 15 apple-dart instances. The two extra ones here, 3a8c80000 and 3ad060000, come from this tree's DTB and bound normally.
  • Display: DCP's three OSLog carve-outs were reserved, and the DRM connector came up connected and enabled.
  • NVMe: nvme0 up, root mounted from it.
  • GPU: the module loaded and the compute.uber d4 smoke matched its CRC b022fbaf, with 0 GPU faults.
  • Health: 0 failed systemd units, 0 kernel WARN/BUG/SError lines.
  • Afterwards: the Mac returned to its saved stock kernel, and the next row confirmed the stock checks.

@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

The 12 KUnit jobs in run 46353355395 waited about four hours for a runner and were cancelled without starting any tests; every job that did run passed. I reran the cancelled jobs at the same head 3be2702b.

@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Both blockers from the HOLD at 3be2702b are cleared: all 21 checks pass at this head (the cancelled KUnit jobs were rerun), and the second-generation row is in, a J773g (M4, three-level DARTs) boot of #3689 head 91ed6a22, which contains this head (comment 7292835569).

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 3be2702b4d0c

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: - Full 2-file diff (drivers/iommu/apple-dart.c, drivers/iommu/apple-dart-test.c, +160/-3), MERGEABLE against main.

  • __apple_dart_finalize_domain() extends root import to n_levels == 4 strictly when stream->dart->locked && (fw_handoff || fw_mirror) && stream->dart->fw_tree, leaving 3-level and non-fw_tree DARTs unchanged; apple_dart_test_four_level_live_import exercises the locked 4-level root import path.

Follow-ups (not blocking): queued Apple build/KUnit (2nd-gen regression row not required)

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

Reviewed at 3be2702b4d0c. The early import is limited to locked four-level streams with a recorded firmware tree. The three-level path and four-level streams without a firmware tree keep their existing behavior. The two KUnit cases cover both four-level paths. Apple build checks passed, and the J775c target and J773g regression rows cover the handoff.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 2026
@satchlj
satchlj merged commit 49befb4 into main Dec 1, 2026
52 of 69 checks passed
@satchlj
satchlj deleted the fix/dart-four-level-live-import branch December 1, 2026 05:25
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) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge 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.

2 participants