Skip to content

borealis: skip query-memory CDM streams in application self-cut prefix check - #1247

Merged
DjDeveloperr merged 1 commit into
aurora-wipfrom
fix/cdm-prefix-skip-stamp-streams
Nov 27, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-wipfrom
fix/cdm-prefix-skip-stamp-streams

Conversation

@DjDeveloperr

Copy link
Copy Markdown

Fixes the asahi - mesa:hk_sync_stamps line 1237 CI failure on aurora-wip caused by the interaction between #1213 (088f2038215) and #1235 (c454b390fe6).

What:

  • Scope cdm_waits_for_prefix() and cs_meets() in src/asahi/vulkan/hk_sync.c by the producer kinds that a self-cut compute barrier covers (previous_on_sq_kinds()).
  • In cs_reusable(), when checking application compute work against cmd->sync.req (which never names pure query-memory streams), walk back past pure HK_SYNC_STAMP and HK_SYNC_QRESET streams to the latest earlier HK_SYNC_ALL compute stream. This avoids gratuitously splitting an open compute stream after a leading timestamp carrier, timestamp copy stream, post-graphics query availability stream, or timestamp reset, while still splitting whenever an unwaited HK_SYNC_ALL compute stream sits behind them.
  • In hk_sync_get_cs_after() and non-application callers (HK_SYNC_STAMP / HK_SYNC_QRESET), keep checking HK_SYNC_STREAM_KINDS so query commands, events, and timestamp streams never drop dependencies on earlier stamp or reset streams.
  • Add regression unit tests in src/asahi/vulkan/tests/test-hk-sync-prior.c (test_compute_self_cut()) covering pure HK_SYNC_STAMP/HK_SYNC_QRESET predecessors, unwaited vs. waited HK_SYNC_ALL compute streams behind a stamp stream, and hk_sync_get_cs_after() with HK_SYNC_QUERY_SCOPE (normal and pinned).

Root cause:

  • borealis: order work after a compute barrier after earlier compute streams #1213 tightened cs_reusable() so a self-cut compute barrier keeps an open compute stream d0 only when d0 already waits for previous_on_sq(cmd, d0).
  • borealis: flush leading timestamps before opening a compute stream #1235 flushes a leading timestamp into a preceding pure HK_SYNC_STAMP carrier c0 before creating d0. Because application barriers never name HK_SYNC_STAMP, d0 does not wait on c0.
  • When test-hk-sync-stamps.c:1219 recorded a GFX | COMPUTE barrier after d0, cdm_waits_for_prefix(cmd, d0) saw c0 as an unwaited predecessor and ended d0, causing d1 != d0 and failing test-hk-sync-stamps.c:1237 (as well as gratuitously splitting compute chains following any pure HK_SYNC_STAMP/HK_SYNC_QRESET stream).

Tested:

  • Fedora 44 Mesa CI (./rig/fedora-mesaci.sh b3dba28a7a8d): 218/218 PASS, 0 fail, 0 warnings in touched files (hk_sync_stamps: 896 tests, 0 failures; hk_sync_prior: 3,784 checks, 0 failures).
  • MacBook Neo (J700, G17P B1, stock 7.3.0-41.fc44.aurora.aarch64, isolated overlay git-b3dba28a7a, stock.diff=0, kfaults GPU-side=0, avc_delta=0, recoveries=0):
    • gpubench-d3d12 --verify --test compute.conv2d --param kind=gaussian --param res=1080p --depths 1: PASS (1209.68 us/submit, gpu_us 1093.42 us, CRC 2d55a14d valid).
    • Vulkan CTS (deqp-vk): dEQP-VK.query_pool.occlusion_query.* (434/441 Pass, 7 Not supported, 0 Fail), dEQP-VK.query_pool.statistics_query.compute_shader_invocations.* (60/60 Pass, 0 Fail), dEQP-VK.query_pool.statistics_query.reset_before_copy.* (4,650/4,651 Pass, 1 Not supported, 0 Fail) — 5,144 Pass / 0 Fail total.

Risk: two-way · M3, M4, Neo, M5

Not yet:

  • gpubench-vk render.pass_chain kind=oq_bar on J700 (neohw was occupied by an ABBA run during follow-up) and hardware runs on M3, M4, and M5 (all four M5/G17P chip variants and exact-prior modes are covered by hk_sync_stamps and hk_sync_prior).

…x check

Commit 088f203 (#1213) changed cs_reusable() so a self-cut compute
barrier keeps an open compute stream only when that stream already waits
for its predecessor on the compute subqueue. Commit c454b39 (#1235)
then flushed leading timestamps into a preceding pure HK_SYNC_STAMP
carrier before opening a compute stream.

When an application compute stream follows a pure HK_SYNC_STAMP or
HK_SYNC_QRESET stream (such as a leading timestamp carrier, timestamp
copy stream, post-graphics query availability stream, or timestamp reset),
an application barrier never names those query-memory streams, so the
open compute stream does not wait on them. Treating them as unwaited
predecessors in cs_reusable() caused hk_sync_check_cs() to split the
compute stream on the first compute barrier, breaking
test-hk-sync-stamps.c:1237 and gratuitously splitting compute chains.

Scope cdm_waits_for_prefix() by the required producer kinds:
- For application work in cs_reusable(), walk back to the latest earlier
  HK_SYNC_ALL compute stream, ignoring pure HK_SYNC_STAMP and
  HK_SYNC_QRESET streams while still splitting whenever an unwaited
  application compute stream sits behind them.
- For hk_sync_get_cs_after() and non-application callers (query commands,
  events, and timestamp streams), keep checking HK_SYNC_STREAM_KINDS so
  dependencies on earlier stamp or reset streams are never dropped.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 17:25
@DjDeveloperr

Copy link
Copy Markdown
Author

J714s (MacBook Pro M5 Pro, G17S, kernel 7.3.0-m5-cdirect16, second generation) at exact head b3dba28a7a8d13be2bb96359a25fe935ee0861e3 against ef132f590b2: PASS

  • Build & unit tests: Clang 22.1.8 assert (-Db_ndebug=false, 0 warnings in touched files) and GCC release (-Db_ndebug=true) --suite asahi: 215/215 PASS each (hk_sync_stamps: 896/896, hk_sync_prior: 3,784/3,784).
  • gpubench-vk (--timestamps on): compute.conv2d (d=1 281.46 us, d=2 281.04 us) and render.deferred (d=1 301.63 us, d=2 281.50 us): 4/4 status=ok, all non-zero GPU timestamps.
  • Vulkan CTS (cts1471, 0 Fail):
    • dEQP-VK.query_pool.*: 19,236/19,276 PASS, 0 Fail (40 Not supported).
    • dEQP-VK.api.command_buffers.*: 126/131 PASS, 0 Fail (5 Not supported).
  • Health: boot=same, 0 kernel errors, 0 GPU faults.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Independent review at b3dba28a7a8d: LGTM, no blockers.

  • Splitting cdm_waits_for_prefix() / cs_meets() on prefix_kinds via previous_on_sq_kinds() cleanly separates reusable application compute streams (HK_SYNC_ALL, so pure HK_SYNC_STAMP/HK_SYNC_QRESET carriers do not force a split while any unwaited prior HK_SYNC_ALL compute stream behind them still splits) from hk_sync_get_cs_after() and stamp/query/reset callers (HK_SYNC_STREAM_KINDS).
  • Unit coverage in test-hk-sync-prior.c exercises both cases, Fedora CI is 218/218 PASS (hk_sync_stamps 896/896, hk_sync_prior 3,784/3,784), and both J700 (G17P) and J714s (G17S) exact-head verification rows passed with zero faults.

@RyanTheTide RyanTheTide 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 b3dba28a7a8d

Blockers: none

Checked:

  • This fixes the tip's red hk_sync_stamps from the #1213 x #1235 clash (bisect on #1235). Head merged into aurora-wip 78d817d9: local drm-shim gate 338 Ok / 0 Fail, against 337/338 at the tip, where only hk_sync_stamps fails.
  • Application compute (cs_reusable() with kinds lacking STAMP/QRESET) now checks its self-cut prefix only against earlier HK_SYNC_ALL compute streams. That is safe because:
    • HK_SYNC_STAMP streams write only query memory, which no application dependency names (hk_sync.h:98-106).
    • HK_SYNC_QRESET is used only for timestamp pool resets (hk_CmdResetQueryPool() sets kind_override = stamps ? HK_SYNC_QRESET : HK_SYNC_ALL, hk_query_pool.c:888). Occlusion and pipeline-statistics resets, which dispatches do write through, stay HK_SYNC_ALL and keep ordering every later dispatch.
  • Query commands, events and timestamps keep the full HK_SYNC_STREAM_KINDS prefix: the kinds & (STAMP|QRESET) path, plus hk_sync_get_cs_after() and the pinned-stream re-cut, which pass HK_SYNC_STREAM_KINDS explicitly.
  • previous_on_sq_kinds() walks the same list as previous_on_sq() with a kind filter. An unwaited HK_SYNC_ALL stream behind a stamp stream still forces the split (new test_compute_self_cut() cases).

Rows: shared sync code. A J700 row plus another generation at this head, then merge.

@DjDeveloperr
DjDeveloperr merged commit cb40d46 into aurora-wip Nov 27, 2026
@DjDeveloperr
DjDeveloperr deleted the fix/cdm-prefix-skip-stamp-streams branch November 27, 2026 18:00
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.

2 participants