Skip to content

j615: external DisplayPort over USB-C (dcpext), with fbdma framebuffer mirror - #356

Open
ericjuta wants to merge 11 commits into
omacom:integration/aurorafrom
ericjuta:j615/dcpext
Open

ericjuta wants to merge 11 commits into
omacom:integration/aurorafrom
ericjuta:j615/dcpext

Conversation

@ericjuta

@ericjuta ericjuta commented Nov 4, 2026

Copy link
Copy Markdown

External DisplayPort over USB-C on the J615 (MacBook Air 15", M3), on both ports. It's the J613 dcpext path from #103/#114 plus two fixes the J615 needs. Reports and logs are in #103.

Commits

  1. soc: apple: t8122 display gate: dcpext_disp_dart switch. apple_t8122_display.dcpext_disp_dart=0 enables the dcpext without appending dispext0_dart to the display subsystem's iommus. On the J615 that shared domain faults the internal DCP's DART (28d304000, NO PMD/PTE at 0x1000a000000..) about 2 s into boot, and the internal DCP crashes (the dark panel of kboot: reserve the T8122 dcpext firmware only with chosen.asahi,t8122-dcpext=1 m1n1#14). The default is unchanged, so J613 behaves as before.
  2. drm: apple: dcp: mirror framebuffers into the T8122 dcpext fbdma domain. Without that DART in the shared domain, the dcpext faults at the framebuffer DVAs. An optional fbdma child (dispext0_dart stream 0, with the display subsystem's DVA window) gets its own domain, and each swapped framebuffer is mapped into it read-only at its display DVA. Imported (GPU) buffers use obj->sgt. Without the node nothing changes.
  3. arm64: dts: apple: t8122-j615: external display over USB-C (dcpext). The J613 routes block, with the same Type-C wiring (usb-pd@c Left-back/ATC0, usb-pd@a Left-front/ATC1), plus fbdma. Everything stays disabled until the m1n1 marker is set (chosen.asahi,t8122-dcpext=1).

Tested (J615, 14.7, Samsung C49G95T 5120x1440@120, direct USB-C to DP)

Both ports, unplug/replug ×2, s2idle with the display attached, lid closed, pipeline takeover between ports. 0 DART faults, internal panel and GPU fine. Not tested: docks/HDMI/MST, DP audio, long sleeps.

For review

  • The switch is a kernel argument. It could instead be a J615 board default, or the gate could skip the DART on T8122 whenever an fbdma node exists. Your call; I don't know why the shared domain faults on J615 but not on J613.
  • Depends on drm/apple: enable J615 panel brightness control #354 only for panel brightness, not for the display.

Disclosure: the analysis, the patches and this text were made with an AI coding agent (Claude). The tests ran on real hardware, and I checked the results.

@ericjuta

ericjuta commented Nov 8, 2026

Copy link
Copy Markdown
Author

Additional J615 field observation (2026-11-08): the user reports stable unplug/replug and lid-open/closed use with the combined local kernel 7.2.11-dcpexp-usb-recovery-20261108, retaining apple_t8122_display.dcpext_disp_dart=0. This build also carries the idle-port handover, brightness, thermal and USB-recovery changes, so the result cannot isolate this PR or #357 as the cause.

The installed Image matches the USB-recovery build Image by SHA-256. The current boot journal search found no DART translation-fault or co-processor-crash entries. The tested combined kernel is now the first/default Limine entry, with stock and older kernels retained. No additional cable cycles or suspend tests were requested during this audit; the lid/replug result is user-reported, not a controlled suspend/resume qualification. Please treat this as supporting combined-stack hardware evidence, not an exact-PR-branch boot test.

@scottjones scottjones left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, this is great work, and the testing is really thorough: both ports, unplug/replug, s2idle, lid closed, takeover between ports, 0 DART faults. It looks sound for the J615, and J613 is untouched (no fbdma node there, switch default unchanged).

A few code points:

  • Must fix: dcp_fb_mirror() in drivers/gpu/drm/apple/dcp.c maps each framebuffer read-only into the fbdma domain, but nothing unmaps it when the framebuffer or GEM object is freed. Freed pages stay readable by the external DCP until that DVA is reused. A lifetime bug, not a crash. Could you unmap on fb release / cleanup_fb, or keep a per-fb record that's torn down with the fb?
  • Minor: for native buffers it builds a fresh sg_table via drm_gem_dma_get_sg_table() on every flush, even when the buffer is already mapped. At 120 Hz that adds up, so do the already-mapped check before the allocation.
  • Fine as is: only logging a failed iommu_map_sgtable().
  • Wording: a few comments still say "Experiment" (dcp-internal.h, dcp.c, t6030-display-gate.c). Please reword before merge.

On your question about the switch: we'd like a J615 board default, driven by the DT, so a J615 works with no kernel argument:

  • The J615 dcpext node gets apple,no-shared-display-dart.
  • The display gate keeps dispext0_dart out of the shared domain only if that node also has its fbdma child. Otherwise it warns and shares.
  • apple_t8122_display.dcpext_disp_dart becomes tri-state: unset means the board decides, =0/=1 overrides.

The DT property ties the two halves together: m1n1 can check the same marker, so it only turns dcpext on by default for the J615 once a kernel with this support is installed. We have that m1n1 change drafted, and the 13-inch Air's m1n1 default is up as omacom/m1n1#44.

We have this as a commit on top of your branch. It builds clean with W=1 and the property lands in the dtb, but it hasn't run on hardware, since we don't have a J615. You can fold the same change in yourself, or we can share the commit for you to cherry-pick. Which do you prefer?

Once the unmap fix and board default are in, could you retest on your J615 with no dcpext_disp_dart=0 and confirm the internal panel and both ports still work with 0 DART faults?

@maravilla2610

Copy link
Copy Markdown

Please merge this! I need an external monitor support for my MacBook Air 13-inch M3 2024

@ericjuta

Copy link
Copy Markdown
Author

Pushed four review-response commits through f592f13. These add the binding and J615 board marker, fbdma-guarded DT default with tri-state dcpext_disp_dart override, framebuffer mirror lifetime cleanup, and the allocation/comment fixes.

Lifetime detail: unmapping is tied to GEM-object free rather than framebuffer release, since multiple framebuffers can share one buffer. Per-DCP mirror tracking also permits teardown to unmap outstanding mirrors before destroying the fbdma domain. The already-mapped check precedes sg_table allocation.

J615 hardware retest: booted 7.2.11-dcpexp-combined-20261111 without any dcpext_disp_dart command-line override. The live DT contains apple,no-shared-display-dart and fbdma; the gate logs that the display DART is kept out of the display subsystem and framebuffers are mirrored. Internal panel works at 2880x1864@60; Samsung G9 works at 5120x1440@120 on both left USB-C ports. Monitor replug and lid close/open recovered; no matching DART translation faults, coprocessor crashes or mirror failures were found in the checked boot logs. Links bounced for approximately five seconds around replugs before settling. This is functional coverage, not a long-duration GEM-lifetime stress test.

Important qualification: this was a combined kernel, carrying #357 idle-port handover, #354 brightness, local #410 thermal work and local USB-recovery changes in addition to this PR and the four review commits. It is not an isolated #356 test. The local m1n1 boot DT overlay was updated with the board marker; this does not test the drafted upstream m1n1 change.

Separate unresolved observation: after swapping monitor/hub ports, the hub mouse (USB2) returned but its USB3 hub and connected Kiyo Pro Ultra did not. Power-cycling the hub recovered USB3 and the camera at 5 Gb/s. Through-hub MJPEG 3840x2160@30 capture then passed for 20 seconds (599 decoded frames, discarded). USB3 reconnect reliability remains unresolved; cause and relationship to these changes are unproven.

Build verification: changed objects built W=1 and J615 DTB built; combined Image/modules/DTBs built successfully. Focused combined-tree ARM64 KUnit: 267 passed, 1 skipped. Existing boot default retained.

@freber

freber commented Nov 15, 2026

Copy link
Copy Markdown

Claude Code wrote this up from my tests.

I tested this PR on my 15-inch M3 MacBook Air and the external monitor works! The seven commits at f592f13 applied cleanly to aurora16. Thanks for this, Eric.

apple-t8122-display: /soc/dcp@31ac00000: display DART /soc/iommu@319304000 kept out of the display subsystem; framebuffers are mirrored

The monitor is an LG Ultra HD on a single USB-C cable (DisplayPort alt mode), which also carries its USB hub and charging. It came up at 3840x2160 and 60 Hz in 10-bit color on both ports.

Test Result
Hotplug after login, back port (near the hinge) pass (the first try hit the link fault below)
Hotplug after login, front port pass
Unplug and replug 4 times, alternating ports pass, about 3 s from plug to picture each time
Lid closed, the monitor becomes the main screen pass
Suspend (s2idle) for 48 minutes with the monitor connected, woken by opening the lid pass. The session was still locked before I authenticated, Hyprland kept the same PID and the monitor came back at 3840x2160 and 60 Hz
Monitor connected at boot pass, it came up by itself at 3840x2160 and 60 Hz without the link fault
Audio over DisplayPort not tested (the log says "No audio support")
Dock or hub with its own DP output not tested, I don't have one

The first hotplug after my first boot with this PR failed with a link fault on the back port. The driver recovered by itself 3 seconds later. It didn't happen again on any later plug or after the resume.

apple-dcp 31ac00000.dcp: DPTXPort: firmware reports link fault 22 on target 0:0
apple-dcp 31ac00000.dcp: dcp_hotplug() connected:0 valid_mode:0 nr_modes:0

The journal for the boot has no DART faults or DCP crashes. The J615 memory floor from aurora-silicon/linux#1985 ran the whole time and kept confirming its requests in about 31 ms, so the gate's changes to report@8 don't seem to disturb it.

Once m1n1 sets the dcpext line for the J615 by default, will older kernels in the boot menu need apple_t8122_display.dcpext=0 too? The device tree in boot.bin is shared by every kernel in the boot menu. While I tested, I gave my stock aurora16 kernel that setting, since its gate doesn't know apple,no-shared-display-dart and would add dispext0_dart to the display subsystem. I didn't boot it without the setting to check.

@scottjones scottjones left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @ericjuta, this is a really solid follow-up. All four points from my 11-09 review are fixed, and fixed well:

  • The mirror is unmapped when the GEM object is freed, and everything left is unmapped on unbind before the fbdma domain goes away. Keying on the GEM object rather than the framebuffer is the right call.
  • The sg_table is only allocated after the already-mapped check.
  • The "Experiment" comments are reworded.
  • The J615 DT default is in, with dcpext_disp_dart as a tri-state override.

We'd like to ship this in Omarchy 4.5.1. Two things are needed first.

1. The binding description. In Documentation/devicetree/bindings/display/apple,dcp.yaml (around lines 274-277), fbdma/apple,dma-range has a $ref but no description, so dt_binding_check fails the meta-schema ("'description' is a dependency of '$ref'"). tools/aurora-ci/dt-check.py treats binding-invalid as blocking, so the required Kernel CI check will fail once it runs. It hasn't run yet because the fork run is waiting for approval. A one-line description fixes it.

2. A new loader marker that older kernels refuse. m1n1 runs once and fixes up the DT from the newest kernel. The Limine snapshot and rollback entries then boot older kernels with that same DT. A pre-#356 gate enables dcpext whenever the node has apple,t8122-dcpext-firmware-ready == 1, and it shares the display DART. So on a J615 an older kernel would likely take the panel dark. That's from reading the code, I haven't booted it.

Could the gate also accept a new value, for example apple,t8122-dcpext-firmware-ready = <2> (or a separately named node property), for loader defaults? Pre-#356 gates refuse anything but 1, so they'd leave dcpext off. Please keep accepting <1> for an owner's explicit line, and document the new value in apple,dcp.yaml.

A few more asks while you're in there:

  • With the new marker, if a node has apple,no-shared-display-dart but no fbdma child, please refuse dcpext instead of warning and sharing the DART. Separately, forcing dcpext_disp_dart=1 on a J615 should either refuse or disable the fbdma device. Today it shares the DART while fbdma maps the same DVAs and hits the WARN_ON in dart_init_pte() on every flush.
  • Gate KUnit cases for the marker variants and the tri-state: unset with marker and fbdma, unset with marker and no fbdma, =0, =1.
  • A retest without the chosen line in boot.bin, using my m1n1 build once it writes the new marker. I'll share it when it's ready.

One optional note, not blocking: imported dma-bufs are mirrored using sg_phys() on the exporter's table. That breaks the dma-buf rule and would trip under CONFIG_DMABUF_DEBUG (off in our config). iommu_iova_to_phys() on the display domain would be cleaner.

I'm making the matching m1n1 change, and the J613 default from omacom/m1n1#44 moves to the same marker, so both Airs work the same way.

Happy to approve once those are in and CI is green. The branch needs approval after the last push, so I'll approve then rather than now.

@scottjones

Copy link
Copy Markdown
Collaborator

@freber thanks for testing this so carefully, and good catch on the older kernels. I got this wrong on 11-09 when I said m1n1 "only turns dcpext on by default for the J615 once a kernel with this support is installed".

m1n1 runs once and fixes up the DT from the newest kernel. The snapshot and rollback entries in the boot menu then boot older kernels with that same DT. A pre-#356 gate doesn't know apple,no-shared-display-dart, so it would add dispext0_dart to the display subsystem and the J615 panel would likely go dark. I haven't booted that, it's from reading the code, but your dcpext=0 on the stock aurora16 kernel was the right move.

Here's the plan for 4.5.1:

Thanks again, this question made the rollout a lot safer.

apple_t8122_display.dcpext_disp_dart=0 enables the T8122 dcpext without
appending its display DART to the display subsystem's iommus. On the J615
the shared domain faults the internal DCP's DART (NO PMD/PTE FOR IOVA at
0x1000a000000..) and crashes the internal DCP about 2 s into boot.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
With the dcpext display DART out of the display subsystem's domain, the
external pipe scans framebuffers through a DART stream nothing maps. An
optional fbdma child of the dcpext (display DART stream 0, the display
subsystem's DVA window) gets its own domain, and each swapped framebuffer
is mapped read-only there at its display DVA. Imported (GPU) buffers use
the importer's sg table.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
The J613 dcpext routes, carried to the J615 (same T8122 Type-C wiring:
usb-pd@c Left-back/ATC0, usb-pd@a Left-front/ATC1), plus an fbdma child on
dispext0_dart stream 0 for the framebuffer mirror.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
…lay-dart

Describe the fbdma child an external coprocessor scans mirrored
framebuffers through, and the marker that keeps its display DART out of
the display subsystem's IOMMU domain.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
… freed

dcp_fb_mirror() mapped each framebuffer read-only into the fbdma domain
and never unmapped it, so freed pages stayed readable by the external
DCP until their DVA was reused.

Track each mirrored GEM object in an xarray and remove its mapping from
the GEM free hook, before the pages and the DVA are released, and drop
all mirrors when the fbdma device goes away. The xarray also answers
"already mapped" before any sg_table is built, so a flush of a mapped
native buffer no longer allocates. Only a failed mapping is logged.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
…DART

apple,no-shared-display-dart on a dcpext node that has an fbdma child
keeps its display DART out of the display subsystem's domain, so a J615
needs no kernel argument. Without the fbdma child the gate warns and
shares. apple_t8122_display.dcpext_disp_dart becomes tri-state: unset
lets the board decide, =0 and =1 override.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
…by default

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
The boot loader marks a T8122 external coprocessor whose firmware it has
reserved. One device tree serves every installed kernel, and kernels
that share the display DART unconditionally enable the coprocessor on
<1>, which takes the internal panel down on a J615. Document the
property and add <2> for the boot loader's default: those kernels refuse
it. <1> stays for an owner's explicit boot loader configuration.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
The display gate disables the fbdma child when it shares the dcpext's
display DART with the display subsystem. The shared domain already maps
every framebuffer on that DART, and mirroring the same addresses through
the fbdma stream as well hits the WARN_ON in dart_init_pte() on every
flush.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
…r mirror

Accept apple,t8122-dcpext-firmware-ready = <2>, the boot loader's
default, beside <1>, the owner's explicit request. Older gates enable
the dcpext only on <1> and always share its display DART, so a default
of <2> keeps them from taking a J615 panel down when they boot from the
same device tree.

A node with apple,no-shared-display-dart and no fbdma child is now
refused instead of shared with a warning: the board says sharing is
unsafe, and without fbdma nothing can reach the external pipe.

When the DART is shared, by the board or by
apple_t8122_display.dcpext_disp_dart=1, the gate disables the fbdma
child, so framebuffers are never mapped on that DART twice.

The T8122 KUnit tree gains a J615-like dcpext, and cases for both marker
values, a wrong and a missing marker, the board default with and without
fbdma, a board that shares, and dcpext_disp_dart=0 and =1.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
@ericjuta

Copy link
Copy Markdown
Author

@scottjones thanks, all of it is in. The branch is rebased onto integration/aurora 39d5f88ab4e5 (no conflicts) and force-pushed; new head bf36ee14de34. Every commit now carries a Signed-off-by, which the earlier ones lacked.

Blocking

  1. Binding description. fbdma/apple,dma-range has a description (folded into the binding commit). make dt_binding_check DT_SCHEMA_FILES=display/apple,dcp.yaml with dtschema 2026.9 passes here.
  2. Loader marker. The gate accepts apple,t8122-dcpext-firmware-ready = <2> as the loader default and keeps <1> for an owner's explicit line; anything else is refused as before. I kept the one property with a new value rather than adding a second property, so a pre-j615: external DisplayPort over USB-C (dcpext), with fbdma framebuffer mirror #356 gate sees a value it refuses. Both values are documented in apple,dcp.yaml.

Also asked

  • apple,no-shared-display-dart without an fbdma child: the dcpext is refused ("left disabled: apple,no-shared-display-dart without an fbdma child to mirror framebuffers through"). I did this for both marker values, not only <2>: the board says sharing is unsafe either way. Say if you want <1> to keep the old warn-and-share.
  • dcpext_disp_dart=1 on a J615: the gate shares the DART and sets the fbdma child status = "disabled" in the same changeset, and the driver only creates the fbdma device for an available node. So the DART is either shared or mirrored, never both, and the dart_init_pte() WARN_ON path is gone. The same rule applies to any board that shares and happens to have an fbdma child.
  • Gate KUnit: the T8122 test tree gains a J615-like dcpext (marker <2>, apple,no-shared-display-dart, fbdma). Nine new cases: unset with marker and fbdma (not shared, fbdma on), marker <1>, marker <3>, no marker, unset with marker and no fbdma (refused, panel still on), a board without the property (shared, fbdma off), =0, =1, and no panel handoff.
  • Optional sg_phys() note: done as the last commit. dcp_fb_mirror() now reads the pages behind each framebuffer's display DVA with iommu_iova_to_phys() on the display subsystem's domain and maps them into the fbdma domain, for native and imported buffers alike. No sg_table is built or borrowed any more.

Tested

  • arm64 QEMU KUnit (clang, 16K pages, DRM_APPLE=y, the gate and drm/apple suites): 319 cases passed, 0 failed, including apple-display-gate-t8122 24/24. I did not run the full aurora.kunitconfig set locally.
  • Not booted. None of the new commits has run on hardware. That matters most for the last commit, which changes the mirror path that you, freber and I tested at f592f134e698. It is a separate commit so you can drop it if you would rather ship 4.5.1 on the tested path.

Retest

Ready when your m1n1 build is. I will build this head, boot it on the J615 with no chosen line in boot.bin and your m1n1 writing <2>, and report internal panel, both ports, hotplug and DART faults. I will also boot a pre-#356 kernel from the same boot.bin to confirm it leaves the dcpext off and the panel on.

@scottjones

Copy link
Copy Markdown
Collaborator

Thanks Eric, this is a really thorough round. I've been through the new head and everything I asked for looks done.

Two things before I approve:

  1. Kernel CI hasn't run on bf36ee1 yet. Fork runs need a maintainer to approve them first. I'll approve the PR once CI is green on this head.
  2. Could you do one boot of this exact head on a J615, with the external display going through the fbdma mirror? The last commit rewrote dcp_fb_mirror_range() after your and freber's test runs, and KUnit doesn't cover it, so I'd like to see it work on hardware once. Your current m1n1 is fine for this; the m1n1 that writes <2> isn't out yet, and we'll retest with it when it is.

On your question: refusing without an fbdma child for both marker values is right, please keep it. No need to bring back the old warn-and-share for <1>.

One optional nit, not a blocker. In dcp_fb_mirror_range(), pgsize is the larger of the two domains' minimum page sizes, with one iommu_iova_to_phys() per step. If the source domain ever had a smaller page size than fbdma, a hole inside a step could be missed. Both are t8110 DARTs with the same page size on T8122, so it can't happen today. Refusing when the minimums differ, or checking each source page within a step, would close it.

…ations

dcp_fb_mirror() mapped an imported buffer from its exporter's sg_table
with sg_phys(), which an importer must not do and CONFIG_DMABUF_DEBUG
would catch, and built a new sg_table for every native buffer.

Every framebuffer already has a display DVA, so read the pages behind it
with iommu_iova_to_phys() on the display subsystem's domain and map them
into the fbdma domain at the same addresses, for native and imported
buffers alike.

Signed-off-by: Eric Juta <ericjohnjuta@gmail.com>
@ericjuta

Copy link
Copy Markdown
Author

@scottjones the J615 boot with the external display on the fbdma mirror, with the display code at b4cc668a6802 (kernel 7.2.11-dcpext-pr356-combined-20261116, a local build that carries this branch), current m1n1, marker <1>, no dcpext_disp_dart argument.

  • Gate: display DART /soc/iommu@319304000 kept out of the display subsystem; framebuffers are mirrored; fbdma: framebuffers mirrored through /soc/dcp@31ac00000/fbdma.
  • Cold boot with a 4K monitor attached (AOC 28E850, USB-C DP alt-mode adapter): internal panel on, external up at 3840x2160@60.
  • Hotplug on one port, unplug, replug on the other port (DPTX PHY 0, then PHY 1): up in about 3 s each time.
  • Lid close/open with the monitor attached: both panels back.
  • No DART translation faults, no DCP errors, no WARNING across two boots (about 10 h of use on the first).

Not tested on this build: suspend/resume with the display attached, and 5120x1440@120.

The page-size nit is in too: dcp_fb_mirror_range() steps by the source domain's smallest page and returns -EINVAL when fbdma's differs.

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.

4 participants