Skip to content

drm/asahi: g17: keep timestamp writers behind cross-engine publication - #3246

Closed
DjDeveloperr wants to merge 1 commit into
mainfrom
fix/g17-timestamped-consumers-wait
Closed

DjDeveloperr wants to merge 1 commit into
mainfrom
fix/g17-timestamped-consumers-wait

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: Fixes #3243. Since #2552, a G17 command that writes timestamps can overlap a cross-engine producer whose host-written timestamps aren't published yet. On G17P its timestamps then come out earlier than the ones written before it, and 42 of the 48 multiview query timestamp cases fail. With this change, a timestamp-writing command waits on the host for such producers, as a query-accessing compute command already does. Commands that write no timestamps keep #2552's overlap.

Tested: host build of drivers/gpu/drm/asahi (asahi.config, LLVM, Rust, CONFIG_KUNIT=y) at 72a4de931df0: builds with no new warnings, and the new KUnit case compiles. No hardware row yet.

Risk: two-way door · G17P (A18 Pro) and the M5 boards that don't wait for producers on the host; elsewhere the decision doesn't change

Not yet: a J700 row with the 48 multiview cases and the query/timestamp CTS against base. A J714s row with the same cases plus a game-perf sample, since timestamp-writing passes no longer overlap. CI.

Details

EnqueueOrdering::build() decides, for each covered producer on the other engine, between two orderings:

  • a host wait on the producer's completion fence, which includes its host timestamp publication;
  • a firmware wait on its scheduled fence, with the consumer's own publication chained behind the producer's.

#2552 made the second the default when producers aren't waited for on the host. It kept the host wait only for query-accessing compute behind a producer with a pending publication.

That misses a consumer that writes timestamps. Running next to the producer, it stamps before the producer's timestamps are published. A render chained behind a predecessor writes its timestamps on the host at publication, while a compute timestamp holds the GPU time it ran at. So the order of the values no longer follows command order. Multiview query cases alternate render passes with timestamp writes, which is where it shows: "Fail (timestamp)", with no faults or recoveries. The Neo bisected this to the #2552 merge f0c5cb1a80eb: its first parent passes 48/48.

The decision now goes through observes_published_timestamps():

build() takes the consumer's writes_timestamps. The existing KUnit cases pass false, so they keep checking #2552's overlap. The new timestamp_writers_wait_for_cross_engine_publication checks four plans:

  • Render(ts) → timestamp-writing NO_QUERY_ACCESS compute: host wait;
  • Compute(ts) → timestamp-writing render: host wait, nothing chained;
  • Compute(ts) → render without timestamps: still a firmware wait, chained;
  • with host waits on: unchanged.

Cost: a pass that writes timestamps behind other-engine work with a pending publication loses the overlap and waits on the host, which was the behaviour before #2552. Games that don't time passes on the GPU are unaffected.

Evidence
  • ./linux-build/build kernel --profile asahi <tree> -- olddefconfig drivers/gpu/drm/asahi/ with CONFIG_KUNIT=y: exit 0. The new case is in the module object, and there's no warning in g17/queue/mod.rs.
  • rustfmt: no diffs.
  • checkpatch --strict: 0 errors, 0 checks, and 1 warning for a 101-column line. The file already has longer lines, and rustfmt accepts it.
  • The bisect and the failing cases: drm/asahi g17: multiview query timestamps wrong on main (regression since 11-16, J700) #3243.

Since "drm/asahi: overlap cross-engine commands with timestamped
producers on G17" (#2552), a command can run in firmware next to a
cross-engine producer whose host-written timestamps are not published
yet, and chain its own publication behind the producer's. Only a
query-accessing compute command still waited on the host for such a
producer.

That is not enough for a command that writes timestamps itself. Where
producers are not waited for on the host (G17P), it then runs, and
stamps, before the producer's timestamps are published, so its
timestamps can come out earlier than the ones written before it. On a
J700, the multiview query timestamp cases alternate render passes with
compute timestamp writes, and 42 of 48 fail with "Fail (timestamp)"
since that merge, without faults or recoveries.

Treat a consumer that writes timestamps like a query-accessing compute
command: it waits on the host for each cross-engine producer whose
publication is still pending, and chains none. Commands that write no
timestamps keep overlapping their producers, and nothing changes where
producers are always waited for on the host.

KUnit: asahi_g17_cross_engine_timestamps
(timestamp_writers_wait_for_cross_engine_publication).

Fixes: #3243
Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 26, 2026 12:37
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at 72a4de931df0: ready

Blockers: none

Checked:

  • Every path that writes or reads timestamps or query words is covered. The kernel sees two signals, and the cross-engine wait now follows both: stamp destinations (Destinations::has_outputs(), which looks only at the four start/end stamp slots) and compute query access (no NO_QUERY_ACCESS).
    • Timestamp writes, multiview and empty carriers: vkCmdWriteTimestamp2 always rides on some command's start or end stamp (hk_sync_write_timestamp()), and that includes multiview passes and the empty timestamp carriers. So that command has stamp destinations and now host-waits for an other-engine producer whose publication is pending. This holds on both engines: for a render, query_access is always true, but only the new writes_timestamps term can make it wait.
    • Copy, reset and multiview zero reports: vkCmdCopyQueryPoolResults, vkCmdResetQueryPool and the zero reports and availability a multiview timestamp writes for its other views all go through hk_note_query_access(). That makes their compute stream a query-accessing command, which already host-waited.
  • The overlap is kept everywhere else. For a command with no stamp destinations and no query access, observes_published_timestamps() is false, so cross_engine_chain_publication() and cross_engine_wait_completed() give the same answer as after drm/asahi: overlap cross-engine commands with timestamped producers on G17 #2552. All the existing ordering cases pass with writes_timestamps = false, unchanged. The new case's third plan shows that a no-timestamp render behind a timestamped compute still takes a firmware wait on scheduled and chains. With host_producer_waits() true (the M5 boards without the G17D forms), every producer is still host-waited, as before.
  • The wait can't deadlock.
    • The host wait is a drm_sched dependency on the producer's completed fence (dependencies.push()), not a wait in the ioctl or under a lock.
    • The producer is earlier in submission order on the other engine. Its completion depends only on its own work and on publications chained behind earlier commands.
    • A host-waiting consumer chains nothing (predecessors stays empty), so no fence ever points from an earlier command to it. This is the same shape query-accessing compute has used since before drm/asahi: overlap cross-engine commands with timestamped producers on G17 #2552.
  • Merged-code rules: no runtime switch, no new constant, no SoC or board gate. The always-wait boards keep using the existing host_producer_waits().
Evidence
  • Build at 72a4de931df0 with the asahi profile (LLVM, Rust): rust/ and drivers/gpu/drm/asahi/, exit 0, no warning in g17/queue/mod.rs.
  • KUnit drivers/gpu/drm/asahi/.kunitconfig (arm64 QEMU, Rust; run locally because CI's KUnit asahi was still queued; CONFIG_WERROR off for this host's clang 23):
    • this head: 464 run, 460 pass, 4 skipped. asahi_g17_cross_engine_timestamps passes 8/8, including timestamp_writers_wait_for_cross_engine_publication;
    • this head with observes_published_timestamps() returning drm/asahi: overlap cross-engine commands with timestamped producers on G17 #2552's rule (compute with query access only): timestamp_writers_wait_for_cross_engine_publication fails at g17/queue/mod.rs:1185, the render to timestamp-writing compute host wait. Everything else passes.
  • Borealis (hk_query_pool.c): hk_note_query_access() is called from the copy, the reset and the G17P zero-report paths, and hk_CmdWriteTimestamp2() → hk_sync_write_timestamp() attaches every timestamp to a command's stamp.
  • The J700 multiview and query CTS row and the J714s row with a game-perf sample are still listed under "Not yet".

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m5 Macs affected, from Merge risk (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 72a4de93: not ready yet

Check Detail
CI at head no failing: KUnit ane-boot, KUnit dcp-topology, KUnit asahi, KUnit spi-hid-apple, KUnit avd, KUnit ave
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 72a4de93
Conflicts ok none
PR text ok Risk: two-way · G17P (A18 Pro) and the M5 boards that don't wait for producers on the host; elsewhere the decision doesn't change

Areas: area:gpu

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

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 26, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J714s (MacBook Pro 14" M5 Pro, G17S B1) A/B at 72a4de931df0 against base b14959b819cf: not a fix on G17S. All 48 #3243 cases still fail, and BeamNG runs 7.8 % slower.

Setup:

  • Both kernels are warm native builds on the M5 from one tree and config, booted with the default command line, headless. The default kernel was restored after every boot.
  • Every case runs on the system Mesa (aurora-m5, vk-aac82bea8e) on both kernels.
  • One session, in the order base boot, head boot, base re-boot (A B B A for the game).

1. The #3243 multiview cases, one case per process. On CTS 1.4.7.1, dEQP-VK.multiview.{renderpass2,dynamic_rendering}.*queries*timestamps* plus readback_explicit_clear.no_queries comes to 112 cases.

2. query_pool.* (19,276), pipeline.*timestamp* (950) and synchronization* (146,489):

  • Base: 23 Fail, 2 Flake, 106,753 Pass. Head: 23 Fail, 1 Flake, 106,754 Pass. The rest are Skip/Warn.
  • The 23 Fails are the same pipeline.*.timestamp.* cases on both arms (44× "Timestamp query not available", 3× "Test stage timestamp"). So nothing new fails and nothing gets fixed. query_pool and the sync groups have 0 Fail on both.

3. BeamNG, west_coast_usa, DX11 through Proton ARM64, 3024x1964 fullscreen, 170 s with 5 FPS windows per run. The output was muted, and the game settings were restored byte-identical afterwards.

Run Kernel Mean FPS (windows) ms/frame Worst p99 ms
A1 base 16.30 (16.21–16.49) 61.36 62.41
B1 head 15.07 (14.98–15.17) 66.34 68.51
B2 head 15.03 (14.94–15.14) 66.54 68.30
A2 base 16.36 (16.27–16.49) 61.14 63.45
  • Result: base 16.33 FPS and head 15.05 FPS, so −7.8 % FPS, +5.2 ms per frame.
  • Noise: run to run it's 0.37 % on base and 0.29 % on head, so the drop is about 20 times the noise.
  • Absolute FPS: it's low because both arms use the older system Mesa rather than the game campaign's kits. Holding the Mesa fixed is what makes the comparison valid.

4. Kernel log: 0 GPU MMU faults, 0 G17 recoveries, 0 firmware crashes and 0 WARN/BUG/Oops in every window on both kernels. The base CTS window had one "compute publication … gave up" (main's linux#3235); the head had none.

Reading: on the J714s the new path runs. host_producer_waits() is false here, because the board takes the completion-class waits (!g17d_forms && !completion_inputs is false), and the FPS drop confirms the change took effect. It removes the overlap but doesn't change the multiview timestamp values, so the G17S failure needs a different fix.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo, A18 Pro, G17P) A/B at 72a4de931df0 against base b14959b819cf: not a fix on G17P either. The 48 #3243 cases still fail on head exactly as on base (42 Fail / 6 Pass, same cases), and nothing else changed.

Setup:

  • 7.3.0-neo-tsbase = b14959b819cf, 7.3.0-neo-tsfix = 72a4de931df0. Both were built from one tree with the Neo's -41 config; only the release string differs. Head was an incremental build of the g17/queue/mod.rs change, and its aurora.ko differs from base's.
  • One-shot boots, default command line, stock Mesa 26.3.0-30, soft faults. One kernel per hold, same test script on both.
Group base b14959b8 head 72a4de93
48 #3243 cases, one deqp process each 42 Fail (timestamp) / 6 Pass 42 Fail (timestamp) / 6 Pass, the same cases
query_pool.* (19,276) 18,708 run: 18,676 Pass, 32 NotSupported 18,000 run: 17,968 Pass, 32 NotSupported
pipeline.*timestamp* (950) 489 run: 329 Pass, 26 NotSupported, 134 DeviceLost 824 run: 495 Pass, 26 NotSupported, 303 DeviceLost
Sync subset (6,426) 6,050 Pass / 376 NotSupported 6,050 Pass / 376 NotSupported, the same cases
GPU faults / recoveries 0 / 0 0 / 0
New WARN / BUG / kernel error lines 0 / 0 / 0 0 / 0 / 0

The DeviceLost results:

  • What they are: every one is a dEQP-VK.pipeline.*.timestamp.* case. Each fails at vkGetQueryPoolResults with WAIT, returning VK_ERROR_DEVICE_LOST after about 2 s, with no kernel fault and no recovery. My reading is that the timestamps are never published, so the wait times out. That would be the same problem as drm/asahi g17: multiview query timestamps wrong on main (regression since 11-16, J700) #3243.
  • Both kernels have them: of the cases both runs reached, 7 changed result, all in this family and in both directions (3 Pass → DeviceLost, 4 DeviceLost → Pass). So they're flaky, and head doesn't add new ones.
  • Why head shows more: each DeviceLost restarts a deqp chunk, so neither run finished group 2 inside its 7-minute cap. Head got further and reached the shader_object_* timestamp groups (165 DeviceLost / 157 Pass), which base never reached. Without those groups, head is at 138 DeviceLost in 502 cases and base at 134 in 489.

Not run here: these timestamp cases on stock 7.3.0-41. So I don't know yet whether the DeviceLosts come from the same regression as #3243.

Neo state: every boot cleared the PMU boot-error count and read it back as 00. The Neo is back on the stock -41 default, the test kernels are removed, and stock.sh matches the start.

@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: CLOSE or rework at 72a4de93 (do not merge as-is)

Blockers:

  1. Hardware A/B verification on both target platforms shows this change does not fix #3243 and causes a performance regression:
    • J714s (M5 Pro, G17S): all 48 #3243 multiview query timestamp cases still fail, and BeamNG runs 7.8% slower.
    • J700 (Neo, G17P): the same 42/48 #3243 cases still fail identically to base.
  2. Do not merge a change that adds host synchronization overhead without fixing the target bug; either close this PR or rework after root-causing #3243.

Checked:

  • Reviewed PR description, diff (drivers/gpu/drm/asahi/g17/queue/mod.rs), and both A/B hardware test reports at 72a4de931df0.
Evidence
  • J714s and J700 A/B comments on this PR at 72a4de931df0 both confirm 0/48 #3243 failures resolved and -7.8% BeamNG FPS on G17S.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Closing as part of the stale-PR closeout. Your own A/Bs at 72a4de93 (11-26 15:06 and 15:20) show that all 48 #3243 cases still fail on the J714s, J700 has the same 42 of 48 failures as base, and BeamNG is 7.8 % slower on the M5. The review App also asked to close or rework. The bug stays tracked in #3243, and a new PR can follow once the root cause is found. Reopen this if you see it differently, @DjDeveloperr.

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) blast:m5 Macs affected, from Merge risk (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.

drm/asahi g17: multiview query timestamps wrong on main (regression since 11-16, J700)

2 participants