Repository navigation
iommu/apple-dart: fix J700 internal display with handed-off display DARTs - #404
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-1as an external monitor, which blocks lid suspend. disp0_dart fails to probe:The internal DCP (
412e00000.dcp) then waits on it forever (sync_state() pending due to 412e00000.dcp).Root cause
f5b77b77("boot: reserve Neo display table pages…"), merged from omacom/m1n1 and shipped with 553b566. Itsdt_t8140_reserve_tables()reserves the display DARTs' firmware table pages (dart-tables@…) and setsapple,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).display-subsystemhasiommus = <&disp0_dart 0>, <&dispext0_dart 0>(t8140-j700.dts). Aura gives it two reserved regions, both read from disp0's firmware tables:framebufferat IOVA 0x1ea0000 (0x5758000 bytes) andregion94at 0x1ddc000.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 andiommu_create_device_fw_mappings()callsiommu_map().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.fw_mirroraccepts 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) bound412e00000.dcpand apple-drm on this Neo on 10-22. That log has nodart-tables@reservations. On 10-23, with the new aura on the same package, thedart-tables@reservations appear and the -16 failure appears with them.apple-dart.citself did not change.Fix
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: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 underfw_mirror.iommu/apple-dart: keep stream invalidates out of handed-off slots. The stream invalidate (attach, release, resume) used
apple_dart_fw_invalidate()only forfw_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.core-second-dartruns the realiommu_create_device_fw_mappings()over a two-DART domain. It fails with -EBUSY on the old source and passes with the fix.map-*cases check that a hole, a wrong physical address, wrong protection, a changed root and a four-level stream are still refused.7.3.0-1-1.1-ARCH.412300000.iommuand412340000.iommuare bound to apple-dart.apple-drm display-subsystem: bound 412e00000.dcp, and alsobound 416e00000.dcp.[drm] Initialized apple 1.0.0 for display-subsystemandappledrmfb. simpledrm is gone./sys/class/drmlistscard1-eDP-1(connected, 2408x1506) andcard1-DP-1.apple-panel-blbacklight is present. MutterSetBacklightchanges it.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.