Skip to content

iommu/apple-dart: fix the J700 internal display and SLC with handed-off display DARTs - #235

Merged
maralcbr merged 3 commits into
integration/aurorafrom
neo/t8140-display-dart-handoff-20261025
Oct 29, 2026
Merged

maralcbr merged 3 commits into
integration/aurorafrom
neo/t8140-display-dart-handoff-20261025

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On Neo (J700, T8140), 7.2.11 never enables the system level cache, and the internal display stays on simpledrm. Both come from the display DARTs:

  1. The boot loader marks the T8140 display DARTs apple,firmware-root-handoff. In handoff mode, apple_dart_check_fw_map() refuses every page in a firmware-held slot, even one that repeats the firmware translation exactly. The display subsystem's direct mapping covers two DARTs, and only disp0 holds the translation, so the core maps the region and gets -EBUSY. disp0's DART probe is rolled back:
    iommu apple-dart.412300000.iommu: IOMMU driver was not able to establish FW requested direct mapping.
    apple-dart 412300000.iommu: probe with driver apple-dart failed with error -16
    
  2. The display subsystem never binds.
  3. apple-mcc lists it in apple,boot-dma-devices, so it stays deferred ("waiting for /display-subsystem to bind").
  4. SLC allocation stays off: AMCC +0x82c reads 1 on all four planes.

These are the two commits from aurora-silicon/linux#404:

  • accept mirrored pages in handed-off firmware slots. Handed-off slots get the same per-page rule as the retained-root mirror path: a page is accepted only if the firmware leaf already maps it to the same physical address with the same protection. Every other page in a firmware slot is still refused, four-level streams still refuse everything, and apple_dart_publish_root() still requires the whole Linux leaf to mirror the firmware leaf, so the firmware slot is never written.
  • keep stream invalidates out of handed-off slots. The stream invalidate used at attach and release now goes through apple_dart_fw_invalidate() for handed-off DARTs too, as it already did for mirrored ones. A whole-stream flush could otherwise break the boot framebuffer scanout through firmware-held slots. The pick needed a one-line resolution, because integration/aurora has no apple_dart_has_borrowed(). (Its commit message also lists resume, but apple_dart_resume() returns early for locked DARTs, so resume never reaches it.)
  • keep page tables after a failed invalidate at root retire (review fix, 07d64c6). Retiring a locked root on a mirrored or handed-off DART runs a range invalidate. Its error is now returned and remembered per stream, so apple_dart_domain_free() keeps the page tables after a TLB timeout, also when a consumer release or an attach rollback retired the root first.

Only DARTs the boot loader hands off take the new paths. handoff-other-soc checks that handoff stays off outside T8140.

Testing

  • Host fixture tools/asahi/apple-dart-fw-tests.py: 73/73 pass on this branch. core-second-dart reproduces the two-DART -EBUSY on the old code; the fixture's iommu_map() only calls apple_dart_check_fw_map(), so it covers admission, not publication. The map cases cover a hole, a wrong physical address, a wrong protection, a changed root and a four-level stream, and all of them are still refused. The retire-* cases force the TLB command to time out for a direct free, a release before the free and a rollback before the free; each keeps the page tables, and the timeout cases fail on the old code.

  • Neo, 7.2.11 with this branch: disp0's DART binds and appledrm binds both DCPs (eDP-1 and DP-1), so the internal display leaves simpledrm. apple-mcc logs "system level cache allocation enabled on 4 planes", and the "irq 55: nobody cared" path no longer occurs.

  • GPU rows, µs per submit, with the same G17 driver (drm/asahi: G17 (Neo, T8140) driver update for 7.2.11 #229) and Mesa on both kernels. "7.3" is aurora-silicon with the SLC enabled.

    row 7.2.11 base 7.2.11 + this 7.3
    cross-queue hop 32 22.4 22.7
    compute.light d1 148 106.7 102.2
    compute.light d64 18.9 13.7 13.9
    render.light d32 39.6 29.0 29.4

    A diagnostic module that does only the MCC probe's SLC write, on an unfixed 7.2.11 boot, gave the same improvement, so the GPU change comes from the SLC.

Since the boot loader marks the T8140 display DARTs with
apple,firmware-root-handoff, the J700 internal display stays on
simpledrm. disp0_dart fails to probe:

  iommu apple-dart.412300000.iommu: IOMMU driver was not able to
  establish FW requested direct mapping.
  apple-dart 412300000.iommu: probe with driver apple-dart failed with
  error -16

and the internal DCP waits for it forever.

The display subsystem is one domain over two DARTs, disp0 and dispext0.
Its framebuffer and region94 reservations come from disp0's firmware
tables, which scan out the boot framebuffer. dispext0 does not hold the
same translation, so apple_dart_inherited_phys() cannot report the
region as mapped for the whole domain, and the core maps it. In handoff
mode apple_dart_check_fw_map() refuses any page in a firmware-held
slot, including one that repeats the firmware translation exactly, so
the direct mapping fails with -EBUSY both before and after attach and
the DART probe is rolled back.

Without the handoff property the same DARTs take the retained-root
mirror path, which accepts such a page when the firmware leaf maps it to
the same physical address with the same protection. With that path the
same 7.2.10 package bound the internal DCP on this machine before the
boot loader started setting the property.

Apply the same per-page rule to handed-off slots. Every other page in a
firmware slot is still refused, four-level streams still refuse
everything, and apple_dart_publish_root() already requires the whole
Linux leaf to mirror the firmware leaf before it accepts the slot, so
the firmware slot is never written. dispext0 receives the copy in a
vacant root slot.

In the host fixture, core-second-dart reproduces the two-DART -EBUSY
on the old code. The map cases now cover a hole, a wrong physical
address, a wrong protection, a changed root and a four-level stream,
all still refused. The T8112 SEP DMA host test, which compiles
apple_dart_check_fw_map(), stubs the new helper like the other
firmware-slot helpers it does not reach.

(cherry picked from commit e772e7f)
Signed-off-by: DjDeveloperr <[email protected]>
A whole-stream invalidate on a T8140 DART can break DMA that still runs
through firmware-held root slots, such as the boot framebuffer scanout
of the internal display, as apple_dart_fw_invalidate() describes. Range
flushes already route both the retained-root mirror and the
reserved-table handoff through apple_dart_fw_invalidate(), but the
stream invalidate used at attach, at release and on resume did so only
for the mirror path. A handed-off DART, which the boot loader now
selects for the J700 display DARTs, got a whole-stream flush there.

Treat handed-off DARTs like mirrored ones: invalidate only the slots
Linux published, by DVA range, and do it while retiring a root, before
the root is unmapped. This is what these DARTs did before the boot
loader started handing their roots off.

(cherry picked from commit ff5c39a)
Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr

Copy link
Copy Markdown
Collaborator Author

Hardware result on a fresh omarchy-pkgs install (J700, 10-28)

The released linux-aurora 7.2.11.aurora8-1 (937b727) loses the internal display on every boot (6/6). m1n1-aurora 1.6.1.aurora21 marks the T8140 display DARTs apple,firmware-root-handoff, and without this PR the display-subsystem core's mapping of the boot framebuffer (iova 0x1ea0000 -> 0x101eb4b8000) is refused with -EBUSY:

iommu apple-dart.412300000.iommu: IOMMU driver was not able to establish FW requested direct mapping.
apple-dart 412300000.iommu: probe with driver apple-dart failed with error -16
platform 220000000.memory-controller: deferred probe pending: apple-mcc: waiting for /display-subsystem to bind
platform display-subsystem: deferred probe pending: platform: supplier 412300000.iommu not ready

display-subsystem never binds, apple-drm never loads, the panel stays on simpledrm, and apple-mcc never binds either.

The same tree plus this PR's two commits (95e86af, e2fecd9), packaged as 7.2.11.aurora8-2:

  • disp0 DART probes with no error;
  • apple-drm binds both DCPs;
  • eDP-1 is connected;
  • Hyprland runs on the apple-drm card.

aurora9 (30a6518) carries no DART change, so it still regresses the J700 display.

Host reproduction, using the production function bodies compiled by tools/asahi/apple-dart-fw-tests.py:

  • --ref 937b727ef9 and --ref 30a651868a: core-second-dart and map-firmware FAIL (iommu_create_device_fw_mappings() = -16);
  • --ref e2fecd940c: all cases PASS.

@maralcbr maralcbr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @DjDeveloperr, good find, and your J700 result on a fresh install (internal display lost on 6/6 boots with aurora8, back with this PR) makes this urgent. The admission rule is right. A firmware-held slot only accepts a page its firmware leaf already maps to the same physical address with the same protection (apple-dart.c:675-687, :1629-1634). Four-level streams still refuse, and apple_dart_publish_root() never writes the firmware slot. Routing the handoff stream invalidate through apple_dart_fw_invalidate() (:1262-1265) is right too.

I checked the blast radius. Handoff only turns on for a locked apple,t8140-dart (:609-612), the mirror path only for T8140/T8142 (:3135-3137), and apple_dart_check_fw_map() skips every other DART up front (:1582). So M1, M2 and M3 DARTs see no change. The mirror refactor's leaf index is the same as before.

Locally at e2fecd94, tools/asahi/apple-dart-fw-tests.py passes 68/68. Against the base apple-dart.c, core-second-dart, map-firmware and map-attached fail, so the reproduction holds. CI is green.

One thing before merge:

  • A failed invalidate no longer stops domain_free() from freeing the page tables on handed-off DARTs. apple_dart_hw_unmap_locked_ttbr() now runs the range invalidate while retiring the root, but drops its result (:953), always returns 0, and clears locked_ttbr (:958). The invalidate_tlb() that domain_free() checks (:2184-2191) then reaches apple_dart_fw_invalidate() with no root, issues no command and returns 0 (:1229-1230), so the tables are freed (:2193) even after a TLB timeout. On the base, handed-off DARTs got a real FLUSH_SID there, and its error kept the tables. The mirror path already has this gap; this PR extends it to every handed-off DART. Please return the retire-time error and remember it per stream, so domain_free() still keeps the tables when apple_dart_release_device() (:2116) or the attach rollback (:1803) did the unmap first. A fixture case that forces the TLB command to time out would cover direct free, release-before-free and rollback-before-free. Today the fixture doesn't include apple_dart_hw_unmap_locked_ttbr() or apple_dart_domain_free().

Smaller things:

  • If firmware ever changes a page Linux now mirrors on disp0, apple_dart_publish_root() refuses the whole root (:738-750), and every later map on that stream fails and rolls back. Failing closed is right, but please confirm it doesn't happen in practice: a Neo session with DP-1 hotplug and an s2idle cycle, and no "failed to publish" lines.
  • nit: the comment at :1625 says "its snapshotted leaf", but only the root entry is snapshotted. fw->leaf maps the live firmware table (:850-853).
  • nit: commit 2's message says the stream invalidate is used "at attach, at release and on resume". apple_dart_resume() returns early for locked DARTs (:3516), and handoff requires locked, so resume never reaches it.
  • nit: the PR body says the fixture covers "another SoC with handoff". handoff-other-soc only shows handoff stays off outside T8140 (fixture.c:134-135). The fixture's iommu_map() also only calls apple_dart_check_fw_map() (fixture.c:106), so core-second-dart doesn't exercise publication.

For release: a cold boot on your Neo at the final head, plus the hotplug and s2idle check above.

continue;
apple_dart_retire_root(live, owned, dart->pgsize / sizeof(*live));
if (dart->fw_mirror && dart->version >= 0x0202 && !idx) {
if ((dart->fw_mirror || dart->fw_handoff) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With fw_handoff here, the result of the apple_dart_fw_invalidate() below is dropped and locked_ttbr is cleared, so the later invalidate_tlb() in domain_free() returns 0 without issuing a command and the page tables are freed even after a TLB timeout. Please return the error and remember it per stream (see the main comment).

apple_dart_t8110_hw_invalidate_tlb(struct apple_dart_stream_map *stream_map)
{
if (stream_map->dart->fw_mirror && stream_map->dart->version >= 0x0202)
/* Keep out of firmware-held slots; see apple_dart_fw_invalidate(). */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Right for the attach and release flushes. Note that after apple_dart_hw_unmap_locked_ttbr() this returns 0 without a command, which is what the :948 issue relies on.

Comment thread drivers/iommu/apple-dart.c Outdated
continue;
/*
* All pages of an inherited slot remain firmware's;
* only a page its snapshotted leaf already maps the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: only the root entry is snapshotted; fw->leaf maps the live firmware table (:850-853). Suggest "only a page its firmware leaf already maps the same way may be repeated".

…retire

On DARTs with a firmware root mirror or handoff, retiring a locked root
runs a range invalidate of the slots Linux published.
apple_dart_hw_unmap_locked_ttbr() dropped its result, returned 0 and
cleared the root. The invalidate that apple_dart_domain_free() checks
afterwards then found no root, issued no command and returned 0, so the
domain's page tables were freed even after a TLB timeout, while the
hardware could still cache translations through them. Before the
handoff DARTs took that path, a whole-stream flush there returned the
error and the page tables were kept.

Return the first retire-time invalidate error, and remember it per
stream on the DART. apple_dart_domain_free() keeps the page tables when
its own retire or invalidate fails, and also when a consumer release
or an attach rollback retired the root first and its invalidate failed.
The remembered error is never cleared, because only the hardware could
show that the TLB no longer holds those entries; later domains on that
stream keep their page tables too.

The host fixture now builds apple_dart_hw_unmap_locked_ttbr(),
apple_dart_release_device() and apple_dart_domain_free(), and forces
the TLB command to time out for a direct free, a release before the
free and a rollback before the free. Each keeps the page tables, and
the timeout cases fail on the old code. A comment in
apple_dart_check_fw_map() now says the firmware leaf is checked,
because only the root entry is snapshotted.

The previous commit's message also lists resume as a user of the stream
invalidate, but apple_dart_resume() returns early for locked DARTs, and
handoff requires a locked DART, so resume never reaches it.

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

Copy link
Copy Markdown
Collaborator Author

Thanks for the careful review. Fixed in 07d64c6:

  • Retire-time invalidate error: apple_dart_hw_unmap_locked_ttbr() now returns the first error of the range invalidate it runs while retiring a root, and the DART remembers it per stream (locked_retire_err). apple_dart_domain_free() keeps the page tables when its own retire or invalidate fails, and also when apple_dart_release_device() or the attach rollback retired the root first and its invalidate failed. The remembered error is never cleared, because only the hardware could show that the TLB no longer holds those entries, so later domains on that stream keep their page tables too. This also covers the mirror path.
  • Fixture: it now builds apple_dart_hw_unmap_locked_ttbr(), apple_dart_release_device() and apple_dart_domain_free(). The new retire-free, retire-release and retire-rollback cases force the TLB command to time out (-timeout variants). Each keeps the page tables; the timeout cases fail against e2fecd94's apple-dart.c. The rollback case calls apple_dart_hw_unmap_locked_ttbr() and drops its result, as the rollback does; the fixture doesn't build apple_dart_setup_translation_locked().
  • Nits: the comment now says "its firmware leaf". e2fecd9's message can't change without a force-push, so 07d64c6's message and the PR body note that resume never reaches the stream invalidate. The PR body no longer says the fixture covers another SoC with handoff, and it says core-second-dart covers admission, not publication.

Testing at 07d64c6:

The same change is aurora-silicon/linux#546. I'll post the Neo cold boot at this head, plus the DP-1 hotplug and s2idle check, when I have them.

@maralcbr maralcbr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@DjDeveloperr thanks, this is the fix I was after.

  • apple_dart_hw_unmap_locked_ttbr() now returns the first error from the firmware-root invalidate and records it per stream in locked_retire_err under dart->lock (apple-dart.c:968-973).
  • apple_dart_domain_free() keeps the page tables if any retire, its own invalidate_tlb(), or an earlier retire from release or attach rollback failed (:2217-2234, using apple_dart_retire_error()). That covers the case I flagged: locked_ttbr is cleared, so the later invalidate_tlb() returns 0 without issuing a command.
  • The new fixture cases cover a clean free and release, plus the three timeout regressions (free, release, rollback). The timeout cases fail on e2fecd9's apple-dart.c. The rollback case calls the helper directly rather than going through a real attach rollback, which is fine for what it checks.

Not blocking: locked_retire_err is never cleared, so one TLB timeout means every later domain on that stream keeps its page tables until reboot. If domains keep being recreated, the retained page tables and domain objects add up with no cap. Keeping them is still the safe trade over freeing tables the TLB may hold. A one-time dev_warn when a stream first gets marked would make it obvious in a bug report. Separately, and not new here: the ordinary unmap path still drops invalidate errors (:1550-1565). That's outside this PR.

Approving. Your Neo results show this is what brings the internal display back when m1n1 marks the T8140 display DARTs apple,firmware-root-handoff (aurora21 and later), so I'd like it in the next kernel pin.

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

Reviewed 07d64c6b829a: firmware-leaf matching and retire-time invalidation-error retention preserve firmware-owned mappings and retain backing on uncertainty. The firmware-DART and SEP DMA host checks passed. The combined M3/G15 regression run passed boot, native GL/Vulkan readbacks (zero wrong pixels), unchanged OMT status maps and the bounded A/B/A workload suite, followed by exact restoration. Full source pins, timings and limits.

Approval is for the reviewed source and this regression coverage; the Neo-specific inherited display-DART path was not exercised by our J516S run.

@maralcbr
maralcbr added this pull request to the merge queue Oct 29, 2026
Merged via the queue into integration/aurora with commit 11c0eb0 Oct 29, 2026
13 checks passed
@DjDeveloperr

Copy link
Copy Markdown
Collaborator Author

Thanks for merging. The one-time warning you suggested is in #272: the first time a stream records a retire-time invalidate error, it logs that the stream's page tables are kept until reboot. The ordinary unmap path's dropped invalidate errors are left as they are, as you said.

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