Skip to content

drm/apple, iommu: apple-dart: drive the M4 MacBook Air's internal panel on macOS 27.2 (v27 backend, on #2541's rebase) - #2818

Draft
RyanTheTide wants to merge 12 commits into
djdev/j773g-272-dcpext0from
j713-disp3/dcp272-internal
Draft

RyanTheTide wants to merge 12 commits into
djdev/j773g-272-dcpext0from
j713-disp3/dcp272-internal

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

#2590 (the M4 MacBook Air's internal panel on the macOS 27.2 stub) can no longer be merged. It was stacked on an older head of #2541, and #2541 has since been rebased onto integration (3 commits dropped as landed via #2688, the rest adapted to the landed helpers). #2590's history also still carries #2541's old commits through two merges.

Change

Same series as #2590, replayed onto #2541's current head (bc0067c). This replaces #2590.

What the series does is unchanged from #2590:

  • drm/apple: admit the J713 internal DCP with the 26B123 image and aura's firmware-27 clocks to the v27 backend.
  • iommu: apple-dart: on that handoff, keep the two internal display DARTs' locked roots (as for T6041), and map the re-exported firmware segments with the protection their live leaves have.
  • DT: the internal DCP's bandwidth slot, and the apple,panel node.
  • apple_dcp_usable() lets a T8132 internal DCP handed over this way join the DRM device on any board.

Testing

Still to run

Reviewer / agent detail

Assisted-by: LLM (Claude:Opus 5.5)

…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 <ryan@aurorasilicon.org>
…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 <ryan@aurorasilicon.org>
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 <ryan@aurorasilicon.org>
…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 <ryan@aurorasilicon.org>
…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 <ryan@aurorasilicon.org>
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 <ryan@aurorasilicon.org>
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 <ryan@aurorasilicon.org>
…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 <ryan@aurorasilicon.org>
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 <ryan@aurorasilicon.org>
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 <ryan@aurorasilicon.org>
…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 <ryan@aurorasilicon.org>
…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 <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Open item before this is ready, from Dj's review of #2596 (same pattern here):

The two internal display DARTs get fw_mirror through j713_display_v27, which apple_dart_serves_t8132_dcp_v27() decides from the DCP's 27.2 handoff (apple_t8132_dcp_v27_2(): firmware version 27.2.0, the 26B123 UUID and the firmware-27 clocks). A later 27.x image would then lose the mirror and the panel with it. The DART's own state should decide this, as it already does for T6041/T8140/T8142.

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 pmp@380500000).

Plan: key fw_mirror for apple,t8132-dart on locked && !fw_handoff && !borrowed. Borrowed would be decided by the positive 26.6.2 identification the M4 backend already uses, so anything not on that path, including later 27.x images, defaults to the mirror. That also covers #2596's J773g dcpext DARTs. It newly mirrors the PMP DART, so it lands only with a J713 row that shows the PMP firmware and its reports unchanged, next to the panel rows.

Converted to draft until then.

@RyanTheTide
RyanTheTide marked this pull request as draft November 22, 2026 15:04

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

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

  1. 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 before apple_dart_readl(dart, DART_TCR(dart, sid)) runs. On apple_dart_hw_t8110, tcr_4level is non-zero (DART_T8110_TCR_FOUR_LEVEL), and apple_dart_probe() drops its probe PM ref at line 6280 for non-borrowed/non-MTP DARTs (j713_display_v27), so dart->dev can runtime-suspend before DART_TCR is read. Read both ttbr and tcr before calling pm_runtime_put(dart->dev).

  2. §1 (No firmware-version gating in DART fw_mirror):
    apple_dart_serves_t8132_dcp_v27() (drivers/iommu/apple-dart.c:5485-5499) keys T8132 fw_mirror and dart->j713_v27 on apple_t8132_dcp_v27_2() (hardcoding 27.2.0 + the 26B123 UUID), rather than deciding fw_mirror from the DART's own hardware state (locked && !fw_handoff && !borrowed) as T6041/T6050/T8140/T8142 already do. Any subsequent 27.x firmware build would lose fw_mirror and fail to attach the internal panel. Agreed with your Draft comment's plan to key T8132 fw_mirror on locked && !fw_handoff && !borrowed (and verify the PMP DART 380300000 is 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.

  3. Stack, CI & §5 evidence:

    • Currently Draft, stacked on unmerged Draft #2541 (djdev/j773g-272-dcpext0), with 0 CI runs executed on a912b89b. Needs #2541 landed, retargeted onto integration/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 DART 380300000 / PMP reports unchanged under fw_mirror, and (c) J713 26.6.2 borrowed-path regression check.

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 via apple_dart_fw_table_ram(), leaf tables via apple_dart_fw_table_decode(), overflow-safe window bounds via locked_window[sid], exact PA matches, and uniform page protections (never widening beyond the live leaves, failing closed on mismatch). iomfb_m4.c gating bw_mailbox on if (external) preserves 26.6.2 behavior; t8132-dcp.dtsi pmgr_dcp slot (0x382820000) and t8132-j713.dts panel geometry (290x189/181 mm, 500 nits) check out. Non-T8132 SoCs and J773g's idle main DCP are unaffected. #2819 stacks cleanly on top.
  • §4 (Clean-room & attribution): Clean. All 12 commits carry human identity (Ryan Murray) and human Signed-off-by: with zero AI trailers (old #2541 Co-Authored-By history from #2590 is cleanly gone); PR body includes Assisted-by:.
  • §6 (Naming): Clean.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at a912b89.

  1. drivers/iommu/apple-dart.c:4603-4606: pm_runtime_put(dart->dev) runs before the DART_TCR read in the same condition, so the TCR is read after the reference is dropped. Read TTBR and TCR together, then put.
  2. Selection is keyed on the processor's compatible, the firmware UUID and version/compat 27.2.0 from the handoff (include/linux/soc/apple/display.h:60-65), and the DARTs follow their DCP rather than their address. That is the right shape. But apple,clock-ids is used as a "was handed over" signal, and it is not one: it describes clocks. The commit messages say the default Stage 2 does not write it, so on the default boot chain this series does nothing and J713 stays on simpledrm. Please name the boot-loader change it needs and whether it is the default. If a handoff marker is the intent, check an explicit one instead of whether clock metadata is present.
  3. apple-dart.c:430, 4568, 6058-6060: the bit is j713_v27 and the log lines say "J713", but since cd2c258 no board is involved. Name it after the handoff (e.g. t8132_dcp_v27) so an M4 MacBook Pro doesn't log as a J713.
  4. apple-dart.c:6051-6064: fw_mirror also needs !fw_handoff. A DART that is locked and has a reserved-table handoff is refused with "NOT locked", which is wrong in both outcome and message. Refuse on !dart->locked and handle (or reject with its own message) the fw_handoff case.
  5. drivers/gpu/drm/apple/dcp.c:7218-7250: the new hw-data comment is placed between the J773g dcpext comment and apple_dcp_hw_t8132_dcpext_v27, so the dcpext struct has lost its comment. Put the new comment and struct after the dcpext struct.
  6. dcp.c:6036-6049: the internal DCP uses the same "ASSUMED, NOT TRACED" IOMFB numbering as the J773g dcpext. The J713 rows are then the only evidence for it. Please post them at this head: boot to appledrm on eDP-1 with the panel, backlight, a modeset and 60 Hz pacing, no DART faults, and the firmware segment ... protection lines.
  7. Rows owed at this head: J713 on 27.2 (above, plus s2idle with the panel bound). J773g on 27.2 as a no-regression row: the main DCP must still be left alone and dcpext0 must be unchanged by the apple_dcp_usable() and DART changes. J713 on 26.6.2: the M4 backend still binds and bw_mailbox is unchanged.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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:

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