Repository navigation
drm/asahi: g16: wait for the service stamp in cross-engine barriers - #3370
DjDeveloperr wants to merge 4 commits into
Conversation
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]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Verdict at 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. |
|
J516s (MacBook Pro 16" M3 Pro, G15S) row at
|
…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]>
There was a problem hiding this comment.
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:
- Targets open non-
mainbase branchfix/g16-3201-cross-vm-render-drain(#3353, which is itself stacked on#3185); fullmainCI has not run.
Checked:
- Verified
#3353and#3185are stillOPEN(noteJ516sM3 Pro PASS row is recorded atf84a141f). - Deferred final approval until parent PRs land and this PR is retargeted onto
mainwith green CI.
Evidence
- Base ref:
fix/g16-3201-cross-vm-render-drain(#3353state:OPEN,#3185state:OPEN).
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_stampthat the firmware stores at FINALIZE. The wait stays in firmware.fw_stamp.timeline_semaphore.write_image_tess_control_read_blit_image.*, about one full parallel run in three under CPU load.ComputeGraph::service_stamp()andRenderGraph::{ta,fs}_service_stamp(), which return aStampCellwith its VA and a read.cross_engine_barrier_typecomment said FINALIZE flushes caches beforefw_stampadvances. It now says which stamp each wait uses and why.user_stampcell. Whichever of the two PRs lands second pointsComputeGraph::service_stamp()atuser_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 areab9d85f2bf17, which is the same code without commit 4's refactor.How it was isolated: a lab kernel on drm/asahi: g16: drain the engine before a render of another VM #3353 with a runtime switch for how cross-queue waits are resolved. Each run is the full
dEQP-VK.synchronization*multi_queue*list (36,573 cases) with 3 deqp-vk processes, under CPU load (2 busy loops, or a 1 s journalctl poller). Each lab boot also ran 2 runs of the unchanged path in between.fw_stamp, as drm/asahi: g16: drain the engine before a render of another VM #3353f84a141fb06e(12)Correctness on
ab9d85f2bf17, one boot, 0 GPU faults, no stalls:dEQP-VK.synchronization*multi_queue*dEQP-VK.synchronization*.cross_instance.*api.copy_and_blitblit_image RGBA8/BGRA8dEQP-VK.synchronization*single_queue*dEQP-VK.tessellation.*Cost: µs, lower is better, median of 2 passes. drm/asahi: g16: drain the engine before a render of another VM #3353 and this PR were each measured on their own boot. Metal 4 values are native macOS 26B123.
Host: the asahi-m4 host selftests pass, 26/26 files at each commit.
test-publication.pychecks that every cross-engine barrier waits on a service stamp and none onfw_stamp.test-stamp-wrap.pycompiles the production accessors into its retirement harness.Risk: two-way door.
Not yet: