graphics: drain submitted guest command buffer to fix CPU/GPU fence race (Dead Cells hang, #1189) #1190
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1190
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1190"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tyyyyyyyyyyyyyyyy on GitHub · 2026-10-08 07:06 UTC · original
tyyyyyyyyyyyyyyyy:fix/dcb-submit-ordering→main· +1 −0 · 1 files · 1 commits · openFixes the hard hang on Linux/RADV described in #1189 (Dead Cells, PPSA15552; also reported for other titles).
Root cause (from #1189)
At the hang the gfx queue front is a
Graphicssubmission suspended onIT_WAIT_REG_MEM_64(fence == 1). A gdb hardware watchpoint on the fence shows the value alternating:i.e. the submitted buffer does
IT_WRITE_DATA(1 -> fence)+IT_WAIT_REG_MEM_64(fence == 1), but the guest CPU runs ahead and stores0to the same fence before the (asynchronous) GPU thread has finished processing the buffer, so the wait never observes1. The queue stalls andGuestGpu::SuspendPointthen deadlocks onm_suspend_point_ready. Windows is unaffected (different timing).Change
GuestGpu::Submit()now drains the submitted buffer before returning to the guest so the guest stays in step with the emulated GPU.Testing
With this change Dead Cells, Hollow Knight Silksong, Raiden IV and TMNT Splintered Fate all run at 60 fps with no hang (vs. Dead Cells deadlocking within ~30-60 s without it).
Note
WaitForIdle()after every DCB submit is a coarse fix — it serialises CPU and GPU. It is fine on the titles above, but maintainers may prefer a narrower synchronisation. Opening it to start the discussion; happy to rework.@coderabbitai[bot] on GitHub · 2026-10-08 07:11 UTC · original
📝 Walkthrough
Walkthrough
GuestGpu::Submitnow callsWaitForIdle()after enqueueing a nonempty graphics submission. Empty submissions still return immediately.Suggested reviewers:
nmzikPriority: ⬆️ High
Change: Bug fix
Merge Risk: 🟠 High · up to
31fe6Every graphics submission now waits for the GPU to finish. If a submitted command buffer waits for a value that the game writes only after submission returns, the game hangs permanently. This can affect any title that uses that pattern. Replace the full drain with targeted fence synchronization before merging.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
GuestGpu::Submit()change, affected games, testing results, and the synchronization trade-off.Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -145,6 +145,7 @@ void GuestGpu::Submit(std::span<const uint32_t> draw_commands,submission.commands = draw_commands;submission.constant_commands = constant_commands;Enqueue(std::move(submission));WaitForIdle();@coderabbitai[bot] on GitHub · 2026-10-08 07:11 UTC · original
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Keep
Submit()from waiting on guest progress.WaitForIdle()waits until all submissions complete. If this submission executes aWAIT_REG_MEMfor a value that the submitting guest thread will write afterSubmit()returns, the blocked submission stays pending and this call cannot return. The guest thread cannot perform the write, so the game hangs. Use targeted synchronization for the fence ordering instead of draining blocked PM4 work inSubmit().@coderabbitai[bot] on GitHub · 2026-10-08 07:11 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
e850eaf3-9ac1-4f80-a82f-bec33cebbbc5📥 Commits
Reviewing files that changed from the base of the PR and between
5a8808086aand31fe6461b5.📒 Files selected for processing (1)
src/graphics/guest_gpu/graphicsRun.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.