Skip to content

iommu/apple-dart: fix J700 internal display with handed-off display DARTs - #404

Merged
DjDeveloperr merged 2 commits into
integration/aurorafrom
fix/t8140-display-dart-handoff
Oct 23, 2026
Merged

DjDeveloperr merged 2 commits into
integration/aurorafrom
fix/t8140-display-dart-handoff

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Problem

On the MacBook Neo (J700, T8140), the internal display stays on simpledrm with the Alpha 8 kernel (8c2774e). This means no backlight control, and GNOME treats Unknown-1 as an external monitor, which blocks lid suspend. 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

The internal DCP (412e00000.dcp) then waits on it forever (sync_state() pending due to 412e00000.dcp).

Root cause

  • What changed. Aura now runs f5b77b77 ("boot: reserve Neo display table pages…"), merged from omacom/m1n1 and shipped with 553b566. Its dt_t8140_reserve_tables() reserves the display DARTs' firmware table pages (dart-tables@…) and sets apple,firmware-root-handoff = <1> on 412300000, 412340000, 416300000 and 416340000. The kernel DTS never sets this property. It turns on the reserved-table handoff path (fw_handoff) from e47d06c in place of the retained-root mirror path (fw_mirror).
  • The two-DART domain. display-subsystem has iommus = <&disp0_dart 0>, <&dispext0_dart 0> (t8140-j700.dts). Aura gives it two reserved regions, both read from disp0's firmware tables: framebuffer at IOVA 0x1ea0000 (0x5758000 bytes) and region94 at 0x1ddc000.
  • Why the lookup misses. apple_dart_inherited_phys() reports a page as mapped only when every DART in the domain inherited the same translation. dispext0 does not hold the boot framebuffer, so the lookup returns 0 and iommu_create_device_fw_mappings() calls iommu_map().
  • Why the map fails. With fw_handoff, apple_dart_check_fw_map() refuses any page in a firmware-held root slot, even one that repeats the firmware PTE exactly. The map returns -EBUSY before attach, then again after attach. iommu_setup_default_domain() fails, and the DART probe rolls back with -16.
  • Why the old path worked. fw_mirror accepts a page whose firmware leaf already maps the same physical address with the same protection. With that path, the same 7.2.10 package (7.2.10-1-2-ARCH) bound 412e00000.dcp and apple-drm on this Neo on 10-22. That log has no dart-tables@ reservations. On 10-23, with the new aura on the same package, the dart-tables@ reservations appear and the -16 failure appears with them. apple-dart.c itself did not change.

Fix

  1. iommu/apple-dart: accept mirrored pages in handed-off firmware slots. The handoff branch of apple_dart_check_fw_map() now applies the same per-page rule as the mirror path. A page in a firmware-held slot is accepted only when:

    • the slot is still the one that was snapshotted;
    • the stream is three-level;
    • the firmware leaf maps that page to the same physical address with the same R/W/cache bits.

    Everything else stays refused. apple_dart_publish_root() already checks the whole Linux leaf against the firmware leaf in handoff mode, so the firmware slot is never written. dispext0 gets the copy in a vacant slot, as it did under fw_mirror.

  2. iommu/apple-dart: keep stream invalidates out of handed-off slots. The stream invalidate (attach, release, resume) used apple_dart_fw_invalidate() only for fw_mirror. A handed-off DART got a whole-stream FLUSH_SID on the live scanout stream. Range flushes already treat both modes the same, so this aligns the stream invalidate with them. That is also aurora-wip's T8140 behaviour, which was proven on this machine.

Testing

  • tools/asahi/apple-dart-fw-tests.py: 68/68 cases pass, including the new ones.
  • New case core-second-dart runs the real iommu_create_device_fw_mappings() over a two-DART domain. It fails with -EBUSY on the old source and passes with the fix.
  • New map-* cases check that a hole, a wrong physical address, wrong protection, a changed root and a four-level stream are still refused.
  • J700 hardware: Alpha 8 kernel (8c2774e) with these two commits, same config, aura 553b566. It was booted as a separate GRUB entry, 7.3.0-1-1.1-ARCH.
    • Both 412300000.iommu and 412340000.iommu are bound to apple-dart.
    • apple-drm display-subsystem: bound 412e00000.dcp, and also bound 416e00000.dcp.
    • [drm] Initialized apple 1.0.0 for display-subsystem and appledrmfb. simpledrm is gone.
    • /sys/class/drm lists card1-eDP-1 (connected, 2408x1506) and card1-DP-1.
    • The apple-panel-bl backlight is present. Mutter SetBacklight changes it.
    • GNOME sees eDP-1 as the built-in panel, and there is no handle-lid-switch inhibitor.
    • virq 55 carries both display DART handlers, with 0 faults.

IRQ 55 (intermittent hang after "irq 55: nobody cared")

On this kernel and DT, virq 55 is AIC hwirq 0x2ba. That line is shared by disp0_dart (412300000), dcp_dart (412340000) and the disabled 412320000. When disp0_dart's probe fails, its handler is freed. Any later disp0 DART exception then has no handler on the shared line, which produces "nobody cared". The probe failure also leaves disp0's attach-time whole-stream flush of the live scanout stream behind (fixed by the second commit). With both fixes, disp0_dart stays bound and its faults are handled.

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

1 participant