Repository navigation
iommu/apple-dart, drm/apple: t8132: dual-pipe peer bonding for high-pixel-rate external displays - #3454
iommu/apple-dart, drm/apple: t8132: dual-pipe peer bonding for high-pixel-rate external displays#3454stango-git wants to merge 6 commits into
Conversation
…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>
satchlj
left a comment
There was a problem hiding this comment.
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-safeallocatedaccounting, andAPPLE_DART_DISPEXT_GATEDgating 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 -> 2upward-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.
- Commit 1 (
- 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: duplicateSigned-off-byline in9f541f763and one 101-columndev_errline atdrivers/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,125120x2160@165 Hz hardware verification is covered in the PR description).
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
The merge-base changed after approval.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Verdict: FIX, then re-review at 358830a0849b
Blockers:
- Missing
peer_stop_workcancellation on unbind (drivers/gpu/drm/apple/iomfb_m4.c/dcp-m4-peer.inc):dcp_m4_peer_schedule_stop()callsschedule_work(&dcp->peer_stop_work)after releasingdcp_m4_peer_lock, whiledcp_m4_peer_forget()only setsdcp->peer_unbinding = trueandiomfb_m4_quiesce()only cancelsdcp->backlight_work— neverdcp->peer_stop_work. Ifpeer_stop_workis pending or scheduled around unbind,dcp_m4_peer_stop_work()can run afteriomfb_m4_quiesce()returns and dereference freeddcp(&dcp->lock,dcp->runtime,dcp_m4_peer_release(dcp)). Guardschedule_work(&dcp->peer_stop_work)againstdcp->peer_unbindingunderdcp_m4_peer_lock(or usedisable_work_sync(&dcp->peer_stop_work)) and cancel/flush&dcp->peer_stop_workiniomfb_m4_quiesce(). - Unpinned
struct iomfb_m4 *peerdereferenced across lock drops (drivers/gpu/drm/apple/dcp-m4-peer.incandiomfb_m4.c):- In
dcp_m4_peer_get_locked(),peeris loaded fromdcp->peer_reservedunderdcp_m4_peer_lock, thendcp_m4_peer_lockis released with no reference held onpeerbeforemutex_lock_nested(&peer->lock, SINGLE_DEPTH_NESTING). Ifpeerunbinds and frees in that window, taking&peer->lockis a use-after-free. - In
iomfb_m4_ext_sleep_down(), both&peer->lockand&dcp->lockare released around a 1-secondwait_event_timeout(peer->ext_settle_wq, ...)and re-acquired onpeerwithout holding any lifetime reference onpeer. - Hold a lifetime reference on
peer(for exampleget_device(peer->dev)/ akrefonstruct iomfb_m4) acquired underdcp_m4_peer_lockbefore dropping it, paired with adcp_m4_peer_put_locked()helper for every caller.
- In
- Prior
9f541f76items still open:358830a0mergedmaincleanly (#3258included), 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
358830a0849bagainstmain(#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()): callsdcp_m4_peer_forget(dcp); dcp_m4_failed(dcp, -ENODEV); cancel_work_sync(&dcp->backlight_work);without cancellingdcp->peer_stop_work.drivers/gpu/drm/apple/dcp-m4-peer.inc(dcp_m4_peer_get_locked()): releasesdcp_m4_peer_lockbeforemutex_lock_nested(&peer->lock, SINGLE_DEPTH_NESTING)with no refcount/device pin onpeer.drivers/gpu/drm/apple/iomfb_m4.c(iomfb_m4_ext_sleep_down()): unlocks&peer->lockand&dcp->lockacrosswait_event_timeout(peer->ext_settle_wq, ...)and re-locks&peer->lockwith no refcount/device pin onpeer.
|
(Note: this answered the earlier Addressed the earlier
@satchlj please hold off on re-review for now — pushing a follow-up commit to address the |
…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>
There was a problem hiding this comment.
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.
|
Standalone current-head hardware row at
PR body updated with the |
There was a problem hiding this comment.
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
DjDeveloperr
left a comment
There was a problem hiding this comment.
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-testswasg17-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-sideoobclear) 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.
|
Merge-up check against current main: the textual conflict is small. In |
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>
|
I merged main ( 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 (
Checks at this head:
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:
If you want any of this done differently, change it as you like. |
|
@DjDeveloperr Tested Host tests: What happened on hardware
Root-cause notes
Happy to work on a fix patch, test it on this |
|
Thank you, this report and its log were enough to find it: #3321 broke this on main, not your PR. The extra-looking 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 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:
|
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). Mergedmain(c3fbd2361475, which includes #3258) at358830a0849band added peer lifetime pinning +peer_stop_workunbind teardown atb21a5c532a0cso the diff againstmaincontains 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:
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) on7.3.0-dp-b21a5c532+: PASS — cold boot straight into dual-pipe5120x2160@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->@60single ->3840x2160@144single ->5120x2160@165dual), DPMS off/on (paired DRM modeset ... kept), and two consecutive USB-C disconnect/replug cycles including rapid unplug/replug with overlappingdcp_dptx_disconnect/ pendingpeer_stop_work(peer stop on disconnect: 0+ clean re-reservation and recovery to5120x2160@165 Hz);0DART faults,0frame not shown,0refcount/UAF/kernel oops/WARN,0failed systemd units.b21a5c532a0c:tools/asahi/run-host-tests.py—apple-dart-dispext-window6/6 pass (includingpeer-allow-same-dart),apple-dcp-m4-peer3/3 pass (width-only+no-concurrent-oob),apple-dart-isp-host1/1,apple-dart-range1/1,apple-dart-fw2/2;tools/testing/selftests/drivers/gpu/apple-dcp/run.py --group m49/9 pass (includingm4-notch-frame).b21a5c532a0c:LLVM=1 W=1build ofdrivers/gpu/drm/apple/iomfb_m4.oand fullImage+ modules + BTF (7.3.0-dp-b21a5c532+) succeeded with 0 warnings/errors;scripts/checkpatch.pl --strict --no-treeonb21a5c532a0c: 0 errors, 0 warnings, 0 checks.5120x2160@165 Hzand 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, internaldisp0, and non-T8132 Macs untouched.Not yet:
mem/deep) resume at high-pixel-rate dual-pipe external modes (5120x2160@120/165 Hz) depends on companion PMC PR pmdomain: apple-pmc: restore display interface enables after deep sleep #3452 — firmware deep sleep clears PMCbwr_enable(0x2020) and resetsboost_enable(0x2028), leaving external pipes at minimum display clock on wake (scanout underrun at 165 Hz without pmdomain: apple-pmc: restore display interface enables after deep sleep #3452). Suspend-entry peer teardown/unpair is handled by iommu/apple-dart, drm/apple: t8132: dual-pipe peer bonding for high-pixel-rate external displays #3454, and single-pipe<= 60 Hzdeep sleep does not depend on pmdomain: apple-pmc: restore display interface enables after deep sleep #3452 (already verified at5120x2160@60 Hzin iommu/apple-dart, drm/apple: support 64 MiB T8132 external scanout up to 5120x2880 #3258).Details & Provenance
Clean provenance for single-pipe limits and wire fields
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,840active px/s, matching the public M4 6K@60 Hz single-pipe external display spec) verified directly against live T8132 firmwareSetHints/A364enumeration on J713 + Dell AW3926QW: modes at or below1,274,019,840active px/s (5120x2160@60 Hz=663,552,000px/s,3840x2160@144 Hz=1,194,393,600px/s) reportrequires_merge=0and run single-pipe, while modes above it (5120x2160@120 Hz=1,327,104,000px/s,5120x2160@165 Hz=1,824,664,387px/s) reportrequires_merge=1in A364 and require a peer pipe. Unlike non-compact firmware-27 services (dptxep.c:dptxport_init_props()), T8132 compact AFKdispext0:dcpdptx-port-epic:0does not emitMaxPixelWidth/MaxActivePixelRateinit properties, so the chip ceiling is defined indcp-m4-peer.h.main):struct dcp_display_hints(160 B,hints[0],+0x38width,+0x3cheight,+0x40total,+0x44active,primary_id/peer_id/extra_pipes/flags/status) andstruct dcp_peer_tiling+dcp_peer_tiling_get()/set()(D115/D116): directly included fromdrivers/gpu/drm/apple/dcp-peer-v26_6.handdrivers/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/A365video_data(0x50timing +0x20color;0x7c/0x74req/resp): mirrored directly fromdrivers/gpu/drm/apple/dcp-peer-v26_6.inc.A360/A361,A362,A364,A365,A366,A367–A373,A406/A407,A413,A473,D115/D116,D575,D590): identical to existingdrivers/gpu/drm/apple/dcp-peer-v26_6.inc,drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc, anddrivers/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 existingdcp_m4_swap_encode_on()indrivers/gpu/drm/apple/dcp-m4-frame.h.Commit breakdown
5bc08061c(iommu/apple-dart: map retained dispext SID0 scanout surfaces into a peer DART): Addapple_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; extendtools/asahi/apple-dart-dispext-window-tests.py+run-host-tests.pywithpeer-allow-same-dartmutation.9f541f763(drm/apple: t8132: bond idle external DCP peer for high-pixel-rate modes): WireDPTX_APCALL_SET_TILED_DISPLAY_HINTSupward-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; addtools/asahi/apple-dcp-m4-peer-tests.py.358830a08(Merge remote-tracking branch 'origin/main' into feat/t8132-dcpext-dual-pipe): Mergemain(c3fbd2361475, containing iommu/apple-dart, drm/apple: support 64 MiB T8132 external scanout up to 5120x2880 #3258); onlytools/asahi/run-host-tests.pyconflicted and kept both main'sapple-dart-isp-host-tests.pyand this PR's test entries.b21a5c532(drm/apple: iomfb_m4: pin peer lifetime across lock drops and disable peer_stop_work on unbind): Guardschedule_work(&dcp->peer_stop_work)underdcp_m4_peer_lock, calldisable_work_sync(&dcp->peer_stop_work)iniomfb_m4_quiesce(), and pinstruct iomfb_m4(kref) +peer->dev(get_device()) acrossdcp_m4_peer_get_locked()/iomfb_m4_ext_sleep_down()lock drops, released viadcp_m4_peer_put_locked()at all callers.Evidence
tools/asahi/run-host-tests.py) atb21a5c532a0c:apple-dart-dispext-window: 6/6 passedapple-dcp-m4-peer: 3/3 passedapple-dart-isp-host: 1/1 passed;apple-dart-range: 1/1 passed;apple-dart-fw: 2/2 passedtools/testing/selftests/drivers/gpu/apple-dcp/run.py --group m4) atb21a5c532a0c: 9/9 passed (includingm4-notch-frame).