Skip to content

drm/asahi: g16: wait for the service stamp in cross-engine barriers - #3370

Open
DjDeveloperr wants to merge 4 commits into
fix/g16-3201-cross-vm-render-drainfrom
fix/g16-3349-compute-service-stamp
Open

DjDeveloperr wants to merge 4 commits into
fix/g16-3201-cross-vm-render-drainfrom
fix/g16-3349-compute-service-stamp

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3349. Stacked on #3353.

What: on the g16 backend, a firmware barrier between compute and render work now waits on the producer's service stamp, not on the fw_stamp that the firmware stores at FINALIZE. The wait stays in firmware.

  • Cause:
    • A render that reads compute output (for example a blit after a tessellation-control pass that writes an image) waited on the compute pipe's fw_stamp.
    • The firmware stores that stamp at FINALIZE. The kernel retires compute work only later, at the pipe's service stamp, once the firmware has serviced the record.
    • Between the two, the compute writes aren't yet visible to work on another firmware queue. A render on another queue of the same VM could read the old contents: "Memory contents don't match" in timeline_semaphore.write_image_tess_control_read_blit_image.*, about one full parallel run in three under CPU load.
  • Change, one commit per direction plus one for structure:
    1. A render's TA and FS barriers on a compute pipe wait on that pipe's service stamp. This is the commit that fixes drm/asahi g16: timeline_semaphore write_image_tess_control_read_blit_image exclusive fails intermittently under parallel multi_queue (J773g) #3349.
    2. Compute on one pipe waiting on compute on the other pipe does the same. No failing case shows this direction on its own.
    3. Compute waiting on a render's FS waits on the FS service stamp. No single failing case isolates this direction either. Earlier, though, signalling render job fences at FINALIZE instead of the service stamps made hundreds of "write on one queue, read on another" multi_queue cases fail on the J773g.
    4. Each service-stamp cell gets one accessor: ComputeGraph::service_stamp() and RenderGraph::{ta,fs}_service_stamp(), which return a StampCell with its VA and a read.
      • Three things go through it: the work item that tells the firmware where to store the stamp, retirement that reads it, and the barriers that wait on it.
      • The selftests check that no other code names these cells. A barrier can therefore never wait on a cell the firmware no longer writes, which would hang the queue.
      • No functional change.
    • The cross_engine_barrier_type comment said FINALIZE flushes caches before fw_stamp advances. It now says which stamp each wait uses and why.
  • Merge order with drm/asahi: g16: map the compute notifier records ASC-cached #3285: drm/asahi: g16: map the compute notifier records ASC-cached #3285 maps the compute notifier page ASC-cached and moves compute's service stamp into the queue's uncached user_stamp cell. Whichever of the two PRs lands second points ComputeGraph::service_stamp() at user_stamp. After commit 4 that's the only line to change, and drm/asahi: g16: map the compute notifier records ASC-cached #3285's rebase conflicts on exactly that accessor.

Tested: J773g (M4 Mac mini, macOS 26B123 firmware). The exact head is f84a141fb06e. Commits 1–3 are ab9d85f2bf17, which is the same code without commit 4's refactor.

Risk: two-way door.

  • Scope: the cross-engine barriers on the g16 backend: M4, and the M3 parts on the 26B123 protocol.
  • Cost: a consumer now starts after the producer's record has been serviced, not at FINALIZE. Measured above.
  • Unchanged: same-engine waits (TA→TA, FS→FS, render→render on the shared TA/FS pair) and job fences, which already signal at the service stamps.

Not yet:

  • A J516s (M3 Pro, G15S) row, because the g16 backend is shared.
  • Confirmation from a macOS capture of which stamp Metal waits on for a cross-queue compute→render dependency. The capture is prepared.

A render pass that depends on compute work waits for it with a firmware
barrier on the compute pipe's stamp. That barrier waited on fw_stamp,
which the firmware stores at FINALIZE. The kernel only retires compute
work at the pipe's later service stamp, after the firmware has finished
servicing the record.

A render on another queue of the same VM could therefore start while
the compute writes it reads were not yet visible to it. In
dEQP-VK.synchronization.op.multi_queue.timeline_semaphore.
write_image_tess_control_read_blit_image.*, a tessellation-control
compute pass writes an image on one queue and a blit reads it on
another; under CPU load about one full parallel run in three failed
with "Memory contents don't match" (linux#3349).

Wait on the service stamp instead, at both the TA and the FS barrier.
The wait stays in firmware.

Closes: #3349
Signed-off-by: DjDeveloperr <[email protected]>
Compute on one pipe that depends on compute on the other pipe waits with
a firmware barrier on the producer pipe's stamp. Like the render barriers
before the previous commit, it waited on fw_stamp, which the firmware
stores at FINALIZE, earlier than the service stamp the kernel retires on.

No failing case shows this on its own: the measured failure in
linux#3349 is a render reading compute output. The dependency is the
same kind, though, and FINALIZE has not been a point at which writes
are visible to another queue anywhere we measured. So wait on the
producer pipe's service stamp here too. This commit stands alone so it
can be reviewed and reverted separately.

Signed-off-by: DjDeveloperr <[email protected]>
Compute that depends on a render pass waits for it with a firmware
barrier on the render FS stamp. It waited on fw_stamp[1], which the
firmware stores at FINALIZE, earlier than the FS service stamp that
render retirement waits for.

No single failing case isolates this direction. The evidence that FS
FINALIZE is not a point at which a render's writes are visible to
another queue is direct, though: signalling render job fences at
FINALIZE instead of the service stamps made the multi_queue sync list
fail hundreds of "write on one queue, read on another" cases on the
J773g. The compute-to-render direction of the same wait is linux#3349.
So wait on the FS service stamp here too. This commit stands alone so it
can be reviewed and reverted separately.

Signed-off-by: DjDeveloperr <[email protected]>
Three places name a pipe's service-stamp cell: the work item that tells
the firmware where to store the stamp, retirement that reads it, and the
cross-engine barriers that now wait on it. They named it separately. If
one of them moved the cell, for example by mapping the notifier page
differently, a barrier would wait on a cell the firmware no longer
writes, and its queue would hang.

Give each cell one accessor, ComputeGraph::service_stamp() and
RenderGraph::{ta,fs}_service_stamp(), returning a StampCell with its VA
and a read. Work items, retirement and barriers all go through them,
and the selftests check that no other code names the cells. No
functional change: every address and read is the same as before.

Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 27, 2026 09:47
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 09:47
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 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) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at f84a141f: not ready yet

Check Detail
CI at head ok 3 checks passed
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 f84a141f
Conflicts ok none
PR text ok Risk: two-way · . - Scope: the cross-engine barriers on the g16 backend: M4, and the M3 parts on the 26B123 protocol. - Cost: a consumer now starts after the producer's record has been serviced, not at FINALIZE. Measured above. - Unchanged: same-engine waits (TA→TA, FS→FS, render→render on the shared TA/FS pair) and job fences, which already signal at the service stamps.

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 f84a141fb06e: ready

Blockers

None.

Checked

Still owed before merge: the J516s (G15S) row listed under Not yet, since the g16 backend is shared. The J773g row is in the body.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (MacBook Pro 16" M3 Pro, G15S) row at f84a141fb06e: PASS. multi_queue is clean in both 3-worker and one-process runs. One-shot boot of the exact head on the default cmdline; build ID 7.3.0-m3-maint-gf84a141fb06e. Mesa: aurora-wip 69179743d9ae, an isolated kit. The comparison is #3353 456bce008249, booted earlier the same day.

  • CTS, multi_queue:
    • 900 sampled synchronization{,2}.op.multi_queue cases split across 3 deqp-vk processes: 732 Pass, 168 NotSupported, 0 Fail;
    • the same 900 cases in one process (--jobs 1): 732 Pass, 168 NotSupported, 0 Fail, with 0 recoveries before and after.
  • CTS, cross_instance: 300 cases, 100 Pass, 200 NotSupported.
  • CTS, sync subset: 671 cases in one process (basic, smoke, timeline_semaphore, op.single_queue, signal_order and implicit, for sync and sync2): 599 Pass, 72 NotSupported, 0 Fail.
  • gpubench-vk (median µs per submission, 456bce008249 → this head):
    • render.light tri: procs d4 119.0 → 119.9, procs d16 136.5 → 126.5, queue d4 51.4 → 51.5;
    • render.postfx 1440p msaa1: procs d2 1,606 → 1,606, procs d4 2,564 → 2,548, queue d1 1,707 → 1,667, queue d2 1,244 → 1,256.
  • Suspend: s2idle is refused at prepare, as on main (dwc3-apple … genpd_prepare returns -11), so no sleep was tested.
  • 0 GPU faults, 0 recoveries or hang kills, 0 "no completion-stamp progress" lines, 0 failed units.
    • Kernel errors: besides the per-boot MTP HID line, one Wi-Fi line 12 s after boot, brcmfmac … brcmf_pcie_ring_mb_update_rptr: ring 4: r_ptr 0 outside depth 0, first seen on this boot. It isn't in a GPU path.
  • Clean reboot to stock, verified.

DjDeveloperr added a commit that referenced this pull request Nov 27, 2026
…r-pairs-on-3201

Stack this series on #3370 (linux#3349: cross-engine barriers wait on the
producer's service stamp, one accessor per service-stamp cell).

With per-VM render pairs every pair has its own render graph, so a
compute's barrier on a render waits on the FS service stamp of the
waited render's pair, and retirement reads each pair's TA and FS
service stamps through that pair's accessors.

Signed-off-by: DjDeveloperr <[email protected]>

@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.

Superseded 12-01: not a hold under the merge bar (no shown failure). Final review deferred until #3353/#3185 land; follow-ups: retarget, main CI (J516s PASS on file)

Verdict: HOLD at f84a141f

Blockers:

  1. Targets open non-main base branch fix/g16-3201-cross-vm-render-drain (#3353, which is itself stacked on #3185); full main CI has not run.

Checked:

  • Verified #3353 and #3185 are still OPEN (note J516s M3 Pro PASS row is recorded at f84a141f).
  • Deferred final approval until parent PRs land and this PR is retargeted onto main with green CI.
Evidence
  • Base ref: fix/g16-3201-cross-vm-render-drain (#3353 state: OPEN, #3185 state: OPEN).

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

This branch has not been deployed

No deployments
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:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (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.

1 participant