Skip to content

drm/syncobj: walk bypassed signaled chain predecessors for direct wait - #3406

Merged
RyanTheTide merged 1 commit into
mainfrom
fix/syncobj-direct-wait-bypassed-prev
Dec 1, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
fix/syncobj-direct-wait-bypassed-prev

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What

When drm_syncobj_direct_wait_fence() unwraps a timeline point to its contained fence, the dma_fence_chain wrapper itself never has dma_fence_signal() called on it. On the next consecutive depth-1 submit, checking only DMA_FENCE_FLAG_SIGNALED_BIT on chain->prev sees an unset bit even though prev->fence and all earlier nodes are already signaled. As a result, every other consecutive depth-1 timeline wait (50%) falls back to a wrapped chain wait and fires a dma_fence_chain_irq_work self-IPI (irq=6), moving completion wakeups into hard-IRQ context.

Add drm_syncobj_chain_prev_signaled() to walk chain->prev using only monotonic DMA_FENCE_FLAG_SIGNALED_BIT checks (bounded to 8 hops, no driver callbacks, safe under syncobj->lock), so already-complete bypassed chain wrappers continue to allow direct waits. Add KUnit tests covering consecutive depth-1 sequences, unsignaled predecessors, and the bounded depth limit.

Tested

  • KUnit (drm_syncobj_direct_wait): 3/3 passed (0.083s) on exact head 924f87dc08ec4:
    • drm_syncobj_test_direct_wait_depth1_sequence
    • drm_syncobj_test_direct_wait_unsignaled_prev_stays_chain
    • drm_syncobj_test_direct_wait_deep_chain_bounded
  • Exact-head 4-boot BAAB on MacBook Neo (J700, T8140 / G17P B1), fca33ed67eb81 vs 924f87dc08ec4 (Mesa 30df6feb98f):
    • ftrace (A2 vs B2, 25 ms): dma_fence_chain IRQ_work self-IPIs dropped from 100/199 (50.3%) to 0/185 on render.light d1, and 117/234 (50.0%) to 0/233 on compute.light d1 (100% task-context completion wakeups).
    • gpubench-vk (4-boot BAAB means, all status=ok):
      • default compute.light d1: 112.08 -> 104.23 us (-7.85 us, -7.0%, med 105.1 -> 101.0, p95 123.7 -> 115.5)
      • u1024 render.light d1: 105.09 -> 101.85 us (-3.23 us, -3.1%, med 78.5 -> 74.4)
      • u1024 compute.light d1: 106.20 -> 104.38 us (-1.82 us, -1.7%, med 104.4 -> 101.2)
      • policy0=4044MHz render.light d1: 78.92 -> 76.19 us (-2.73 us, -3.5%, med 75.2 -> 72.4)
      • render.light d2/d4/d8, compute.light d4: -0.2% to -0.9%
      • Controls (render.deferred, render.postfx, compute.heavy d1/d4): flat (-0.2% to +0.3%)
    • Geekbench 6.7.1 Vulkan (n=4 per arm): 84.14s -> 84.06s (-0.08s, -0.10%, no regression).
    • Vulkan CTS (B2): dEQP-VK.synchronization.basic.* 29/29 PASS, dEQP-VK.synchronization2.basic.* 26/26 PASS, dEQP-VK.compute.pipeline.basic.* 80/81 PASS (1 NotSupported, 0 failed).
    • Health / Idle: pre-load idle settles to P=744 MHz, E=816 MHz; 0 GPU faults, 0 SELinux AVCs, 0 new kernel errors across all 4 boots.

Risk

Risk: two-way · J700, J714s.

Low. drm_syncobj_chain_prev_signaled() only reads the monotonic DMA_FENCE_FLAG_SIGNALED_BIT, invokes no driver ->signaled callbacks, holds no extra locks beyond brief RCU reads, and caps traversal at 8 predecessors before conservatively returning the wrapped chain fence.

Not yet

  • Tested on J700 (T8140) and UML KUnit only; not separately benchmarked on M3/M4/M5 hardware.
  • Under synthetic policy0/scaling_min_freq=4044000, compute.light d1 on J700 shifts 98.37 -> 107.30 us because 100% task-context wakeups allow upstream WAKE_SHORT_LOCAL to keep the waiter on cpu0 (c2d = 10 us vs 13 us on cpu5), which independently reproduces via taskset -c 0 even with NO_WAKE_SHORT_LOCAL due to G17P compute firmware db->irq timing at c2d = 10 us. Default and u1024 compute.light d1 both improve cleanly.

When drm_syncobj_direct_wait_fence() unwraps a timeline point to its
contained fence, the dma_fence_chain wrapper itself never has
dma_fence_signal() called on it. On the next consecutive depth-1 submit,
checking only DMA_FENCE_FLAG_SIGNALED_BIT on chain->prev sees an unset
bit even though prev's contained fence and all earlier nodes are already
signaled, falling back to a wrapped chain wait and firing a
dma_fence_chain irq_work self-IPI on every other submit.

Walk chain->prev using only monotonic DMA_FENCE_FLAG_SIGNALED_BIT checks
(no driver callbacks, bounded to 8 hops, safe under syncobj->lock) so
already-complete bypassed chain wrappers still allow direct waits.

Add KUnit tests covering consecutive depth-1 timeline sequences and
unsignaled predecessors.

Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 15:57

@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: HOLD at 924f87dc08ec

Blockers: Hosted CI and a second GPU-family regression covering overlapping timeline waits.

Checked: Code approved by inspection. The walk takes a reference on the predecessor before dropping the current wrapper and consumes the input reference on every exit. It uses monotonic signal bits and keeps the chain on ambiguous or over-limit walks. The exact-head KUnit 3/3 and J700 results are author-reported.

Evidence

Reviewed PR source and recorded results at 924f87dc08ec.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Second-generation hardware verification on J714s (Apple M5 Pro / G17S B1) at exact head 924f87dc08ec4297d3a6637091adb84233df35b3 (7.3.0-m5-pr3406, origin/main DTB, Mesa inst-A 8643d38a0c91): PASS.

  • gpubench-vk (3 x 500 ms):
    • compute.light (d1): ok, us_per_submit median 162.65 us, latency_us median 153.80 us (n=9261), gpu_us 3.25 us.
    • render.light (d1): ok, us_per_submit median 180.25 us, latency_us median 173.96 us (n=8337), gpu_us 7.04 us.
    • sync.signal (kind=host, work=compute.light, d1): ok, latency_us median 125.11 us (p5 119.95, p95 129.53, n=4592).
    • sync.signal (kind=queue, work=compute.light, d2): ok, us_per_hop median 17.52 us (p5 17.40, p95 17.77).
  • VK CTS (deqp-vk 1.4.7.1): 1,922/1,922 PASS, 0 Fail:
    • dEQP-VK.synchronization.smoke.*: 12/12 PASS
    • dEQP-VK.synchronization.timeline_semaphore.one_to_n.*: 955/955 PASS
    • dEQP-VK.synchronization.timeline_semaphore.wait_before_signal.*: 955/955 PASS
  • Health: online=1, crashed=0, quarantined=0, fw_inputs converted=106193 published=106193, 0 GPU faults / kernel WARNs / errors. Clean restore to default 7.3.0-m5-cdirect16 verified (253/253 ESP hashes, LIVE vulkaninfo=1 dispatch=1 kernel=ok).

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 924f87dc: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text, KUnit asahi, KUnit spi-hid-apple, KUnit avd, KUnit ave, KUnit isp
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 924f87dc
Conflicts ok none
PR text ok Risk: two-way · J700, J714s. Low. drm_syncobj_chain_prev_signaled() only reads the monotonic DMA_FENCE_FLAG_SIGNALED_BIT, invokes no driver ->signaled callbacks, holds no extra locks beyond brief RCU reads, and caps traversal at 8 predecessors before conservatively returning the wrapped chain fence.

Areas: none matched in CODEOWNERS

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 924f87dc08ec (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at 924f87d that the readiness check found (PR body or comment). CI: linux train L4 = main (after L3) + 34 approved PRs (#3419 dropped: conflicts): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit ane-boot/clpc/ane-pm/dcp-fabric/dcp-topology/dcp-display/macaudio/asahi/sep all pass, host tests apple-dcp + apple-scaler-recovery pass (the red host-tests on some heads were base failures since fixed on main). The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 2b5fec5 into main Dec 1, 2026
27 of 41 checks passed
@RyanTheTide
RyanTheTide deleted the fix/syncobj-direct-wait-bypassed-prev branch December 1, 2026 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-failing A check failed at the PR head (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.

2 participants