Skip to content

drm/asahi: g17: do not host-wait query_access on timestamp-free chains - #3319

Merged
RyanTheTide merged 1 commit into
mainfrom
fix/g17-query-access-no-ts-waits
Nov 28, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
fix/g17-query-access-no-ts-waits

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What

When a G17 command without host-timestamp outputs chains its Publication behind an earlier timestamp-writing command, its Publication stays pending while both commands are queued ahead of GPU execution. EnqueueOrdering::build() previously treated every covered pending Publication as a host completion wait for query_access compute commands, forcing those computes to stall on the host for every intermediate timestamp-free render or compute instead of only the actual timestamp-writing ancestors.

Track the deduplicated pending timestamp-writer completion fences inherited by timestamp-free commands (timestamp_writers), wait on the host only for those actual timestamp writers, and keep intermediate timestamp-free producers on firmware barriers. This matches native overlap: query_access computes only drain on the host for commands that actually publish host timestamps, rather than draining the whole render/compute pipeline on every query copy.

Tested

  • Host verification:
    • ./scripts/checkpatch.pl --strict --git origin/main..HEAD: 0 errors, 0 warnings, 0 checks.
    • python3 tools/asahi/run-host-tests.py --only g17: 220/220 passed.
  • J714s (Apple M5 Pro, G17S, native 3024x1964, GP_NOANAT=1, identical Mesa kit inst-K libvulkan_asahi.so 1cf23c9f22d5):
    • Vulkan CTS (deqp-vk 1.4.7.1) on 97fe64450656 (rebased on origin/main 2094ccb2a036):
    • GTA V benchmark Pass 4 FPS (0 GPU faults, 0 kernel errors across all runs):
      • origin/main baseline (7.3.0-m5-hops1): 41.24, 41.41 (mean 41.33).
      • Candidate (NO_TS, 3 runs across 2 boots: 50.17, 51.51, 49.89, mean 50.52): +22.2% mean (+24.6% peak) over origin/main.
      • 24 MHz GPU hop instrumentation: GTA V GPU union busy rose from 71.42% to 89.31% (+17.89 pp); 83% of query_access computes (5,587/6,735) overlap via firmware barriers (R->C HOST WAIT median +208.3 us -> -1,425.6 us).
    • BeamNG wcusa steady-state windows 2–5 FPS (0 GPU faults, 0 kernel errors):
      • origin/main baseline: 34.79 mean (34.50 / 35.33 medians).
      • Candidate (NO_TS): 35.87 mean (35.92 / 35.86 medians, +3.1% over origin/main, GPU union busy 91.82%).

Risk

Risk: two-way · G17 scheduler ordering (drivers/gpu/drm/asahi/g17/completion/publication.rs, job.rs, queue/mod.rs); no UAPI or firmware ABI changes, single-commit revert cleanly restores previous host-wait behavior.

Not yet

  • Follow-up retirement optimization (latched compute retirement + granular work-state splitting) to eliminate remaining host-side retirement latency is tracked separately.

When a command without timestamp outputs chains its host Publication
behind an earlier timestamp-writing command, its Publication stays
pending while both are still queued ahead of GPU execution.
EnqueueOrdering::build previously treated every covered pending
Publication as a host completion wait for query_access computes,
forcing the compute to wait on the host for every intermediate
timestamp-free render or compute instead of only the actual
timestamp-writing ancestors.

Track the deduplicated pending timestamp-writer completion fences
inherited by timestamp-free commands, wait on the host only for those
actual timestamp writers, and keep intermediate timestamp-free
producers on firmware barriers so query_access computes do not drain
the GPU pipeline.

Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 26, 2026 21:59
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 97fe6445: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text, pr-text / pr-text
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 97fe6445
Conflicts ok none
PR text ok Risk: two-way · G17 scheduler ordering (drivers/gpu/drm/asahi/g17/completion/publication.rs, job.rs, queue/mod.rs); no UAPI or firmware ABI changes, single-commit revert cleanly restores previous host-wait behavior.

Areas: area:gpu

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

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at 97fe64450656: ready (code). The second-generation row (J700, G17P) is still owed before merge; see below.

Blockers: none.

Checked

  • Host timestamps are still written before a query_access compute runs. The host waits exist because a query_access compute can read or reset query words whose host timestamp write is still pending.
    • A timestamp writer's completed fence is the Output fence. Output::publish() runs destinations.write(ticks) before fence.signal(), and a writer's publication itself waits for its predecessors.
    • So a host wait on each pending writer's completed covers every host write the old wait on the chained command covered.
  • The inherited writer list is complete.
    • collect_timestamp_waits() takes an entry's own completed when it writes timestamps. Otherwise it takes the writers it inherited at enqueue that are still pending or failed (fence_status <= 0), deduplicated by fence pointer.
    • It is collected for every entry pushed as a predecessor in both the same-engine and cross-engine chain loops, so the list is transitive through timestamp-free chains (A → B → D gives D {A}).
    • A command that writes its own timestamps stores None.
    • A chain whose predecessors all published cleanly is no longer pending (upstream_released), so it drops out on its own.
  • GPU-side ordering is kept.
    • Cross-engine. A timestamp-free producer that the query_access compute used to wait on from the host now gets a firmware wait (scheduled, completed), so a render's GPU query writes still land before the compute.
    • Same engine. Such an entry relies on in-order execution of the ring, like any other covered same-engine command did before. A timestamp-free compute writes no query words of its own.
    • Explicit host waits. host_waits and timestamp writers keep the full host wait.
    • No silent downgrade. With host_waits false, cross_engine_wait_completed() is only true for an entry with a pending publication, so the new branch can't turn a needed host wait into nothing.
  • Failed producers. The new early status < 0 → host wait branch for cross-engine entries doesn't change the outcome. enqueue() already adds the earliest failed command in range of either engine as a checked host dependency.
  • Lifetime. Fences::timestamp_waits holds refcounted Fences in an Arc<KVec<_>> that lives as long as the frontier entry. Nothing here touches a packet, lease or VM pin, and nothing waits or allocates on the completion path.
  • Tests.
    • The new KUnit case checks that a query_access compute covering A (writer) and B (timestamp-free, chained) host-waits only A and firmware-waits B. The updated case now expects the writer's fence.
    • Putting back the old host wait on the chained producer in the cross-engine branch fails the new case.
  • Text. The commit and PR text are neutral and carry no attribution. checkpatch --strict gives 0/0/0.

Before merge

  • J700 (G17P) row. This is shared G17 code, so the second-generation row is required, and "Not yet" doesn't list it yet. The query_pool and multiview.queries CTS subsets plus a game or benchmark that copies queries would cover it.
  • CI. The KUnit asahi and build jobs were still pending at this head when I checked.
  • PR text. Tested says the CTS ran on "97fe64450656 (rebased on origin/main 2094ccb2a036)". The head's parent is 8e2ee15f3ca3, not 2094ccb2a036; it merges cleanly with 2094ccb2a036. Please state which commit the rows actually ran on.
  • Host tests. The 220 g17 host tests don't exercise EnqueueOrdering. The Rust KUnit suite is what covers this change.
Evidence
97fe6445065696ec1339d03a3dd65362a204ef90 (parent 8e2ee15f3ca3), merges cleanly with main 2094ccb2a036

tools/asahi/run-host-tests.py --only g17      -> 220/220 passed
scripts/checkpatch.pl --strict -g HEAD~1..HEAD -> 0 errors, 0 warnings, 0 checks

kunit.py run --arch=arm64 --make_options LLVM=1 --kconfig_add CONFIG_WERROR=n \
  --kunitconfig=drivers/gpu/drm/asahi/.kunitconfig
  head: asahi_g17_cross_engine_timestamps (8 subtests) PASSED, including
        query_access_waits_only_on_timestamp_writer_not_timestamp_free_chain and
        settled_timestamp_free_publication_drops_contagion_and_host_waits
        Testing complete. Ran 464 tests: passed: 460, skipped: 4
  mutation (cross-engine branch host-waits the chained producer's completed, as before):
        query_access_waits_only_on_timestamp_writer_not_timestamp_free_chain FAILED
        (queue/mod.rs:1471, "Expected plan_c.host_waits.len() == 1")
        Testing complete. Ran 464 tests: passed: 459, failed: 1, skipped: 4

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo, G17P B1) at 97fe64450656, against base main 2094ccb2a036: PASS. Every case that doesn't pass on this head gives the same result on the base, so there are 0 new failures, and gpubench CRCs are clean.

  • Setup:
    • One-shot boots of kernels built from the Neo's 7.3.0-41 config. The running build ID matched the vmlinux built from each SHA: 47575dbccad0 for the head, 25c2e91f4061 for the base.
    • System Mesa 26.3.0-30, headless.
    • Three head boots and two base boots, each back to stock 7.3.0-41 afterwards.
  • dEQP-VK.query_pool occlusion, concurrent and statistics queries, copy_* included (19,218 cases): 19,206 Pass, 12 NotSupported, 0 Fail.
  • dEQP-VK.multiview.*quer* (796 cases): 721 Pass and 3 NotSupported on the head. The other 72 differ by how they are run, the same way on both kernels:
  • Sync smoke (synchronization*): 3,004 cases, 0 Fail.
    • timeline_semaphore (1,464), plus synchronization2.basic and smoke (36): all Pass.
    • synchronization(2).basic plus a 1-in-40 sample of op.single_queue and op.multi_queue (1,504): 780 Pass, 724 NotSupported.
  • gpubench:
    • gpubench-vk query, render.light, compute.heavy (alu) and render.heavy (fill, 1080p) at depths 1 and 2: all ok, with 0 CRC/check mismatches.
    • gpubench-gl --verify on render.light, render.heavy and compute.heavy: all ok.
  • Health on every boot: 0 GPU recoveries, 0 MMU faults, 0 driver warnings and 0 kernel WARN/BUG. Also 0 new kernel error lines compared with stock, 0 AVC denials, 0 failed units and 0 core dumps.
  • Restore: a clean reboot to 7.3.0-41 each time, PMU boot-error count 00, and the test kernel, initramfs, modules and BLS entry removed (checked identical to the pre-install snapshot). stock.sh was identical.

@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 97fe6445 (once cancelled CI checks are rerun green)

Blockers: none (code, KUnit/host tests, and two-generation exact-head hardware rows are ready; rerun the 4 cancelled CI checks before merge).

Checked:

  • drivers/gpu/drm/asahi/g17/completion/publication.rs, job.rs, queue/mod.rs: verified collect_timestamp_waits() records only actual pending host-timestamp writer fences (pub_ref.has_outputs() or still-pending/failed fence_status(fence) <= 0 inherited timestamp_waits), deduplicated via push_unique_fence().
  • Verified cross-engine query_access computes covering a timestamp-free producer still add a firmware wait (scheduled, completed) on that intermediate producer while host-waiting only on the actual timestamp writer(s), and still host-wait on any failed (status < 0) entry.
  • Verified 220/220 g17 host tests and exact-head (97fe64450656) hardware rows on both J714s (M5 Pro, G17S: 170/170 query/multiview CTS, GTA V +22.2%, BeamNG +3.1%, 0 faults) and J700 (Neo, G17P: 0 new failures vs base, clean gpubench CRCs).
Evidence
  • Diff reviewed at 97fe6445 (all 3 files, 373 lines).
  • CI at review time: 19 passed, 0 failed, 4 cancelled.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train status at 97fe6445 (App approval noted; rows: 4 cancelled; J714s + J700 exact-head PASS). @DjDeveloperr code-owner ping (6-point rule, point 6): merge earliest 17:15 AEDT once full CI is green (I re-ran cancelled jobs) and the second-family row point holds. Revert: git revert -m 1 <merge>.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at 97fe6445. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J714s+J700. (5) There's no blocking review. (6) Dj was pinged here 60 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit d40c64b into main Nov 28, 2026
20 of 24 checks passed
@RyanTheTide
RyanTheTide deleted the fix/g17-query-access-no-ts-waits branch November 28, 2026 06:13
DjDeveloperr added a commit that referenced this pull request Nov 30, 2026
Resolve against main's timestamp-free publication chaining (#3319): carry both the inline_published flag and timestamp_waits in Fences, and both firmware_published and inherited_timestamp_waits through EnqueueOrdering. Main's new firmware wait for a timestamp-free producer now records its inline_published flag too, so the two vectors stay paired in the zip in Queue::enqueue().

Signed-off-by: DjDeveloperr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) 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