Repository navigation
drm/apple, iommu: apple-dart: drive the M4 MacBook Air's internal panel on macOS 27.2 (v27 backend, on #2541's rebase) - #2818
Conversation
…h slot
The firmware-27 DCP backend asks for apple,bw-scratch before it binds
("Incompatible devicetree!" without it). The T8132 internal DCP's slot is
in the PMC window it already has as disp-4: bandwidth agent 0, the one the
ADT's /arm-io/disp0 bw_req interrupt (BIRQ 0x35) names in the PMGR
bwr-agent table, 0x20000 into the window; agents are 0x4000 apart, which
puts the dcpexts' agents 3 and 4 at the pmgr_dcpext slots this tree
already has. Describe it the way the dcpexts' slots are described, inside
display window 4.
The M4 26.6.2 backend reads the same property and has run the internal
panel without a mailbox; keep it that way by taking the mailbox for an
external processor only, so nothing changes on 26.6.2.
Signed-off-by: Ryan Murray <[email protected]>
…27.2 table
On the macOS 27.2 stub the M4 MacBook Air's (J713) internal display
processor runs the 26B123 image the J773g's processors run (UUID
B3BA603C), and the M4 backend refuses it ("unqualified firmware 26.6.2
handoff"), so the panel stays on simpledrm.
Admit an internal T8132 DCP that the boot loader handed over with that
image (firmware version and compatibility 27.2.0) and with the
firmware-27 clock metadata (apple,clock-ids, from /arm-io/disp0) to the
firmware-27 backend with the 27.2 method table, before the M4 hw data is
looked at. Requiring the clocks keeps out a main DCP that a boot loader
leaves running idle without a handoff, as on the Mac mini.
It gets apple_dcp_hw_t8132_v27: 41-bit firmware DMA (apple,dma-range
<0x100 0 0x10 0> ends at 1 TiB + 64 GiB), no DPTX port service, and
adoption of the live session iBoot leaves running. No sleep support.
That the T8132 26B123 image numbers its IOMFB methods as the T6041 and
T8142 26B123 images do is the assumption the J773g dcpext admission
makes too.
Signed-off-by: Ryan Murray <[email protected]>
Build the real apple_t8132_dcp_v27_2() into the t6041-v27-admission unit (of_property_present() mocked for apple,clock-ids) and check that the internal processor handed over with the T8132 26B123 image and its firmware-27 clocks runs the 27.2 table on either firmware path, and that without the clocks, with the T6041 image, a missing UUID or another release it is the M4 backend's on its path and nobody's off it. Signed-off-by: Ryan Murray <[email protected]>
…ots like T6041's On the macOS 27.2 stub the M4 MacBook Air's internal display processor runs the 26B123 image and the firmware-27 backend. That backend DMAs through ordinary IOMMU domains: RTKit and IOMFB shared memory on SID23, PIODMA maps on SID16, scan-out on SID0. The borrowed J713 display path cannot serve it. It admits only the 26.6.2 layout, so the DCP is left without any IOMMU domain, and it reserves the whole SID23 window from generic DMA for the M4 backend's own allocators. When the internal DCP was handed over with the 27.2 image and its firmware-27 clocks (apple_t8132_dcp_v27_2()), do not borrow its two display DARTs. Give them the locked-root handling T6041's display DARTs get on firmware 27 (fw_mirror): the firmware's live slots are kept and Linux's mappings go into the rest. Refuse the DART if it is not locked as expected. Nothing changes for a DCP on its 26.6.2 handoff, or for a 27.2 one without the firmware-27 clocks (the default Stage 2 hands it over without them). Signed-off-by: Ryan Murray <[email protected]>
…s its leaves do On the J713's 27.2 handoff the internal display DARTs keep their firmware's locked roots (fw_mirror). A Linux table in a slot the firmware holds must then mirror the firmware's leaves exactly, protection included (apple_dart_fw_slot_mirrors()). The boot loader re-exports the firmware's own segments as iommu-addresses, and the core maps those read-write, and uncached for this non-coherent DCP. The live leaves differ: the firmware's text is read-only, and all of its segments are cacheable (SID23 dump on the 27.2 stub: __TEXT flags 0x5, __DATA and the four other segments 0x1). As it stood, the DCP's attach would refuse every segment and leave the processor without a domain. For such a DART, give each translated region the protection the live leaves give every one of its pages. A region whose pages are not mapped there, map elsewhere or disagree keeps its protection, and the attach then refuses it as before. Signed-off-by: Ryan Murray <[email protected]>
The firmware-27 DCP backend takes the internal connector type (eDP) and the backlight range from the DCP's apple,panel child. The M4 26.6.2 backend never needed one, so the J713 has none, and on the 27.2 stub its panel comes up as an 'Unknown' connector without a backlight device. Describe the panel as on the other Airs: 2560x1664 at 224 ppi, 64 notch rows above the desktop, and the published 500 nits maximum. Signed-off-by: Ryan Murray <[email protected]>
Split the region walk from its device lookup and test it on a fake locked root: read-only text pages and read-write data pages take the protection of the leaves that map them (cacheable), a region whose leaf maps another page keeps what it asked for, and nothing changes on a DART that is not a 27.2 J713 display DART. Signed-off-by: Ryan Murray <[email protected]>
…its tables, in its window The live-leaf protection for a 27.2 J713 internal display DART's firmware segments memremaps the stream's root straight from TTBR, and each leaf table straight from its root entry, write-back. The rest of the driver maps a firmware table only after apple_dart_fw_table_decode() has checked it: a table entry with no stray bits, naming reserved RAM. An entry that named a device's registers would get a Normal write-back mapping here. The leaf slot also comes from DVA bits 14..35 alone, so a region outside the stream's 64 GiB window aliases into it. The physical address match made that harmless, but the region should not be looked up at all. Map the root only when it is a firmware table in reserved RAM, decode each leaf table entry with apple_dart_fw_table_decode(), and skip a region that does not lie inside the stream's window (locked_window, the DART's apple,dma-range until a domain attaches: 64 GiB at 1 TiB on the display DARTs). A skipped region keeps the protection it asked for, and the attach refuses it as before. KUnit: the tables are now reserved pages; new cases for a region whose two pages have different protections, a region 64 GiB above the window, and a leaf table outside reserved RAM. All three stay unchanged. Signed-off-by: Ryan Murray <[email protected]>
A 27.2 J713 internal display DART that the boot loader did not leave locked is refused (-EINVAL), but the line saying so was logged with dev_info() as one of two cases of the same message. Log the refusal with dev_err() on its own. Signed-off-by: Ryan Murray <[email protected]>
The T8132 internal DCP's 27.2 case in dcp_check_firmware_version() sat
between the J773g dcpext comment ("ASSUMED, NOT TRACED") and the code
that comment describes. Move it below that code; the two predicates match
different compatibles, so the order changes nothing.
Signed-off-by: Ryan Murray <[email protected]>
…s handoff A T8132 DART took the firmware-27 path for the internal display when it sat at one of the two J713 internal display DART addresses on the M4 firmware path and any available internal DCP anywhere was handed over with the 27.2 image (apple_t8132_internal_dcp_v27_2(), a global scan). The address list and the scan say nothing about whether this DART belongs to that processor. Ask the DART's own user instead: a T8132 DART is a 27.2 internal display DART when an available apple,t8132-dcp that the boot loader handed over with the 27.2 image (apple_t8132_dcp_v27_2(): image, firmware version and its firmware-27 clocks) names it, in its own iommus (the firmware DART) or in a child's (the PIODMA's display DART). Such a DART also skips the "leave it untouched off the qualified firmware" refusal, which is keyed on the same addresses: its processor was handed over. On the J713 the same two DARTs qualify as before. Another M4 whose internal DCP is handed over with the 27.2 image and its clocks now gets its DARTs on the same path instead of the backend running on DARTs left on the borrowed path. The 26.6.2 path and its address keys are unchanged. apple_t8132_internal_dcp_v27_2() has no users left. Link: #2621 Signed-off-by: Ryan Murray <[email protected]>
…oard dcp_check_firmware_version() runs a T8132 internal DCP that the boot loader handed over with the 27.2 image and its firmware-27 clocks on the firmware-27 backend wherever it is (apple_t8132_dcp_v27_2(): processor, image and handoff). apple_dcp_usable() still kept every apple,t8132-dcp out of the component match unless apple_t8132_firmware_path() held, which off 26.6.2 is true only for the J713/J715 board names. An M4 MacBook Pro handed over the same way would have probed and never bound. Admit it on the same handoff predicate. Nothing changes on the Airs (already on the path), on 26.6.2, or for a DCP without the 27.2 image or its clocks (a Mac mini's parked main DCP stays out). The t6041-v27-admission host unit now runs apple_dcp_usable() for the T8132 internal DCP and dcpext on both paths and asserts it names no machine; the readiness unit stubs the new helper as unreachable. Signed-off-by: Ryan Murray <[email protected]>
A DCP whose device tree names its display power words but not its DART streams stops the streams its DARTs have enabled before its first power-down and enables them again at power-up. Let it read them: the first 32 streams of a T8110 DART, read while its domain is up. Signed-off-by: Ryan Murray <[email protected]>
…ry hw.s2r SoC The system-sleep stop ran with an active panel only where the power words are measured, or on the J813, so another SoC's internal DCP stayed running into a deep sleep unless DPMS had turned its panel off first, and the sleep was refused. A derived layout only survives probe with appledrm.s2r_untested set, which already decides it: drop the board check. Signed-off-by: Ryan Murray <[email protected]>
… power words from the device tree The M4 MacBook Air's internal DCP runs the firmware-27 backend on macOS 27.2 but has no firmware stop, so a deep sleep is refused with the processor still running, and DPMS off only darkens the backlight. Give it the hw.s2r stop the T8142 runs on 27.2: set_power_state(0), D572, the AP link's release (A550 in the 27.2 table), RTKit idle and the CPU stop, then the DCP DART's streams. It has no secure mailbox. Its power words are not a per-SoC table: a hw.s2r DCP without a layout in its hw data takes them from its device tree, the ones its deep sleep lowers. DISP_CPU is the first state of its power-domains, DISP_FE that state's parent and DISP_SYS theirs; the retention words are DISP_CPU's apple,retention-workaround, of which only the masked bits are written, the off value at power-off and the value read at probe at power-on; pmc-dcp counts it where the display-power node has that word; and the DART streams are the ones its DARTs have enabled before the first stop. Without those properties the firmware keeps running, as before. Signed-off-by: Ryan Murray <[email protected]>
The T8132's words are T8140's: pmc-dcp, the power manager's power states and its power gate block. Signed-off-by: Ryan Murray <[email protected]>
Name the power manager blocks the internal DCP's firmware-27 stop writes, the ones the deep sleep lowers (pmc-dcp, the power states and the power gate block), and the DCP DART's clock-protection slice (42 in the ADT's dart-dcp) as its gapf word: the stop clears it after the DART's power-down flush so that DISP_CPU's power state can be written. Signed-off-by: Ryan Murray <[email protected]>
… probe, and only all of them Review points on the device-tree power layout: - Its DART streams were read at the first stop, with dcp_streams == 0 standing for "not read yet". A first read of 0 would have had later stops and power-ons read the DART again, maybe with DISP_CPU still lowered, and the restart would enable no streams. Now the streams are read once at probe, with the firmware running. A DCP DART that reads none refuses the layout, and the firmware keeps running as with no power words. - apple_dart_enabled_streams() read only the first enable word. If a stream above 31 is enabled, the 32-bit mask can't describe the DART, so it now reads every word up to num_streams, warns once, and reports 0 in that case. - Comments still described the stop as behind appledrm.s2r_untested or J813-only. The device tree's words stop the firmware by default; only a SoC whose static words are merely derived (T8142) needs the parameter. The same holds for the layout added in "drm/apple: dcp: stop a DCP for a deep sleep with its panel lit on every hw.s2r SoC", whose message says otherwise. Signed-off-by: Ryan Murray <[email protected]>
…and check power word alignment A DCP with a piodma child restores the display DART's streams at power-on from the layout. If that DART is not found, or reads no streams (none enabled, or streams above 31 that the 32-bit mask cannot describe), the layout kept disp_streams = 0 and power-on would have enabled none. Refuse the layout then, like a DCP DART that reads none: the firmware keeps running. The DISP_CPU/FE/SYS offsets are checked against the "ps" block without underflowing on a block shorter than a word, and must be word aligned like the retention offsets. The overview comment named the old first-stop stream read; point it at dcp_s2r_layout_streams(). Signed-off-by: Ryan Murray <[email protected]>
|
Open item before this is ready, from Dj's review of #2596 (same pattern here): The two internal display DARTs get What the J713 reports (PROTECT bit 0, 27.2 stub, from our boot logs): seven T8132 DARTs are locked. Six are display DARTs: dcpext0/dispext0 286340000/286300000, dcpext1/dispext1 48a340000/48a300000, and the internal 30a340000/30a300000. The seventh is the PMP DART 380300000 (protect 0x1e7, serving Plan: key Converted to draft until then. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial pre-PR checklist review (§1–§6) at verified live head a912b89b3c469d92a3dd00c9a812533fd053fa42: requesting changes for a real runtime-PM bug in __apple_dart_j713_v27_fw_prot(), the §1 firmware-build gating of T8132 fw_mirror (which you also noted when converting to Draft), and missing CI / rebased-head hardware evidence.
Blockers
-
Code bug — MMIO read after
pm_runtime_put()(drivers/iommu/apple-dart.c:4600-4607):if (pm_runtime_resume_and_get(dart->dev) < 0) return; ttbr = apple_dart_readl(dart, DART_TTBR(dart, sid, 0)); pm_runtime_put(dart->dev); if (!(ttbr & dart->hw->ttbr_valid) || (dart->hw->tcr_4level && (apple_dart_readl(dart, DART_TCR(dart, sid)) & dart->hw->tcr_4level))) return;
pm_runtime_put(dart->dev)releases the runtime-PM reference beforeapple_dart_readl(dart, DART_TCR(dart, sid))runs. Onapple_dart_hw_t8110,tcr_4levelis non-zero (DART_T8110_TCR_FOUR_LEVEL), andapple_dart_probe()drops its probe PM ref at line 6280 for non-borrowed/non-MTP DARTs (j713_display_v27), sodart->devcan runtime-suspend beforeDART_TCRis read. Read bothttbrandtcrbefore callingpm_runtime_put(dart->dev). -
§1 (No firmware-version gating in DART
fw_mirror):
apple_dart_serves_t8132_dcp_v27()(drivers/iommu/apple-dart.c:5485-5499) keys T8132fw_mirroranddart->j713_v27onapple_t8132_dcp_v27_2()(hardcoding27.2.0+ the26B123UUID), rather than decidingfw_mirrorfrom the DART's own hardware state (locked && !fw_handoff && !borrowed) as T6041/T6050/T8140/T8142 already do. Any subsequent 27.x firmware build would losefw_mirrorand fail to attach the internal panel. Agreed with your Draft comment's plan to key T8132fw_mirroronlocked && !fw_handoff && !borrowed(and verify the PMP DART380300000is unaffected on hardware). Similarly, generalize the live-leaf firmware-segment protection hook from a J713/27.2-specific flag (dart->j713_v27) so it does not require per-build/per-board opt-in. -
Stack, CI & §5 evidence:
- Currently Draft, stacked on unmerged Draft
#2541(djdev/j773g-272-dcpext0), with 0 CI runs executed ona912b89b. Needs#2541landed, retargeted ontointegration/aurora, and green CI (dt-checks,host-tests). - Once reworked, post a fresh J713 hardware row on clean
integration/aurora+ this PR proving: (a) internal panel (eDP-1, backlight, DPMS, s2idle, 0 DART faults, 0 failed units, 0 AVC, 0 new kernel errors), (b) PMP DART380300000/ PMP reports unchanged underfw_mirror, and (c) J713 26.6.2 borrowed-path regression check.
- Currently Draft, stacked on unmerged Draft
What Checks Out (§2, §3, §4, §6)
- §2 (No hacks): Runs on the default kernel command line with no new parameters.
- §3 (Memory safety & other SoCs): Aside from the
pm_runtime_put()ordering bug above,__apple_dart_j713_v27_fw_prot()validates roots viaapple_dart_fw_table_ram(), leaf tables viaapple_dart_fw_table_decode(), overflow-safe window bounds vialocked_window[sid], exact PA matches, and uniform page protections (never widening beyond the live leaves, failing closed on mismatch).iomfb_m4.cgatingbw_mailboxonif (external)preserves 26.6.2 behavior;t8132-dcp.dtsipmgr_dcpslot (0x382820000) andt8132-j713.dtspanelgeometry (290x189/181 mm,500nits) check out. Non-T8132 SoCs and J773g's idle main DCP are unaffected.#2819stacks cleanly on top. - §4 (Clean-room & attribution): Clean. All 12 commits carry human identity (
Ryan Murray) and humanSigned-off-by:with zero AI trailers (old#2541Co-Authored-Byhistory from#2590is cleanly gone); PR body includesAssisted-by:. - §6 (Naming): Clean.
Assisted-by: LLM (Gemini 4 Neon)
|
Review at a912b89.
|
|
J713 row (M4 MacBook Air, macOS 27.2 stub), one-shot boot of integration/aurora f1d5b24 merged with this stack (#2819 head 888805b on #2818 a912b89). Default kernel command line, unchanged Stage 2:
|
… PM reference __apple_dart_j713_v27_fw_prot() took a runtime-PM reference, read the stream's TTBR, dropped the reference and only then read DART_TCR for the four-level check. apple_dart_probe() drops its own probe reference for these DARTs, so the TCR read could hit a suspended DART. Read TTBR and TCR while the reference is held, then put it. The KUnit case now also checks that a stream whose TCR says four-level is left as it asked. Signed-off-by: Ryan Murray <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Signed-off-by: Ryan Murray <[email protected]>
|
Row: |
|
CI note at |
RyanTheTide
left a comment
There was a problem hiding this comment.
Adversarial non-author review at 8e87aefe: no blocking findings. MERGE after #2541, once CI is green at this head (MERGETRAIN6)
Dj's three blockers from a912b89b, checked against the code at this head (the effective diff onto main a851ca0 is 27 files, +2393/-62):
- PM order.
__apple_dart_j713_v27_fw_prot()is gone. The one newpm_runtime_resume_and_get()/pm_runtime_put()pair in apple-dart.c reads TTBR and (whentcr_4level) TCR while the DART is held, and only decides after the put. Fixed. - Firmware gating of
fw_mirror.apple_dart_selects_fw_mirror()returns false unlesslocked && !fw_handoff && !preserve_display, then takesapple_dart_keeps_locked_roots()(the same four compatibles main lists: t6041/t6050/t8140/t8142) orapple_dart_serves_t8132_dcp(). No version, UUID or board is involved in the DART decision.preserve_displayis only set from the existing T8132 26.6.2 borrowed-path flags, so T6041/T6050/T8140/T8142 get exactly main's result. - CI and row. The J713 exact-stack row is posted (7a8022a carries this head: 6/6 display DARTs keep their locked roots, three DCPs bound, s2idle, 0 new kernel errors). The KUnit jobs at this head are still queued. Your host-tests timeout note (cases at ~150 s on the runner, under 3 s locally) needs a green rerun before merge.
Gates (checked because of the no-gates rule): the DCP side still selects the firmware-27 backend by the handed-over image (apple_dcp_image_v27_2 with the T8132 26B123 UUID plus apple,clock-ids). That is the convention main already uses for T6041 (APPLE_T6041_DCP_26B123_UUID). The IOMFB interface belongs to the firmware image the boot loader hands over, and an unknown image fails closed (display left off, logged), never into the wrong ABI. The installer pins the stub to 26B123, so a newer image is a qualified change that adds its UUID. I don't count this as a new gate. The j713_display MMIO-address test predates this PR.
Non-blocking:
- The dcp.c comment marks the T8132 26B123 IOMFB method numbering as "ASSUMED, NOT TRACED". The J713 rows exercise it, but keep the comment until a trace confirms it.
- The monitor row at this head (EDID, DPMS, s2idle, cable pull) is booked; it belongs with #2673.
Signed-off-by: Ryan Murray <[email protected]>
|
Merged main 8c6992d (incl. #2541) into the branch: head |
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict carries to 13e3abcb: the new commit is only a merge of main (after #2541 landed). The tree this PR adds on top of current main is byte-identical to the one I reviewed at 8e87aefe. MERGE once CI is green at this head.
…silicon#2818 review fix) into j713-dcpext/air-dcpext-272 apple-dart.c takes the new stack's state-keyed fw_mirror selection (apple_dart_selects_fw_mirror(): locked, no fw_handoff, not borrowed) and its fw_mirror leaf-protection hook in place of this branch's j713_display_v27/t8132_dcpext_v27 flags and fw_live_prot. The Air's external display DARTs keep this branch's behaviour through the same helper: apple_dart_serves_t8132_dcp() now takes the processor compatible, and a DART named (iommus, or its PIODMA child's) by an available apple,t8132-dcpext that the boot loader handed over with its firmware clocks (apple,clock-ids) is a fw_mirror candidate, decided before the borrowed 26.6.2 j713_dcpext/j713_dispext classification, which it clears. Such a DART that is not locked, or is locked with a reserved-table handoff, is refused, as the internal one is. No image, board or chip check is added: the candidate is keyed on the processor's handoff, as the internal DCP's DARTs are. Signed-off-by: Ryan Murray <[email protected]>
…ora-silicon#2819) into airs-promote/dcpext-deep-refusal aurora-silicon#2673 now sits on aurora-silicon#2819 + the aurora-silicon#2818 review fix. The only conflict was the T8132 hw data in dcp.c: the internal table keeps aurora-silicon#2819's sleep stop, and the firmware-27 T8132 dcpext table gets this branch's external_processor flag. Signed-off-by: Ryan Murray <[email protected]>
What
Runs the M4 MacBook Air's (J713) internal panel when the boot loader hands over the internal DCP with the macOS 27.2 image. This replaces #2590.
apple,panelnode.fw_mirroris decided by the DART's own state: locked, no reserved-table handoff, not borrowed. It no longer depends on the 27.2 firmware version or image UUID (0469085, ef48113). On T8132 it takes only the DARTs that an availableapple,t8132-dcpcarryingapple,clock-idsnames. So the PMP DART (380300000) and the external DCP DARTs keep their current paths. No kernel or module parameter is needed, and nothing is gated on a board.Tested: J713 pass at ef48113 (merged onto main 70e700c with #2541, #2819 and #2434; default cmdline, unchanged Stage 2): eDP-1 2560x1664 enabled, backlight 400/500, both internal display DARTs "locked roots kept (mirror)", s2idle 1/1, gpubench VK+GL pass, Enforcing, 0 AVC. Host tests: dart 16/16, dcp 65/65, display-gate 1/1. Arm64 W=1 build of the touched files is clean.
Risk: two-way (revert restores the previous selection). Macs: J713. The shared
apple_dart_selects_fw_mirror()also runs on T6041/T6050/T8140/T8142, which keep the same result (all their DARTs qualify). The widened leaf-protection hook only changes a region whose live leaves already disagree with the request, and attach already refused that case.Not yet
apple_t8132_dcp_v27_2()indcp.c/apple_drv.c/display-gate.c).Details
git range-diff: 10=, 2 context-only), followed by 4 review fixes (TTBR/TCR read before the PM put, handoff-based names, a separate refusal message, dcp.c comment order). Then 0469085 (fw_mirrorfrom state) and ef48113 (leaf protection for anyfw_mirrorDART, which removes the per-board flag).traces/kernel/20261125-airs-fleet89/j713/7.3.0-aurora-airs89a/in the lab store, with the earlier rows intraces/display/20261123-j713-disp3/.