fix(agc): retire the window imports that pin a range a guest unmap waits for #6182
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6182"
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 XairRrR on 2026-10-15T00:52:43Z.
What
A registered range larger than the import window is imported in windows (
windowRun, 64 MiB by default), and every window'sHostImportholds the whole range throughrange/ranges. When the guest unmaps or frees part of such a range,GuestAllocationsRequireUnpinnedwaits until no one else references the range, and the pin waiter (WaitForLeasesAndImports) retires the live and parked imports that overlap the unmapped bytes (#4291). The imports of the range's other windows do not overlap those bytes, so they keep the range pinned: the unmap waits outAPS5_PIN_WAIT_MSand fails.PPSA05684 (Uncharted: Legacy of Thieves Collection) hit this in its main menu and at the start of its first level:
guest allocation 0x103da00000+0x100000 is still pinned by GPU work or an import (waited 60000 ms for the lease (APS5_PIN_WAIT_MS)), afterleased allocation ... still pinned after 8 recorder syncs. The 1 MiB it unmaps lies inside a 1.4 GiB registered range that is imported in 64 MiB windows.The waiter now retires the live and parked imports whose window overlaps the waited bytes or that hold a registered range overlapping them (
holdsRangeOver), in the places that chose imports by window overlap only: the live imports (both waits), the parked imports, and on Windows the settle-retired imports (releaseSettleRetired, added onmainsince this PR was opened), which hold the same range until their batch is released.Tested
Linux 7.2.9-zen, GCC, Ninja, Release, rebased on
main9caecfd2d:agc_tests pass.tools/check_conventions.py --base origin/mainpasses. The Windows settle path is not tested.agc_window_import_unmap(agc_driver_recorder_tests --window-import-unmap-only,APS5_PIN_WAIT_MS=3000): registers a range of four import windows, imports only the first window, then unmaps the third. WithGuestBufferMemory.cppfrommainit fails with the same error as the title:guest allocation 0x...+0x20000 is still pinned by GPU work or an import (waited 3000 ms for the lease (APS5_PIN_WAIT_MS)); with the change it passes.mainplus #6003/#6004 and local depth patches): before the change, two of three runs ended in this abort within five minutes; after it, no run hit it again (runs end only on this machine's memory limit) and the title reaches gameplay.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-18T10:57:45Z.
Rebased onto
main9caecfd2das2f540fa6d.mainrestructuredWaitForLeasesAndImports, so I reappliedholdsRangeOveronmain's version.mainhas also added a Windows-only release of settle-retired imports (releaseSettleRetired), which matched by window overlap only. Those imports hold the same range until their batch is released, so it now usesholdsRangeOvertoo. That path is untested here (Linux only). All 701agc_tests pass.agc_window_import_unmapstill fails withGuestBufferMemory.cppfrommain(pinned, waited 3000 ms). Description updated.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T17:09:41Z.
Thanks. Linux CI passes
agc_window_import_unmap, but on Windows it exits0xc0000135(DLL not found) in 0.01 s, before the test runs. The new test is missing from theif(WIN32)list incore/libs/prx/libSceAgcDriver/CMakeLists.txtthat gives theagc_driver_recorder_testsmodesENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>"(theset_tests_properties(agc_recorder_read_list agc_host_import_unmap agc_parked_import_unmap ...line). Without it the exe can't findlibcon Windows. Could you addagc_window_import_unmapto that list, next toagc_parked_import_unmap?Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-20T19:26:28Z.
Added
agc_window_import_unmapto theif(WIN32)ENVIRONMENT_MODIFICATIONlist next toagc_parked_import_unmapinb1501db95, and merged main (b1fe49bca) since main had changed the same line (agc_draw_inputs_copied).agc_window_import_unmappasses on Linux; I can't run the Windows job here.Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-21T09:32:27Z.
Title data point for this together with #6565: Onimusha: Way of the Sword (PPSA27836), owned, Windows 10 Pro 22H2, RTX 3080 (NVIDIA 617.42), WinLibs GCC 15.2.0, Release,
APS5_NO_HOST_IMPORT=1. Tree:main1d4164552plus a few open AGC/shader PRs and local workarounds for the #6570 and stencil-mask stops; the only change between the two runs below is #6182 + #6565 merged in.guest allocation 0xe82bf60000+0x1a0000 is still pinned by GPU work or an import (waited 60000 ms for the lease (APS5_PIN_WAIT_MS))(from a guest mutation inlibc).I merged both together, so this does not say which of the two is needed for this title; one run each.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-21T23:57:31Z.
Merged main (
51d5f7e04): main addedagc_idle_publish_waiton the same WIN32ENVIRONMENT_MODIFICATIONline and next to the--window-import-unmap-onlymode intests/Recorder.cpp; both kept. agc tests pass exceptagc_driver_sample_order*, which fail on maina6dcea927too.AI-assisted: yes