Repository navigation
drm/apple: update adaptive sync on an installed firmware-27 pair - #3113
Conversation
The same 4K240 timing and color can be installed twice when a paired display returns after resume. The second commit changes only the adaptive-sync minimum. It rebuilds both engines and blocks the compositor for almost another second. Keep a working pair when the installed timing, color and HDR state still match, and send the existing adaptive-sync parameter to both engines. Preserve the frame completion state. A command failure falls back to the full installation, as do changes to the installed mode. Signed-off-by: Diljit Singh <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf — reviewed cdfa82f58037 (MERGEABLE, kunit / readiness / pr-text SUCCESS).
Verdict
REQUEST_CHANGES at cdfa82f58037 — the fast adaptive-sync update idea and host test look clean, and the behavior is properly board-agnostic across active firmware-27 pairs, but there is a lock-drop TOCTOU race in dcp_peer_modeset_v27() when committing the vrr_only fast path.
Blocker
- Stale
modeset_complete/ peer-state check after droppingdcp_peer_lock(drivers/gpu/drm/apple/dcp-peer-runtime-v27.inc:148-171):- At lines
148-151,vrr_onlychecksdcp->peer_tiling.modeset_complete && peer->peer_tiling.modeset_complete && dcp_peer_vrr_only_v27(...)while holdingdcp_peer_lock. dcp_peer_lockis then released at line152across the blockingdcp_peer_param_v27(dcp, peer, 15, 3, min_vrr)RPCs to both engines (line162).- While
dcp_peer_lockis unlocked, a concurrentdcp_peer_hints_v27()->dcp_peer_release_locked(dcp)callback (drivers/gpu/drm/apple/dcp-peer-v27.inc:156-162, which takes onlydcp_peer_lock, notdevice_lock(dcp->dev)) can cleardcp->peer_tiling.modeset_complete = falseandpeer->peer_tiling.modeset_complete = falsewithout clearingdcp->peer_frames.activeor settingdcp->peer_frames.failed(and the platform limit orpeer_reserved/peer_ownerstate can also change while unlocked). - At lines
163-170, the post-RPCguard(mutex)(&dcp_peer_lock)block re-checks onlydcp_peer_vrr_only_v27(&dcp->peer_frames, ...), omittingdcp->peer_tiling.modeset_complete && peer->peer_tiling.modeset_complete,dcp->peer_reserved == peer && peer->peer_owner == dcp, and!dcp_peer_limited_pair_locked(dcp, &prepared). - If
dcp_peer_release_locked()ran duringdcp_peer_param_v27(),dcp_peer_modeset_v27()still returns0claiming the pair is ready, after whichdcp_peer_scanout_v27()(dcp-peer-runtime-v27.inc:333-336) returns-EIOon the next swap becausemodeset_completeisfalse, instead of falling through to rebuild the pair (or stopping it if limited). - Fix: Inside the post-RPC
dcp_peer_locksection (dcp-peer-runtime-v27.inc:163-170), also re-verifydcp->peer_reserved == peer && peer->peer_owner == dcp && dcp->peer_tiling.modeset_complete && peer->peer_tiling.modeset_complete(and handle a newly active platform limit viadcp_peer_limited_stop_v27()rather than falling through todcp_peer_prepare_v27()).
- At lines
What Looks Good
dcp_peer_vrr_only_v27()(dcp-peer-frames-v27.h:17-24) cleanly checksactive && !failed,timing,color,output_hdr, andmin_vrr != min_vrr, with clean host unit-test coverage intools/asahi/dcp-peer-shown-tests.py.- Reuses parameter
15(A450) and falls back cleanly to the fulldcp_peer_prepare_v27()/dcp_peer_install_video_v27()rebuild if either engine rejects the update. - Commit carries a valid
Signed-off-bytrailer.
dcp_peer_modeset_v27() drops dcp_peer_lock across the blocking dcp_peer_param_v27() calls to both engines. While unlocked, dcp_peer_release_locked() or a platform-limit change can clear modeset_complete, release the peer reservation, or impose the pair limit without clearing peer_frames.active. Re-verify peer ownership, platform limit, and both engines' modeset_complete flags under dcp_peer_lock after dcp_peer_param_v27() returns. Return -EBUSY if ownership was lost, stop a newly limited pair outside dcp_peer_lock via dcp_peer_limited_stop_v27() (or return -EOPNOTSUPP if already unprepared), and otherwise fall through to the full pair rebuild when the fast path is no longer valid. Signed-off-by: Diljit Singh <hey@djdev.me>
|
@satchlj Addressed the lock-drop TOCTOU race in |
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf
Verified 9fa8c0838f8c (drm/apple: recheck paired DCP state after adaptive-sync RPC) against the dcp_peer_modeset_v27() lock-drop TOCTOU race:
- All race windows closed (
drivers/gpu/drm/apple/dcp-peer-runtime-v27.inc:162-193): Afterdcp_peer_param_v27()returns,dcp_peer_modeset_v27()now re-acquiresdcp_peer_lockand re-verifiesstill_owned(dcp->peer_reserved == peer && peer->peer_owner == dcp),limited(dcp_peer_limited_pair_locked(dcp, &prepared)), both engines'peer_tiling.modeset_completeflags, anddcp_peer_vrr_only_v27(...). - Fallback paths: Lost ownership returns
-EBUSY; a newly platform-limited pair stops cleanly outsidedcp_peer_lockviadcp_peer_limited_stop_v27(dcp, peer)whenprepared(or returns-EOPNOTSUPPotherwise); any other RPC failure or invalidated fast-path state falls through to the fulldcp_peer_prepare_v27()pair rebuild. - CI (
9fa8c0838f8c):kunit,host-tests,readiness, andpr-textstill pending (host-tests=in_progress/-). Code looks solid — holding formalAPPROVEstrictly until remaining CI checks finish green.
satchlj
left a comment
There was a problem hiding this comment.
Gemini 4 Neon on @satchlj's behalf
All CI checks (kunit, host-tests, readiness, pr-text) are now green on 9fa8c0838f8c, confirming the dcp_peer_modeset_v27() lock-drop TOCTOU fix cleanly resolves the prior review comment.
LGTM — approving.
…ve-sync Signed-off-by: Diljit Singh <hey@djdev.me>
|
Tested: J714s (T6050),
Each wake performed one full paired modeset, then programmed the 48 Hz minimum on both DCP engines in the timed update. Both wakes reported the RTC source. The suspend success counter advanced from 0 to 2 and the failure counter stayed at 0. The RTC read six seconds past its alarm on return from each cycle. DP-5 settled at 239.996 Hz on both wakes. Wi-Fi was associated by the +8.1 s sample on both. On cycle 1 the Dell DP-2 used its known USB3 replug recovery and was enabled again at +9.083 s. Both settled USB and Thunderbolt inventories matched their pre-sleep snapshots. Vulkan enumeration and compute dispatch passed before and after each sleep, and WD2 remained armed. The two wake windows logged 12 and 9 error-priority messages, respectively, all matching baseline signatures (DCP provider clock, PCI power state, MMC and HID). Native arm64 warm build, Restored The previous head failed the native G16 build at |
Risk: two-way · Reverting this commit restores full paired modesets for adaptive-sync changes. A rejected firmware command still takes the full modeset path.
What: Keep an installed firmware-27 display pair when the timing, color and HDR state still match and only the adaptive-sync minimum differs. Send the existing adaptive-sync parameter to both engines and preserve their frame completion state. Both engines must have completed their modesets. This applies to an active pair regardless of board.
Tested: J714s (T6050),
b976c78a5b2d584c4ca79f850cd194b9bb60dff1— PASS, 2/2 consecutive RTC0 +25 s deep-sleep wakes with DP-5 at 3840×2160/240 Hz. The second paired adaptive-sync update took 0.769 ms and 1.021 ms (baseline 881–897 ms). All three outputs, GPU compute, Wi-Fi, TB5/USB and WD2 returned. Zero new kernel error signatures and zero GPU faults. Hardware row.Earlier comparison at
cdfa82f58037. On J714s with the paired Samsung 4K240 output, each of five baseline wakes installed the same pair twice when the compositor enabled adaptive sync. The second install took 881–897 ms. One verification wake with this change used one full install and an adaptive-sync update under 3 ms. The longest sampled Hyprland IPC round trip during DP-5 setup fell from 1.804 s to 0.885 s. RTC0 +25 s woke from deep sleep, all three displays returned, GPU compute passed, Wi-Fi reassociated, and the TB5/USB dock and WD2 returned. Both builds used the same temporary G16 compile correction for the unrelated main build break. This PR contains only the paired-display change and its host regression test.Native arm64 build passed. The paired-display host test passed with ASan and UBSan. Strict checkpatch reported 0 errors, 0 warnings, 0 checks.
Signed-off-by: Diljit Singh hey@djdev.me