Skip to content

iommu/apple-dart, drm/apple: t8132: dual-pipe peer bonding for high-pixel-rate external displays - #3454

Open
stango-git wants to merge 6 commits into
aurora-silicon:mainfrom
stango-git:feat/t8132-dcpext-dual-pipe
Open

stango-git wants to merge 6 commits into
aurora-silicon:mainfrom
stango-git:feat/t8132-dcpext-dual-pipe

Conversation

@stango-git

@stango-git stango-git commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What: Implement generic T8132 (iomfb_m4) external DCP dual-pipe peer bonding (dispext0 + dispext1) for high-pixel-rate external displays exceeding single-pipe limits (> 6144 px width or > 1,274,019,840 px/s active pixel rate, e.g. 5120x2160@120/165 Hz or 3840x2160@240 Hz). Merged main (c3fbd2361475, which includes #3258) at 358830a0849b and added peer lifetime pinning + peer_stop_work unbind teardown at b21a5c532a0c so the diff against main contains only the 12 intended peer-map and dual-pipe files. Companion PMC fix #3452 handles deep-sleep display clock restore at high pixel rates.

Tested:

  • Standalone current-head row at b21a5c532a0c (without pmdomain: apple-pmc: restore display interface enables after deep sleep #3452): J713 (M4 MacBook Air 13", T8132, Mac16,12, macOS 26.6.2 stub) + Dell AW3926QW (39" 5120x2160@165 Hz OLED over USB-C DP Alt Mode, 4-lane HBR3, DSC active on both pipes) on 7.3.0-dp-b21a5c532+: PASS — cold boot straight into dual-pipe 5120x2160@165 Hz (reserved peer 48ae00000.dcp (index 2) for 5120x2160 active=1824664387), dual/single-pipe transitions (5120x2160@165 -> peer unpair result=0 -> @120 -> peer unpair result=0 -> @60 single -> 3840x2160@144 single -> 5120x2160@165 dual), DPMS off/on (paired DRM modeset ... kept), and two consecutive USB-C disconnect/replug cycles including rapid unplug/replug with overlapping dcp_dptx_disconnect / pending peer_stop_work (peer stop on disconnect: 0 + clean re-reservation and recovery to 5120x2160@165 Hz); 0 DART faults, 0 frame not shown, 0 refcount/UAF/kernel oops/WARN, 0 failed systemd units.
  • Host tests at b21a5c532a0c: tools/asahi/run-host-tests.py — apple-dart-dispext-window 6/6 pass (including peer-allow-same-dart), apple-dcp-m4-peer 3/3 pass (width-only + no-concurrent-oob), apple-dart-isp-host 1/1, apple-dart-range 1/1, apple-dart-fw 2/2; tools/testing/selftests/drivers/gpu/apple-dcp/run.py --group m4 9/9 pass (including m4-notch-frame).
  • Build & style at b21a5c532a0c: LLVM=1 W=1 build of drivers/gpu/drm/apple/iomfb_m4.o and full Image + modules + BTF (7.3.0-dp-b21a5c532+) succeeded with 0 warnings/errors; scripts/checkpatch.pl --strict --no-tree on b21a5c532a0c: 0 errors, 0 warnings, 0 checks.
  • Supporting evidence (composed kernel with pmdomain: apple-pmc: restore display interface enables after deep sleep #3452): deep sleep + wake at 5120x2160@165 Hz and unplug-while-asleep recovery passed on J713 (7.3.0-dualpipe-s2+, functionally identical dual-pipe diff + pmdomain: apple-pmc: restore display interface enables after deep sleep #3452).

Risk: two-way door · M4 (T8132) — cleanly revertible kernel-only change with no bootloader, DT, or persistent state changes; scoped to T8132 external DCP (dispext) dual-pipe peer bonding, leaving single-pipe modes, internal disp0, and non-T8132 Macs untouched.

Not yet:

Details & Provenance

Clean provenance for single-pipe limits and wire fields

  • Single-pipe limits (DCP_M4_EXT_PIPE_MAX_WIDTH = 6144, DCP_M4_EXT_PIPE_MAX_ACTIVE_RATE = 1274019840): Chip-level T8132 external pipe ceiling (6144 x 3456 x 60 = 1,274,019,840 active px/s, matching the public M4 6K@60 Hz single-pipe external display spec) verified directly against live T8132 firmware SetHints / A364 enumeration on J713 + Dell AW3926QW: modes at or below 1,274,019,840 active px/s (5120x2160@60 Hz = 663,552,000 px/s, 3840x2160@144 Hz = 1,194,393,600 px/s) report requires_merge=0 and run single-pipe, while modes above it (5120x2160@120 Hz = 1,327,104,000 px/s, 5120x2160@165 Hz = 1,824,664,387 px/s) report requires_merge=1 in A364 and require a peer pipe. Unlike non-compact firmware-27 services (dptxep.c:dptxport_init_props()), T8132 compact AFK dispext0:dcpdptx-port-epic:0 does not emit MaxPixelWidth/MaxActivePixelRate init properties, so the chip ceiling is defined in dcp-m4-peer.h.
  • Wire layouts, RPC tags, and offsets (all mirrored/reused from existing in-tree drivers on main):
    • struct dcp_display_hints (160 B, hints[0], +0x38 width, +0x3c height, +0x40 total, +0x44 active, primary_id/peer_id/extra_pipes/flags/status) and struct dcp_peer_tiling + dcp_peer_tiling_get()/set() (D115/D116): directly included from drivers/gpu/drm/apple/dcp-peer-v26_6.h and drivers/gpu/drm/apple/dcp-peer-v27.h.
    • dcp_m4_peer_split_timing() (half_fields[] = {4, 8, 12, 16, 20, 28, 68}, signed +24) and A364/A365 video_data (0x50 timing + 0x20 color; 0x7c/0x74 req/resp): mirrored directly from drivers/gpu/drm/apple/dcp-peer-v26_6.inc.
    • EP37 RPC tags (A360/A361, A362, A364, A365, A366, A367–A373, A406/A407, A413, A473, D115/D116, D575, D590): identical to existing drivers/gpu/drm/apple/dcp-peer-v26_6.inc, drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc, and drivers/gpu/drm/apple/iomfb_m4.c.
    • dcp_m4_swap_set_tile() surface-0 source rect (0xac/0xb0/0xb4/0xb8) and destination rect (0x10c/0x110/0x114/0x118) offsets: identical to existing dcp_m4_swap_encode_on() in drivers/gpu/drm/apple/dcp-m4-frame.h.

Commit breakdown

  • 5bc08061c (iommu/apple-dart: map retained dispext SID0 scanout surfaces into a peer DART): Add apple_dart_dcp_dispext_scanout_map_peer() to share retained dispext SID0 backing pages into a distinct peer external display DART with zero extra RAM allocation and full fail-closed checks; extend tools/asahi/apple-dart-dispext-window-tests.py + run-host-tests.py with peer-allow-same-dart mutation.
  • 9f541f763 (drm/apple: t8132: bond idle external DCP peer for high-pixel-rate modes): Wire DPTX_APCALL_SET_TILED_DISPLAY_HINTS upward-only (1 -> 2) peer reservation, D575/D115/D116 tiling state, A364/A365 split modeset, bounded stream-1 OOB DSC copy during stream-0 A413 phase-2 rendezvous, synchronized A360/A361 swap IDs, tile-split paired A406/A407 swaps, and teardown across dual-to-single transitions, DPMS blank, link disconnect, and sleep; add tools/asahi/apple-dcp-m4-peer-tests.py.
  • 358830a08 (Merge remote-tracking branch 'origin/main' into feat/t8132-dcpext-dual-pipe): Merge main (c3fbd2361475, containing iommu/apple-dart, drm/apple: support 64 MiB T8132 external scanout up to 5120x2880 #3258); only tools/asahi/run-host-tests.py conflicted and kept both main's apple-dart-isp-host-tests.py and this PR's test entries.
  • b21a5c532 (drm/apple: iomfb_m4: pin peer lifetime across lock drops and disable peer_stop_work on unbind): Guard schedule_work(&dcp->peer_stop_work) under dcp_m4_peer_lock, call disable_work_sync(&dcp->peer_stop_work) in iomfb_m4_quiesce(), and pin struct iomfb_m4 (kref) + peer->dev (get_device()) across dcp_m4_peer_get_locked() / iomfb_m4_ext_sleep_down() lock drops, released via dcp_m4_peer_put_locked() at all callers.
Evidence
Linux omamacy 7.3.0-dp-b21a5c532+ #11 SMP PREEMPT_DYNAMIC Sun Nov 29 00:16:56 EST 2026 aarch64 GNU/Linux

[   17.969625] apple-dcp 286e00000.dcp: reserved peer 48ae00000.dcp (index 2) for 5120x2160 active=1824664387
[   19.239055] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 1920x1080@120 Hz, 297000 kHz
[   22.616960] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp off: 0
[   23.804304] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 5120x2160@165 Hz, 2036750 kHz
[   58.823642] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp off: 0
[   59.129112] apple-dcp 286e00000.dcp: peer unpair result=0
[   60.273560] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 5120x2160@120 Hz, 1449000 kHz
[   62.441412] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp off: 0
[   62.761451] apple-dcp 286e00000.dcp: peer unpair result=0
[   63.118402] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 5120x2160@60 Hz, 703750 kHz
[   65.279332] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp off: 0
[   65.658552] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 3840x2160@144 Hz, 1332750 kHz
[   67.841858] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp off: 0
[   69.009883] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 5120x2160@165 Hz, 2036750 kHz
[   71.617672] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp off: 0
[   74.428924] apple-dcp 286e00000.dcp: paired DRM modeset 5120x2160 timing 91 color 96: kept
[   74.428940] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 5120x2160@165 Hz, 2036750 kHz
[  100.062240] apple-dcp 286e00000.dcp: dcp_dptx_disconnect(port=0)
[  100.074529] apple-dcp 286e00000.dcp: dcp_dptx_disconnect(port=0)
[  100.074537] apple-dcp 286e00000.dcp: dcp_dptx_disconnect(port=0)
[  100.180207] apple-dcp 286e00000.dcp: peer stop on disconnect: 0
[  100.180241] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp off: 0
[  108.089264] apple-dcp 286e00000.dcp: reserved peer 48ae00000.dcp (index 2) for 5120x2160 active=1824664387
[  109.985536] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 5120x2160@165 Hz, 2036750 kHz
[  118.607714] apple-dcp 286e00000.dcp: dcp_dptx_disconnect(port=0)
[  118.614739] apple-dcp 286e00000.dcp: dcp_dptx_disconnect(port=0)
[  118.614747] apple-dcp 286e00000.dcp: dcp_dptx_disconnect(port=0)
[  118.730149] apple-dcp 286e00000.dcp: peer stop on disconnect: 0
[  118.731154] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp off: 0
[  122.457574] apple-dcp 286e00000.dcp: reserved peer 48ae00000.dcp (index 2) for 5120x2160 active=1824664387
[  124.324884] apple-dcp 286e00000.dcp: dcpext-286e00000.dcp on: 5120x2160@165 Hz, 2036750 kHz

$ systemctl --failed --no-pager
0 loaded units listed.
  • Host tests (tools/asahi/run-host-tests.py) at b21a5c532a0c:
    • apple-dart-dispext-window: 6/6 passed
    • apple-dcp-m4-peer: 3/3 passed
    • apple-dart-isp-host: 1/1 passed; apple-dart-range: 1/1 passed; apple-dart-fw: 2/2 passed
  • M4 selftests (tools/testing/selftests/drivers/gpu/apple-dcp/run.py --group m4) at b21a5c532a0c: 9/9 passed (including m4-notch-frame).

…eer DART

Dual-pipe external display bonding on T8132 scans out a single framebuffer
across two external display pipes (dispext0 and dispext1), each behind its
own display DART. Allocating duplicate 42+ MiB scanout surfaces on the
peer DART would double scanout memory usage and require a second CPU copy
per frame.

Add apple_dart_dcp_dispext_scanout_map_peer() to map the immutable backing
pages of an existing retained dispext SID0 scanout surface into SID0 of a
separate peer external display DART at its own IOVA, with zero additional
RAM allocation and full fail-closed qualification and retention checks on
the peer DART.

Extend tools/asahi/apple-dart-dispext-window-tests.py to exercise
__apple_dart_dcp_dispext_scanout_map_peer() across two distinct display
DARTs (including zero extra page allocations, exact page-by-page physical
translation parity, fragmented peer arena rejection, and same-DART
rejection with a matching mutation check).

Signed-off-by: Joe Stango <212442060+stango-git@users.noreply.github.com>
A single T8132 external display pipe (dispext0) caps out at 6144 px width
and 1,274,019,840 px/s active pixel rate, so high-bandwidth sinks such as
5120x2160@120/165 Hz or 3840x2160@240 Hz report requires_merge=1 in A364
and require bonding an idle peer external pipe (dispext1).

Implement generic T8132 (iomfb_m4) external DCP dual-pipe peer bonding:
- Wire DPTX_APCALL_SET_TILED_DISPLAY_HINTS in dptxep.c to reserve an idle
  higher-index external DCP peer when a non-tiled sink exceeds single-pipe
  width or active pixel rate (up to 2x single-pipe limits), returning the
  peer allocation so firmware enumerates dual-pipe timings.
- Record primary and peer display IDs from D575 tiled hotplug records and
  route D115/D116 tiling state queries across the bonded pair.
- Allow one concurrent stream-1 out-of-band query on external DCPs while a
  stream-0 A413 modeset is paused at the phase-2 rendezvous, so primary
  DSC configuration (A369/A367/A370/A372) can be copied to the peer
  (A368/A371/A373) before the peer runs A413.
- Split horizontal timings and pixel clock in half for A365 derived mode
  insertion, synchronize master swap IDs (A360/A361), share primary SID0
  scanout surfaces onto the peer DART, and submit left/right tile-split
  paired A406 swaps on both copy and direct scanout paths.
- Quiesce and unpair cleanly across dual-to-single mode switches, DPMS
  blank/unblank, link disconnect, and system deep sleep.

Add host tests and mutation checks in tools/asahi/apple-dcp-m4-peer-tests.py
covering pair admission boundaries, horizontal timing splitting, upward-only
peer index rules, tile-split swap encoding, and concurrent stream-1 OOB
transactions.

Signed-off-by: Joe Stango <212442060+stango-git@users.noreply.github.com>
@stango-git
stango-git requested review from a team and DjDeveloperr as code owners November 27, 2026 23:43
satchlj
satchlj previously approved these changes Nov 28, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed exact head 9f541f76320b (iommu/apple-dart, drm/apple: t8132: dual-pipe peer bonding for high-pixel-rate external displays, top 2 commits 5bc08061c and 9f541f763 stacked on #3258):

  • Code audit:
    • Commit 1 (5bc08061c, apple_dart_dcp_dispext_scanout_map_peer()): properly enforces distinct non-coherent dispext DARTs (peer_pio->dart != src_pio->dart), SID 16 qualification, retired/fault-pending fail-closed checks, overflow-safe allocated accounting, and APPLE_DART_DISPEXT_GATED gating while sharing retained scanout backing pages with zero extra allocation.
    • Commit 2 (9f541f763, dcp-m4-peer.{h,inc} + iomfb_m4.c): cleanly bounds peer reservation (1 -> 2 upward-only, width/pixel-rate thresholds), splits horizontal timings/clocks, allows bounded concurrent stream-1 OOB during stream-0 phase-2 rendezvous, and tears down/unpairs across single-pipe transitions, DPMS blank, disconnect, and sleep.
  • Host tests on exact head 9f541f76320b:
    • python3 tools/asahi/apple-dart-dispext-window-tests.py: 5/5 PASS (including peer SID0 scanout mapping + mutations).
    • python3 tools/asahi/apple-dcp-m4-peer-tests.py: 4/4 PASS (dcp_m4_peer_needs_pair, split timing/peer index/tiling state, left/right tile swap encoding, concurrent stream-1 OOB + mutations).
  • scripts/checkpatch.pl --strict --no-signoff (top 2 commits): 0 errors; minor non-blocking nits: duplicate Signed-off-by line in 9f541f763 and one 101-column dev_err line at drivers/iommu/apple-dart-dcp-shared.h:682.
  • Scope note: Code-review + host-test verification only (no T8132 + high-pixel-rate external display on this bench; Mac16,12 5120x2160@165 Hz hardware verification is covered in the PR description).

@github-actions github-actions Bot added area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 995a4bdc: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok comment at 995a4bdc
Conflicts ok none
PR text ok Risk: two-way · M4 (T8132) — cleanly revertible kernel-only change with no bootloader, DT, or persistent state changes; scoped to T8132 external DCP (dispext) dual-pipe peer bonding, leaving single-pipe modes, internal disp0, and non-T8132 Macs untouched.

Areas: area:display, area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot) merge-conflict Conflicts with the base branch (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) ready-to-merge Meets the merge policy: merge it (bot) labels Nov 28, 2026
@stango-git
stango-git dismissed satchlj’s stale review November 29, 2026 04:04

The merge-base changed after approval.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH at 9f541f7. This head conflicts with main and was stacked on an older #3258 head. Please merge current main normally and confirm the new diff contains only the intended peer-map and dual-pipe changes. Please cite clean provenance for the single-pipe limits and new wire fields. The J713 result on a composed kernel is supporting evidence. Please add a standalone current-head J713 row exercising dual/single transitions and teardown and record explicitly which sleep cases depend on #3452.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FIX, then re-review at 358830a0849b

Blockers:

  1. Missing peer_stop_work cancellation on unbind (drivers/gpu/drm/apple/iomfb_m4.c / dcp-m4-peer.inc): dcp_m4_peer_schedule_stop() calls schedule_work(&dcp->peer_stop_work) after releasing dcp_m4_peer_lock, while dcp_m4_peer_forget() only sets dcp->peer_unbinding = true and iomfb_m4_quiesce() only cancels dcp->backlight_work — never dcp->peer_stop_work. If peer_stop_work is pending or scheduled around unbind, dcp_m4_peer_stop_work() can run after iomfb_m4_quiesce() returns and dereference freed dcp (&dcp->lock, dcp->runtime, dcp_m4_peer_release(dcp)). Guard schedule_work(&dcp->peer_stop_work) against dcp->peer_unbinding under dcp_m4_peer_lock (or use disable_work_sync(&dcp->peer_stop_work)) and cancel/flush &dcp->peer_stop_work in iomfb_m4_quiesce().
  2. Unpinned struct iomfb_m4 *peer dereferenced across lock drops (drivers/gpu/drm/apple/dcp-m4-peer.inc and iomfb_m4.c):
    • In dcp_m4_peer_get_locked(), peer is loaded from dcp->peer_reserved under dcp_m4_peer_lock, then dcp_m4_peer_lock is released with no reference held on peer before mutex_lock_nested(&peer->lock, SINGLE_DEPTH_NESTING). If peer unbinds and frees in that window, taking &peer->lock is a use-after-free.
    • In iomfb_m4_ext_sleep_down(), both &peer->lock and &dcp->lock are released around a 1-second wait_event_timeout(peer->ext_settle_wq, ...) and re-acquired on peer without holding any lifetime reference on peer.
    • Hold a lifetime reference on peer (for example get_device(peer->dev) / a kref on struct iomfb_m4) acquired under dcp_m4_peer_lock before dropping it, paired with a dcp_m4_peer_put_locked() helper for every caller.
  3. Prior 9f541f76 items still open: 358830a0 merged main cleanly (#3258 included), but still needs: (a) clean provenance citations for the single-pipe limits and new wire fields, and (b) a standalone current-head J713 hardware row exercising dual/single transitions and teardown (explicitly noting which sleep cases depend on #3452).

Checked:

  • Merge 358830a0849b against main (#3258): diff is scoped cleanly to the 12 intended peer-map and dual-pipe files (apple-dart-dcp-shared.h, dart.h, dcp-m4-peer.{h,inc}, dcp-m4-frame.h, dcp-m4-transaction.h, dptxep.c, iomfb_m4.{c,h}, and host tests).
  • apple_dart_dcp_dispext_scanout_map_peer() peer-window mapping and host tests (apple-dart-dispext-window-tests.py, apple-dcp-m4-peer-tests.py).
Evidence
  • drivers/gpu/drm/apple/iomfb_m4.c (iomfb_m4_quiesce()): calls dcp_m4_peer_forget(dcp); dcp_m4_failed(dcp, -ENODEV); cancel_work_sync(&dcp->backlight_work); without cancelling dcp->peer_stop_work.
  • drivers/gpu/drm/apple/dcp-m4-peer.inc (dcp_m4_peer_get_locked()): releases dcp_m4_peer_lock before mutex_lock_nested(&peer->lock, SINGLE_DEPTH_NESTING) with no refcount/device pin on peer.
  • drivers/gpu/drm/apple/iomfb_m4.c (iomfb_m4_ext_sleep_down()): unlocks &peer->lock and &dcp->lock across wait_event_timeout(peer->ext_settle_wq, ...) and re-locks &peer->lock with no refcount/device pin on peer.

@stango-git

stango-git commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

(Note: this answered the earlier 9f541f76 review — saw the new 358830a0849b review right after posting; holding off on re-review until the peer_stop_work cancellation and peer refcount fix commit is pushed.)

Addressed the earlier 9f541f76 review items at 358830a0849b:

  1. Merged current main (c3fbd2361475, including iommu/apple-dart, drm/apple: support 64 MiB T8132 external scanout up to 5120x2880 #3258) as a merge commit (no force push):
  2. Clean provenance cited in the PR description (Details & Provenance):
    • Single-pipe limits (6144 px / 1,274,019,840 active px/s = 6144 x 3456 x 60) are the chip-level T8132 ceiling verified against live firmware A364 requires_merge boundaries on J713 (3840x2160@144 = 1,194,393,600 px/s single-pipe vs 5120x2160@120 = 1,327,104,000 px/s and @165 = 1,824,664,387 px/s dual-pipe); T8132 compact AFK dcpdptx-port-epic:0 does not emit MaxPixelWidth/MaxActivePixelRate init props.
    • All wire layouts, structs, RPC tags (A360–A373, A406/A407, A413, A473, D115/D116, D575, D590), and tile rect offsets (0xac..0x118) are reused/mirrored directly from existing in-tree dcp-peer-v26_6.{h,inc}, dcp-peer-v27.h, dcp-peer-modeset-probe-v27.inc, and dcp-m4-frame.h.
  3. Standalone current-head J713 hardware row at 358830a0849b (without pmdomain: apple-pmc: restore display interface enables after deep sleep #3452):

@satchlj please hold off on re-review for now — pushing a follow-up commit to address the peer_stop_work cancellation and peer lifetime refcount findings from the latest review, and will ping again at the new head.

…peer_stop_work on unbind

Fix two unbind/lifetime races in the T8132 external dual-pipe peer path:

1. Disable peer_stop_work on unbind:
   - Guard schedule_work(&dcp->peer_stop_work) with !dcp->peer_unbinding
     while still holding dcp_m4_peer_lock in dcp_m4_peer_schedule_stop().
   - Call disable_work_sync(&dcp->peer_stop_work) in iomfb_m4_quiesce()
     after dcp_m4_peer_forget() and dcp_m4_failed(-ENODEV) so no pending
     or newly scheduled peer_stop_work can run after quiesce returns.
   - Guard ext_peer_node insertion against peer_unbinding.

2. Pin struct iomfb_m4 and peer->dev lifetime across lock drops:
   - Add a kref to struct iomfb_m4 (initialized in iomfb_m4_init() and
     released via iomfb_m4_put() in iomfb_m4_release()).
   - Acquire iomfb_m4_get(peer) and get_device(peer->dev) under
     dcp_m4_peer_lock in dcp_m4_peer_get_locked() before dropping
     dcp_m4_peer_lock to take peer->lock, keeping peer alive across both
     the lock handoff and the temporary unlock/relock around the 1 s
     ext_settle_wq wait in iomfb_m4_ext_sleep_down().
   - Release peer->lock, peer->dev, and the kref via
     dcp_m4_peer_put_locked() at every caller (including the !r path in
     dcp_m4_peer_stop_work()).

Signed-off-by: Joe Stango <212442060+stango-git@users.noreply.github.com>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH at b21a5c5

Checked: The revision guards stop-work enqueue under the peer lock, disables and drains the work at quiesce, and pins the peer object and device across the lock handoff. Checked the puts on revalidation failure and in the stop worker.

Blocker: Validate those changes in the standalone J713 dual/single transition and disconnect path at this head. Include teardown while the peer stop is pending and note which sleep cases require #3452. Keep exact-head hosted checks.

@stango-git

Copy link
Copy Markdown
Contributor Author

Standalone current-head hardware row at b21a5c532a0c (without #3452) on J713 (M4 MacBook Air 13", T8132, Mac16,12, macOS 26.6.2 stub) + Dell AW3926QW over USB-C DP Alt Mode: PASS.

PR body updated with the b21a5c532a0c row, full dmesg evidence, and provenance citations. @satchlj ready for re-approval at b21a5c532a0c!

@github-actions github-actions Bot added needs-review No approving review from Core or Omarchy Mac yet (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 29, 2026
@stango-git
stango-git requested a review from satchlj November 30, 2026 02:31

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: MERGE at b21a5c532a0c

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: Code reviewed in the earlier App review at this head (6101545973).

Follow-ups (not blocking): standalone J713 dual/single transition + disconnect row incl. pending peer stop, hosted checks

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 1, 2026
DjDeveloperr
DjDeveloperr previously approved these changes Dec 2, 2026

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

Approve at b21a5c532a0c. The DART side only adds apple_dart_dcp_dispext_scanout_map_peer(). It refuses coherent devices, the same DART and unknown DVAs, claims slices under the peer's alloc_lock, and verifies every PTE and root before handing out the DVA. On any failure after the claim it retires the peer DART, as the other dispext paths do. Peer mappings are cached by source DVA (ext_peer_buf_src), so dual→single→dual transitions don't grow the peer arena. The dptxep.c hook is gated on dcp_is_t8132_ext().

What this still needs:

  • Host tests: the red host-tests was g17-compute-owed-stamp-tests, which failed on main at that time, not here. I restarted it.
  • One more row: dcp-m4-transaction.h (the concurrent stream-1 call and the reply-side oob clear) runs for every iomfb_m4 external DCP, not only in dual-pipe modes. Besides your J713 receipt, the merge needs one ordinary single-pipe external display row on another M4-family Mac (J773g in our lab): hotplug, a mode change and DPMS.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 2, 2026
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Merge-up check against current main: the textual conflict is small. In iomfb_m4.c, main added the DCP_M4_EXT_IDLE_DELAY_MS defines where this branch adds the peer forward declarations, and keeping both resolves it. But main also changed behaviour this PR depends on. Since #3948's window, main powers down an external DCP 5 s after it has no active route (iomfb_m4_ext_idle_work(), armed through iomfb_m4_ext_idle_arm_locked() unless ext_idle_held is set). The peer this PR bonds for dual-pipe modes is exactly such an idle external DCP, so on main it can be stopped before or during a bonded mode, and the bonding path takes no idle hold on it. That needs your call (hold the peer while bonded, or wake it before dcp_m4_peer_* uses it) and your J713 dual-pipe setup to verify, so I have not pushed a merge. Once main is merged with that handled: one standalone J713 dual-to-single-to-dual plus disconnect row at the new head, and the single-pipe external display row on our J773g (hotplug, a mode change, DPMS) for the shared dcp-m4-transaction.h path.

drivers/gpu/drm/apple/iomfb_m4.c: keep this branch's peer declarations and
main's idle power-down delays, which were added at the same place.

Signed-off-by: DjDeveloperr <hey@djdev.me>
An external DCP is now powered down 5 s after it has no route. A dual-pipe
bond's peer never has one: it can be down already when the bond picks it,
or go down under the bond as soon as its display DART is off (a mode that
needs one pipe, DPMS off). RTKit then refuses the first call to it, which
fails its session until the next boot.

Refuse to arm or run the idle power-down of either DCP of a bond, start a
peer that is already down before a modeset uses it, and arm the timers
again wherever a bond ends. The reservation is made under dcp_m4_peer_lock
alone and can race with a stop under way; the modeset takes the peer's
lock, so it sees the stop's result and undoes it. A peer that does not come
back leaves the primary its single pipe.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor

I merged main (37a630623169) into your branch and added one commit, so this doesn't have to wait on you. Your commits are unchanged. The head is now 995a4bdc7411.

What main changed: since #3321 an external DCP without a route is powered down after 5 s. Your peer never has a route, so it could already be down when the bond picks it, or go down under the bond once its display DART is off (a single-pipe mode, DPMS off). RTKit then refuses the first call to it, and that fails its session until reboot.

What the new commit does (995a4bdc7411):

  • Neither DCP of a bond arms or runs the idle power-down while the bond exists.
  • A modeset starts a peer that is already down before it uses it. If the peer doesn't come back, the display stays on a single pipe.
  • Every end of a bond (disconnect, dropped reservation, sleep, unbind) lets both DCPs idle again.

Checks at this head:

  • arm64 clang W=1 of drivers/gpu/drm/apple/ and apple-dart.o: no warnings. T8132 DTBs build.
  • checkpatch --strict on the new commit: only the usual MAINTAINERS note for a new file.
  • Host tests: DART group 33/33, DCP group 113/114. The new apple-dcp-m4-peer-idle-tests fails without the fix.
  • The one DCP failure is apple-dcp: three cases (physical-disconnect, fast-replug-bounce, dropped-swap-teardown) don't compile against what drm/apple: dcp: rearm Type-C IOMFB HPD completion on deep-sleep DPTX release #4013 just added to dcp.c. This branch doesn't touch that file. With main from just before it, the group was 114/114.

Not verified: nothing ran on hardware. Bonding a peer that was restarted from idle is new. The peer is started at the modeset, not at SetHints, so the primary's firmware gets the peer's ID while the peer may still be down.

Rows owed at this head:

  • You, J713: dual -> single -> dual, then disconnect and replug, idling more than 5 s before each re-bond. Please also include DPMS off for more than 5 s in dual mode.
  • Us, J773g: single-pipe external display (hotplug, a mode change, DPMS).

If you want any of this done differently, change it as you like.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Dec 2, 2026
@RyanTheTide RyanTheTide closed this Dec 3, 2026
@RyanTheTide RyanTheTide reopened this Dec 3, 2026
@stango-git

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr Tested 995a4bdc7411 on J713 (Mac16,12, T8132, OS FW 26.6.2 / mBoot-20457.41.3, Dell AW3926QW over USB-C DP Alt Mode, kernel 7.3.0-dp-995a4bdc7+ with matching t8132-j713.dtb from 995a4bdc7411 via aura-try, verified apple,dp-alt-mode present on both phy@402a90000 and phy@40aa90000): FAIL (blocked before dual-pipe by #3321 external DCP idle wake timeout on 26.6.2).

Host tests: python3 tools/asahi/run-host-tests.py --only dcp-m4-peer — 11/11 passed (including apple-dcp-m4-peer-idle-tests and all 7 mutations).

What happened on hardware

  1. Both 286e00000.dcp and 48ae00000.dcp adopted cleanly in initrd (21:20:52, IOMFB startup complete: 165 callbacks; external, AFK[ep:2a]: new compact service dispext0:dcpdptx-port-epic:0 on interface 1 (deferred)).
  2. 5 s later, while initrd waited for LUKS unlock (before sn201202x probed in userspace), #3321's runtime idle power-down fired on both external DCPs.
  3. After switch-root, when sn201202x 1-0a routed the Dell monitor to 286e00000.dcp, iomfb_m4_ext_start() woke RTKit (RTKit: Initializing (protocol version 12)) and then timed out at DPTX ready: -110 with zero AFK compact service re-announcements, quarantining 286e00000.dcp for the rest of the boot:
Dec 02 21:20:57.889913 archlinux kernel: apple-dart 286300000.iommu: CIO DART stop: version=0x202 streams=32 partitions=0 slice=4
Dec 02 21:20:57.890468 archlinux kernel: apple-dart 286340000.iommu: CIO DART stop: version=0x202 streams=32 partitions=0 slice=5
Dec 02 21:20:58.914905 archlinux kernel: apple-dart 48a300000.iommu: CIO DART stop: version=0x202 streams=32 partitions=0 slice=29
Dec 02 21:20:58.915299 archlinux kernel: apple-dart 48a340000.iommu: CIO DART stop: version=0x202 streams=32 partitions=0 slice=30
...
Dec 02 21:21:08.348164 omamacy kernel: apple-dart 286340000.iommu: TEST sv6t7: CIO DART start: PS_PROT slice 5 now 0x12
Dec 02 21:21:08.348744 omamacy kernel: apple-dart 286300000.iommu: TEST sv6t7: CIO DART start: PS_PROT slice 4 now 0x12
Dec 02 21:21:08.349132 omamacy kernel: apple-dcp 286e00000.dcp: RTKit: Initializing (protocol version 12)
Dec 02 21:21:09.402913 omamacy kernel: apple-dcp 286e00000.dcp: external DCP restart failed at DPTX ready: -110
Dec 02 21:21:09.403511 omamacy kernel: apple-dcp 286e00000.dcp: Retained DCP session quarantined: -110
Dec 02 21:21:09.403867 omamacy kernel: sn201202x 1-0a: failed to configure Type-C connection: -110
Dec 02 21:21:10.411906 omamacy kernel: sn201202x 1-0a: failed to configure Type-C connection: -110
Dec 02 21:21:11.418910 omamacy kernel: sn201202x 1-0a: failed to configure Type-C connection: -110
Dec 02 21:21:11.419526 omamacy kernel: sn201202x 1-0a: cable revalidation failed after 3 attempts
  1. Unplugging and replugging the monitor (21:27:58) immediately retried the quarantined 286e00000.dcp and failed with -110 (x4) instead of falling back to 48ae00000.dcp.

Root-cause notes

  • Primary (#3321 / iomfb_m4.c): iomfb_m4_ext_start() wakes 286e00000.dcp via apple_rtkit_wake_retained(), which intentionally does not send RBEP_INIT to the AFK endpoints (ep:2a, probe_ep[]), and then iomfb_m4_ext_reset_finish() waits 1000 ms for dispext0:dcpdptx-port-epic:0 to re-announce with afk_power_gen == gen. On 26.6.2 T8132 hardware, no compact service re-announcements arrive during that wait (either the reset firmware waits for RBEP_INIT on ep:2a before announcing services, or ep:2a stays open across retained wake without re-announcing).
  • Secondary (dcp-fabric.c): In dcp_fabric_snapshot_port(), pipeline->services_ready = !tunnel || dcp_tb_services_ready(dcp) skips iomfb_m4_ext_route_ready(dcp) for direct DP Alt Mode (!tunnel), so a quarantined dcpext (dcp->error != 0) keeps getting selected on replug instead of failing over to the healthy peer dcpext.

Happy to work on a fix patch, test it on this 26.6.2 J713, and either open a separate PR against main or commit it directly here — whichever you prefer — then run the full > 5 s dual/single/DPMS/replug matrix on #3454.

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Thank you, this report and its log were enough to find it: #3321 broke this on main, not your PR. The extra-looking TEST sv6t7 line in your log is in main too (apple-dart-cio.c), so nothing in your kernel explains the failure either. The fix is #4040.

What we found

It is built and host-tested only; nobody on our side has run it on 26.6.2. If you already have a better patch, please push or post it and we will take that one instead.

The row we would like from your J713, on #4040 alone (without this PR): monitor plugged in more than 5 s after boot, unplug and replug after another 5 s or more, DPMS off/on, one s2idle, and 0 external DCP restart failed. One deep sleep with the monitor attached would be a good addition. If the wake now passes but the first connect times out, please post that part of the log: then we turn the idle stop off instead.

For this PR: #4040 does not change what you do here, and the three files both touch merge without conflicts. Nothing else is blocked by it. After #4040 is in, it still needs:

  • main merged in, with your J713 matrix at that head: dual -> single -> dual, disconnect and replug, more than 5 s idle before each re-bond, and DPMS off for more than 5 s in dual mode
  • the J773g single-pipe row from us
  • one approving review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:display Area from CODEOWNERS (bot) area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants