fix(agc): hold the settle and sparse queues across vkDeviceWaitIdle #18828

Merged
DealPotato merged 1 commit from upstream-pr/18828 into main 2026-11-15 02:31:58 +00:00
DealPotato commented 2026-11-12 11:49:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DealPotato on 2026-11-12T11:49:08Z.


What

vkDeviceWaitIdle requires host access to every queue of the device to be externally synchronized. VulkanDevice::WaitIdle held only the present queue's mutex. Guest threads that import mapped memory submit their settle copy to the settle queue under settleQueueMutex, without the GPU mutex (settleImport), and sparse binds run under sparseQueueMutex; either could run during the device-wide wait. WaitIdle now holds those two mutexes as well, after the present queue's.

On WWE 2K26 (PPSA34299) the device was lost during boot and loading with an NVIDIA DMA page fault: Nsight Aftermath reports Error_DMA_PageFault with "an internal command processing error", all GPU units idle, and VK_EXT_device_fault reports "write invalid at 0x0"; the log shows a settle submit failing with VK_ERROR_DEVICE_LOST at that moment. All crashes had the same Aftermath fingerprint. Runs that drain the device on every CPU buffer fill (a WaitIdle per fill) lost it in three runs out of three; with this change neither of two runs did, one of them draining on every fill. That is few runs for an intermittent fault, so the test below is the actual evidence for the rule.

Tested

Windows 11 Pro (build 26300), NVIDIA GeForce RTX 4070, driver 610.88. Focused tests run with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V on main (3b7f31fa70) and on this change, from one build directory; the loader inserted the validation layer in both runs.

Passed on main and on the change: agc_driver_host_import_at_map, agc_driver_host_import_proofs, agc_driver_guest_memory_lifetime, agc_driver_fill_completion_labels. Neither log has a VUID- message.

The new agc_driver_wait_idle_queue_locks holds the settle queue's mutex (and the sparse queue's, when the device has one) on the test thread and checks that WaitIdle on another thread does not return until it is released. It fails on main with "vkDeviceWaitIdle ran while another thread held the settle queue" and passes on the change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA34299 (WWE 2K26; no Game bring-up discussion yet)
  • GPUs tested: NVIDIA GeForce RTX 4070, driver 610.88, Windows 11 Pro (build 26300)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5276834230 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18828). Originally posted by [DealPotato](https://github.com/DealPotato) on 2026-11-12T11:49:08Z. --- ### What `vkDeviceWaitIdle` requires host access to every queue of the device to be externally synchronized. `VulkanDevice::WaitIdle` held only the present queue's mutex. Guest threads that import mapped memory submit their settle copy to the settle queue under `settleQueueMutex`, without the GPU mutex (`settleImport`), and sparse binds run under `sparseQueueMutex`; either could run during the device-wide wait. `WaitIdle` now holds those two mutexes as well, after the present queue's. On WWE 2K26 (PPSA34299) the device was lost during boot and loading with an NVIDIA DMA page fault: Nsight Aftermath reports `Error_DMA_PageFault` with "an internal command processing error", all GPU units idle, and `VK_EXT_device_fault` reports "write invalid at 0x0"; the log shows a settle submit failing with `VK_ERROR_DEVICE_LOST` at that moment. All crashes had the same Aftermath fingerprint. Runs that drain the device on every CPU buffer fill (a `WaitIdle` per fill) lost it in three runs out of three; with this change neither of two runs did, one of them draining on every fill. That is few runs for an intermittent fault, so the test below is the actual evidence for the rule. ### Tested Windows 11 Pro (build 26300), NVIDIA GeForce RTX 4070, driver 610.88. Focused tests run with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V` on `main` (3b7f31fa70) and on this change, from one build directory; the loader inserted the validation layer in both runs. Passed on `main` and on the change: `agc_driver_host_import_at_map`, `agc_driver_host_import_proofs`, `agc_driver_guest_memory_lifetime`, `agc_driver_fill_completion_labels`. Neither log has a `VUID-` message. The new `agc_driver_wait_idle_queue_locks` holds the settle queue's mutex (and the sparse queue's, when the device has one) on the test thread and checks that `WaitIdle` on another thread does not return until it is released. It fails on `main` with "vkDeviceWaitIdle ran while another thread held the settle queue" and passes on the change. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA34299 (WWE 2K26; no Game bring-up discussion yet) - [x] GPUs tested: NVIDIA GeForce RTX 4070, driver 610.88, Windows 11 Pro (build 26300) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-14 09:16:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T09:16:54Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected implementation serializes vkDeviceWaitIdle with the present, settle, and sparse queue mutexes, and the reported focused tests cover the new behavior.

What I ran

Reviewed head 42b8a29cfd72c15e46cfdbc3b185751a8ae188cb using repo_read.py for the prepared diff and pinned repository source. No tests were run in this review; test results in the PR description are author-reported.

Results

Check Result Note
Changed code review passed Queue locks acquired before device wait
Tests in this review not run Author reports focused tests passed
Reported regression test passed Author reports it fails on main and passes here

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full source of core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp was read only around WaitIdle; its other contents were excluded as too large. The new test source was supplied in full and read. No local tests or hardware checks were run. The runtime results and validation-layer logs in the description were not independently confirmed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5903374709 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18828#pullrequestreview-5903374709). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T09:16:54Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected implementation serializes `vkDeviceWaitIdle` with the present, settle, and sparse queue mutexes, and the reported focused tests cover the new behavior. ## What I ran Reviewed head `42b8a29cfd72c15e46cfdbc3b185751a8ae188cb` using `repo_read.py` for the prepared diff and pinned repository source. No tests were run in this review; test results in the PR description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Queue locks acquired before device wait | | Tests in this review | not run | Author reports focused tests passed | | Reported regression test | passed | Author reports it fails on main and passes here | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full source of `core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp` was read only around `WaitIdle`; its other contents were excluded as too large. The new test source was supplied in full and read. No local tests or hardware checks were run. The runtime results and validation-layer logs in the description were not independently confirmed. ## To get this to a good state Nothing is required.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!18828
No description provided.