Repository navigation
drm/asahi: g16: wait for the service stamp in cross-engine barriers - #3370
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 <hey@djdev.me>
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 <hey@djdev.me>
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 <hey@djdev.me>
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 <hey@djdev.me>
|
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 <hey@djdev.me>
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).
…ompute-service-stamp Bring in #3353's branch, which now carries main up to 1b2c361. Main moved the TA, FS and compute service stamps out of the notifier pages, which it maps ASC-cached, into each queue's own uncached user_stamp cell, and dropped the notifier context checks from retirement. The StampCell accessors of this branch now name those cells: ComputeGraph::service_stamp() is user_stamp, and RenderGraph::{ta,fs}_service_stamp() are user_stamp[0] and [1]. Work items, retirement and the cross-engine barriers all go through them, so the barriers still wait on the cell the firmware stores after servicing the record. Retirement keeps main's logic and reads through the accessors. The selftests check the accessors against the user_stamp cells, and that no work item or barrier names a user_stamp VA directly. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Forward-merged the base: new head Conflicts and one silent break:
Checks (pc, x86_64 → arm64, LLVM, rustc 1.100.1):
Rows: the J516s row above is at |
…r-pairs-on-3201 Bring in #3370's branch, which now carries #3353's branch and main up to 1b2c361. Main changed the one render graph that this series splits into pairs. Each pair now takes main's layout: its FS fw_stamp comes from the firmware-cached ring allocator, it has its own ASC-cached FS notifier page, and the shared scheduling context, now allocated in Graphs::finish(), is handed to every pair there. Pair 0 keeps the allocation order, and later pairs share its legacy_empty and registration barrier as before. Retirement keeps main's model per pair: the uncached TA and FS service stamps gate it, the recovery-suspect path falls back to the stage fw_stamps, and the notifier records are never read. The pair's own targets and the latched per-flight TA/FS channel receipts of this series take the place of main's single-pair queue_passed() and queue_receipt(). Progress, the recovery snapshot and the report read each pair's FS user_stamp[1], as main does for its one pair. Render barriers: behind a render on another pair, the stage-order waits on that pair's fw_stamps are always posted. Behind a render on this pair, which is always of the same VM, the TA->TA and FS->FS barriers are left to the ring's order as in #3483 and #3499, and counted. The counters still commit only on TA producer publication, now on the pair's queues. needs_engine_drain() keeps main's compute UMA slot conflict. Selftests: the mocks index render pairs and read the service stamps. This series' pair tests now set the service stamps instead of the notifier, and main's tests carry the pair fields. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J773g (M4 Mac mini, T8132, G16G B0) hardware row PASS for the
|
|
J516s (MacBook Pro 16" M3 Pro, T6030, G15S B1) second-generation row at
|
|
Verdict at Blocker
Checked
Evidence
Hold lifted (14:11 UTC). The same-session J773g A/B (receipt) found no regression at |
satchlj
left a comment
There was a problem hiding this comment.
Reviewed d52995c924a7 (StampCell<'a> + single service_stamp/ta_service_stamp/fs_service_stamp accessors in g16/graph.rs, cross-engine barriers fs2c/c2c/c2ta/c2fs waiting on the producer's uncached service stamp in g16/engine.rs, retirement update in g16/poll.rs, and host-test coverage in test-publication.py/test-resources.py/test-stamp-wrap.py).
Verified against the exact-head M3 Pro J516s second-gen CTS row (multi_queue 205/0, cross_instance 92/0, sync 552/0, 0 faults) and the M4 J773g same-session A/B at stack tip f8951063 (all CRCs valid, 0 faults, A/B hold lifted). pr-text and readiness are green. LGTM.
|
Local build receipt for the merge tree. Hosted CI only ran pr-text and readiness on this stack, so I built it here. Merge tree: main Setup: pc (x86_64, cross to arm64), clang 23.1.3, rustc 1.100.1, bindgen 0.73.2, defconfig + asahi.config, 16K pages,
The stack adds no new warnings. The hardware evidence still stands: the J773g same-session A/B at |
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: