Skip to content

iommu: apple-dart: keep a 27.2 J773g dcpext's locked display DARTs like the J713's - #2596

Closed
RyanTheTide wants to merge 4 commits into
j713-disp2/dcp272-internalfrom
j713-disp2/dcp272-j773g-dcpext
Closed

RyanTheTide wants to merge 4 commits into
j713-disp2/dcp272-internalfrom
j713-disp2/dcp272-j773g-dcpext

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

On the macOS 27.2 stub, the M4 Mac mini's (J773g) dcpext0 runs the firmware-27 backend from #2541. On a 27.2 mini its display DARTs aren't borrowed, so they take the plain locked path. If iBoot leaves them locked with the firmware's live slots, the boot loader's re-exported firmware segments land in those slots. apple_dart_publish_root() refuses any Linux table there, so the attach fails and the processor has no IOMMU domain. #2578 then refuses the processor.

This is the failure the M4 MacBook Air (J713) hit on its internal DCP. #2590 fixed it there with two changes; this ports both to the J773g dcpext, as Dj asked.

Change

Stacked on #2590.

  • A locked T8132 DART that an available 27.2 dcpext names, in its own iommus or its PIODMA's (selected by apple_t8132_dcpext_v27_2(), not by address), gets the locked-root handling (fw_mirror).
  • Its re-exported firmware segments are mapped with their live leaves' protection. The flag is renamed fw_live_prot, since it now covers both cases.
  • An unlocked DART is left as it was. The Air's borrowed external DARTs are never selected.

Testing

  • Host only (we have no J773g): apple-dart KUnit (arm64 qemu) 226/227, the one skip unrelated; the segment-protection case is renamed and passes.
  • apple-dcp selftests 89/89.
  • W=1 build of apple-dart.o plus the t8132-j713 and t8132-j773g DTBs, no new warnings.

Still to run

  • Dj's first J773g 27.2 dcpext0 bind. Expected boot line: T8132 external display DART on the 27.2 image: locked roots kept (mirror) (or not locked) for 286340000 and 286300000. If it reports "not locked", this change does nothing.
Reviewer / agent detail
  • Why the plain locked path refuses: apple_dart_publish_root() returns -EBUSY for a slot whose live entry is non-zero unless apple_dart_fw_slot_owned() finds it in a firmware snapshot. The snapshot (apple_dart_snapshot_fw_root()) exists only with fw_mirror or fw_handoff, and fw_mirror was compatible-gated to t6041/t6050/t8140/t8142.
  • Why the protection matters: an exact-mirror slot must match read/write/cache (apple_dart_fw_slot_mirrors()). The core maps iommu-addresses regions read-write, and uncached for a dma-noncoherent DCP (the T8132 dcpext nodes are). On the J713 the firmware's text leaves are read-only and every segment is cacheable, so every segment was refused until the regions take the leaves' protection.
  • J713 evidence for the same two changes (our own logs): appledrm bound on 27.2, 0 DART faults over 8 boots (see drm/apple, iommu: apple-dart: drive the M4 MacBook Air's internal panel on macOS 27.2 (v27 backend) #2590).
  • Selection: apple_dart_serves_t8132_dcpext_v27() walks the apple,t8132-dcpext nodes that are available and pass apple_t8132_dcpext_v27_2(), and matches the DART in the node's iommus or its children's (PIODMA). On the J773g DT that is dcpext0_dart (SID23) and dispext0_dart (SID16; the display gate also points the display subsystem's SID0 there).

Assisted-by: LLM (Claude:Opus 5.5)

…ke the J713's

On the macOS 27.2 stub the M4 Mac mini's (J773g) dcpext0 runs the
26B123 image on the firmware-27 backend (apple_t8132_dcpext_v27_2()).
Its firmware and display DARTs are not borrowed there (the T8132
firmware path is the Air's or 26.6.2's), so they take the plain locked
path. The boot loader re-exports the processor's firmware segments into
slots its firmware already holds, and on that path
apple_dart_publish_root() refuses any Linux table in such a slot: the
attach would fail and leave the processor without a domain.

Give a locked DART that an available 27.2 T8132 dcpext names in its
iommus, or in its PIODMA's, the locked-root handling the J713's internal
display DARTs get on 27.2 (fw_mirror), and map its re-exported segments
with their live leaves' protection (the flag is now fw_live_prot). An
unlocked DART is left as it was. The Air's borrowed external DARTs are
never selected.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@DjDeveloperr

DjDeveloperr commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Hardware note from the J773g (M4 Mac mini, macOS 27.2 stub), 11-20. This is not a row for this PR's own code.

The kernel that ran on the mini was hvtrace/m4drv8-dcp272 @ 010c3eb (m4drv8 + #2541 + #2578). For the dcpext0 DARTs it carried our own interim patch, afcbcf4 ("keep the J773g's 27.2 external display DARTs' locked roots"), not this PR's 4b4cf9e (ported to m4drv8 as 4e080f9). Both select the same thing: fw_mirror plus live-leaf protection for the locked dcpext0 SID23 and dispext0 DARTs when dcpext0 has the 27.2 handoff. They differ in two ways:

What the hardware showed with afcbcf4:

So the dcpext0 path is proven with the locked-roots mirror approach. This PR still needs its own row: a boot of an Image with it (4e080f9) (hvtrace/m4drv8-dcp2596, pushed; its Image is not built yet) and the "T8132 external display DART … locked roots kept (mirror)" line. That boot will be reported here.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 1.

  1. drivers/iommu/apple-dart.c:5531-5533 and :5464-5478 take the locked-root path only when the DART serves a dcpext that apple_t8132_dcpext_v27_2() accepts, and that helper is of_machine_is_compatible("apple,j773g") plus the 26B123 image UUID (include/linux/soc/apple/t8132.h:82-87). So whether a locked T8132 DART keeps its firmware's roots is decided by board and firmware build, while the thing that actually matters is visible on the DART itself: it is locked, and its live root slots hold the firmware's tables. The T6041/T6050/T8140/T8142 DARTs already get fw_mirror for any locked instance without a handoff (:6036-6041). Do the same for apple,t8132-dart, keeping out only the borrowed external DARTs (j713_dcpext/j713_dispext, which are already excluded at :5531), and set fw_live_prot whenever fw_mirror is set. __apple_dart_fw_live_prot() already leaves a region alone when its live leaf maps another page or disagrees, so the protection change is self-limiting. Then the J773g, a 26.6.2 mini and any other T8132 with a locked display DART all take one path, and apple_dart_serves_t8132_dcpext_v27() can go. If some locked T8132 DART must not mirror, say which one in the commit message and exclude it by a property of that DART.

The selection walk itself is correct: for_each_compatible_node/for_each_child_of_node drop their references when they run to completion, and an unlocked DART stays on the plain path.

HW row: J773g on 27.2 with this head (not the interim afcbcf4): locked roots kept (mirror) on 286340000 and 286300000, the live-leaf protection lines, appledrm lit on HDMI, 0 DART faults. Plus a J713 boot of the same kernel with the internal panel lit and 0 DART faults, and 0 AVC, 0 failed units, 0 new kernel errors on both.

Assisted-by: LLM (Claude:Opus 5.5)

…p272-j773g-dcpext

#2590 gained the review follow-ups (firmware-table and window checks in
the live-leaf protection, the refusal as dev_err) and a merge of its
base. Keep this branch's fw_live_prot name for the flag and the
function, with #2590's checks inside it and its dev_err split beside the
T8132 external display line; the KUnit case keeps the new name and
gains #2590's reserved tables, window and mixed/outside cases.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…p272-j773g-dcpext

#2590 now keys a 27.2 internal display DART on its processor's handoff
with apple_dart_serves_t8132_dcp_v27(), the internal twin of this
branch's apple_dart_serves_t8132_dcpext_v27(). Resolve them into one
helper, apple_dart_serves_v27_dcp(dart, compatible, predicate), used
with apple,t8132-dcp / apple_t8132_dcp_v27_2() for the internal
processor and apple,t8132-dcpext / apple_t8132_dcpext_v27_2() for the
external ones.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 1.

  1. The machine check in apple_t8132_dcpext_v27_2() is gone at f2e99bf (t8132.h:83-87), but it came in with the merge of drm/apple, soc: apple: drive the M4 Mac mini's (J773g) HDMI from dcpext0 on macOS 27.2 (v27 backend) #2541's 2451da0, and the rest of the earlier point still stands: apple-dart.c:5542 and :6048-6060 put a locked apple,t8132-dart on the mirror path only when an available dcpext node carries the 27.2.0 image, and the exclusion of the borrowed DARTs (:5528-5534) is apple_t8132_firmware_path() plus four fixed addresses. Whether the firmware's roots must be kept is visible on the DART itself (dart->locked and its live slots), as the T6041/T6050/T8140/T8142 DARTs already use. Please give fw_mirror to any locked apple,t8132-dart without a reserved-table handoff except the borrowed ones, set fw_live_prot with it (__apple_dart_fw_live_prot() only changes a region whose every page's live leaf maps exactly that address with one protection), and drop apple_dart_serves_t8132_dcpext_v27(). If a locked T8132 DART must not mirror, name it in the commit message and exclude it by a property of that DART.

Smaller: an unlocked DART serving a 27.2 dcpext stays on the plain path (:6057-6063) while the internal case is refused; please refuse it too or explain why programming it under a running processor is safe. The selection walk itself is reference-correct.

Rows: still needs a J773g 27.2 boot of this code (not the interim patch) showing "locked roots kept (mirror)" on 286340000 and 286300000, the live-leaf protection lines, HDMI lit and 0 DART faults, plus a J713 boot of the same kernel with the internal panel lit.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merged #2590's new head forward (906db1f, one merge commit, no force push). #2590 now keys its 27.2 internal display DARTs on the DCP's handoff (2a3bb37), the same way this PR keys the J773g dcpext DARTs. The two lookups are now one helper, apple_dart_serves_v27_dcp(dart, compatible, predicate), called once with apple,t8132-dcp / apple_t8132_dcp_v27_2() and once with apple,t8132-dcpext / apple_t8132_dcpext_v27_2(). KUnit apple-dart 28/28 and apple-dcp 27/27 pass on the merge. The internal half was proven on the J713 (row on #2590). The J773g half still needs a Mac mini row.

Assisted-by: LLM (Claude:Opus 5.5)

RyanTheTide added a commit that referenced this pull request Nov 21, 2026
…xt/air-dcpext-272

#2596 now carries #2590's 2a3bb37, which keys a 27.2 internal display
DART on its processor's handoff and folds the internal and external
DART checks into one helper, apple_dart_serves_v27_dcp(dart,
compatible, predicate). Resolve:

- include/linux/soc/apple/t8132.h: apple_t8132_internal_dcp_v27_2() is
  gone at the base; keep this branch's comment on
  apple_t8132_dcpext_v27_2() and apple_t8132_dcpext_hdmi_v27_2().
- boot.py: keep this branch's comments, which name both boards.
- apple-dart.c: this branch's apple_dart_serves_t8132_dcpext_v27() call
  becomes apple_dart_serves_v27_dcp(np, "apple,t8132-dcpext",
  apple_t8132_dcpext_v27_2), the same body.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…p272-j773g-dcpext

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
RyanTheTide added a commit that referenced this pull request Nov 21, 2026
…xt/air-dcpext-272

#2541 (now 1c70a92) derives the J773g's fixed-DP chain from its
phandles (gate_t8132_run(), machine apple,t8132) and drops the J773g
node list. Keep the Air's 27.2 Type-C dcpext gate as it is: the Airs
return from apple_display_gate_soc() after the 26.6.2 routes before
gate_socs[] is walked, and gate_t8132_dcpext_v27() appends their
display DARTs after whatever the SoC gate left.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

# Conflicts:
#	drivers/soc/apple/display-gate.c

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

Pre-PR checklist review at live head 0d7365a982bb1cf073f3d0c1afc037759a2aff6e (§4 human commit attribution/SoB and §6 naming clean).

Blockers

  1. §1 violation — firmware-version & single-build UUID gating (drivers/iommu/apple-dart.c:5477-5492, :5547-5550, :6054-6067)

    • t8132_dcpext_v27 enables fw_mirror and fw_live_prot for apple,t8132-dart only when apple_t8132_dcpext_v27_2() -> apple_dcp_image_v27_2() (include/linux/soc/apple/display.h:30-49) matches apple,firmware-version == <27 2 0>, apple,firmware-compat == <27 2 0>, and the single 26B123 UUID (APPLE_T8132_DCP_26B123_UUID). Any newer macOS 27.x build UUID/version silently disables fw_mirror and breaks display attach again.
    • Right beside it (apple-dart.c:6054-6059), t6041/t6050/t8140/t8142 already enable fw_mirror purely from the DART's own hardware state (dart->locked && !dart->fw_handoff). __apple_dart_fw_live_prot() is also self-limiting (it only adjusts an IOMMU_RESV_TRANSLATED region whose every page matches the live leaf mapping with one uniform protection).
    • Fix: Enable fw_mirror (and fw_live_prot) for locked apple,t8132-dart instances without a reserved-table handoff (excluding only borrowed external/internal DARTs, which are already excluded), and drop the 27.2.0 / 26B123-UUID gate. If a specific locked T8132 DART must not mirror, document which one in the commit message and exclude it by a property of that DART.
  2. Unlocked DART handling asymmetry (drivers/iommu/apple-dart.c:6060-6071)

    • An unlocked internal display DART (j713_display_v27 && !dart->fw_mirror) is refused with -EINVAL (:6068-6071), while t8132_dcpext_v27 && !dart->fw_mirror only logs "not locked" (:6064-6066) and proceeds into normal DART initialization/reset underneath a live 27.2 dcpext. Either refuse symmetrically or justify in code/commit why resetting an unlocked DART serving a live dcpext is safe (if fw_mirror is keyed on dart->locked, this special case disappears cleanly).
  3. Missing CI and §5 hardware proof on live head 0d7365a9

    • The PR is stacked on unmerged #2590 (j713-disp2/dcp272-internal) and has 0 CI checks run (statusCheckRollup is empty).
    • No hardware boot has run #2596's own code yet (the 11-20 J773g boot ran interim patch afcbcf43, not #2596). Needs a J773g 27.2 boot of this head showing locked roots kept (mirror) on 286340000 and 286300000, live-leaf protection lines, HDMI lit, 0 DART faults, plus a J713 regression boot on the same kernel, with 0 SELinux AVC denials, 0 failed units, and 0 new kernel errors on both.

Non-blocking note

  • In __apple_dart_fw_live_prot() (drivers/iommu/apple-dart.c:4594-4599), pm_runtime_put(dart->dev) is called at :4595 before apple_dart_readl(dart, DART_TCR(dart, sid)) at :4598. Move pm_runtime_put() after the DART_TCR read so it cannot perform MMIO after dropping the runtime PM reference if fw_live_prot is broadened to 4-level DARTs.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Closing: this keys the DART handling on one firmware build; a replacement should keep the roots of any locked T8132 display DART, as the newer SoCs already do.

@RyanTheTide RyanTheTide reopened this Nov 22, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Reopened and kept as a draft; the comment above lists what it still needs before review. cc @niteria

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Replaced by #2825 (draft, stacked on #2818). This branch sits on the closed #2590 and brings in #2541's old commits, some with agent trailers, through its merges, and it conflicts with #2818. So the fixes went onto a clean branch rather than here.

How the review points were handled:

  1. Version/UUID gate: removed. fw_mirror for apple,t8132-dart now comes from the DART's own state (locked, no reserved-table handoff, not one of the 26.6.2-path borrowed display DARTs), as it does for T6041/T6050/T8140/T8142. fw_live_prot comes with it on T8132. apple_dart_serves_v27_dcp() and the dcpext predicate are gone from the DART driver.
  2. Unlocked asymmetry: the dcpext special case is gone. An unlocked T8132 DART takes the plain path, as on every other SoC. The 27.2 internal DARTs keep drm/apple, iommu: apple-dart: drive the M4 MacBook Air's internal panel on macOS 27.2 (v27 backend, on #2541's rebase) #2818's refusal, because they are selected by their processor's handoff.
  3. Rows: still needed. See iommu: apple-dart: keep the firmware roots of any locked T8132 DART (J773g 27.2 dcpext0; replaces #2596) #2825: a J773g 27.2 boot of that head (needs an M4 mini owner) and a J713 27.2 boot of the same kernel.
  • Non-blocking: the TCR read in __apple_dart_fw_live_prot() now happens before pm_runtime_put().
Testing on #2825

KUnit arm64 16K: apple-dart 38/38 with a new selection case. With appledrm built in, 284 tests, 282 pass and 2 skip (OF_OVERLAY). apple-dcp host selftests 92/92. apple-dart.o W=1 clean; checkpatch --strict clean.

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.

2 participants