fix(agc): retire host imports before guest unmap #2575
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2575"
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?
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T06:49:17Z.
Carrying @MarcZX100's fix for #2352 while PR intake is paused. The change is theirs (from
MarcZX100/AnyPS5:fix/host-import-unmap-lifetime, c6bffc00), with its two commits squashed and rebased onto currentmain. A second commit adds the two-line follow-up that @popcoder565 found and @zaydzaari confirmed in the issue.What
Contextor itsBufferPoolpast the device.agc_driver_recorder_tests --host-import-unmap-onlychecks that the import is already gone inside the unmap callback, before the block is released.refreshImportsloadsvkDestroyBufferandvkFreeMemorywhen they are still null, not only when the device changes. A context without a device, like the graphics test's mock, otherwise never loaded them, so retiring an import called a null pointer (agc_driver_graphicssegfaulted atrip 0, throughimportCrossingTests→GuestAllocationsRemove→WaitForLeasesAndImports→retireImport→~RetiredImport).Why
Fixes #2352. A guest unmap released host-imported pages before the import that covers them was freed. The Vulkan spec requires the imported range to stay valid for the import's lifetime. On Windows with NVIDIA 616.92, freeing an import whose pages are already gone loses the device when the release follows the import closely: 12 of 60 runs at about 10 µs, 1 of 20 at 1 ms, and 0 when the import is retired first.
Tested
mainaad16d05):agc_driver_recorder_tests --host-import-unmap-onlypasses, andagc_driver_sampled_cache_budgetand_memorypass.main), with the import already retired at release in every run.agc_driver_recorder_testspassed 20/20,--host-import-unmap-only10/10, and the sampled-cache tests 5/5 each, with no exit crash. With the follow-up,agc_driver_graphicspassed 5/5 and the full ctest 543/543.agc_driver_graphics_testspassed 5/5,--host-import-unmap-only10/10, and the sampled-cache,guest_memory_tests,agc_write_tracking_testsandguest_agc_driver_resources_testspassed.main092e133e: the branch merges cleanly andtools/check_conventions.pypasses. CI runs the build and tests.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T06:52:04Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/tests/Recorder.cppL3610core/libs/prx/libc/include/GuestAllocations.hppL51core/libs/prx/libc/src/GuestAllocations.cppL46, L131-132Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:42:02Z.
Checked on Linux (lavapipe): clean rebase onto current
main,agc_driver_graphics,agc_driver_host_import_teardown,agc_driver_sampled_cache_budget_memoryandguest_memorypass, and--host-import-unmap-onlypasses. The Windows/NVIDIA results from @popcoder565 and @zaydzaari cover the device-loss case, which we can't run here.Added one commit:
agc_driver_recorder_tests --host-import-unmap-onlywas not registered in ctest, so CI never ran it. Registered it asagc_host_import_unmap(skip code 77, same as the neighbouring entries). With the non-test changes reverted it fails, so it pins the fix.Merging on green CI.
Imported from boykopovar/AnyPS5. Originally posted by nikhilpanchal1 on 2026-10-10T14:40:09Z.
Follow-up: #2779 covers host-import construction cleanup and mutation-wait failures. Eight isolated cases fail on main@5edae353 and pass with the fix; all 698 existing test outcomes are unchanged, and 450 repeated lifetime checks pass. Retirement ownership changes are excluded. Windows/NVIDIA validation would be especially helpful.
Imported from boykopovar/AnyPS5. Originally posted by nikhilpanchal1 on 2026-10-10T15:54:28Z.
@adriadam10 Windows/NVIDIA results are now available for #2779: RTX 5070 and RTX 3060 Laptop. The 5070 report reproduced the baseline lease timeout and registry-lock failure, then passed with the fix. The 3060 report notes one intermittent agc_driver crash of unknown relation. Both tested
db76c694; the smaller current revision passes 450 Linux lifetime runs. Could you keep this follow-up on the backlog for review?