fix(agc): release parked host imports a pinned guest range waits for #4291
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4291"
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 diversao on 2026-10-12T05:03:13Z.
What
A guest
munmap/mprotect/free of a range that a replaced Vulkan device had host-imported waits out the whole pin wait (APS5_PIN_WAIT_MS, 60 s) and then fails withEINVAL.Driver::AttachWindowreplaces a device that was created before the window (PrepareForReplacementdrains it withvkDeviceWaitIdle) and keeps it inreplacedDevices. The nextrefreshImportsfrom the new device moves the old device's imports intoHostImports::parked. Each parkedRetiredImportkeeps itsHostImport::ranges, so the guest allocation stays pinned.parkedis only cleared byClearHostImportswhen that device is destroyed, which does not happen before shutdown. The pin waiter (WaitForLeasesAndImports) never looks atparked. Every round finds the recorder idle and no live import over the range, yields, and the guest thread spins until the deadline.releaseParkedImportsdrops the parked imports that overlap the range being changed, in both branches of the waiter, and reports progress so the registry is rescanned. A parked import belongs to a device thatPrepareForReplacementalready waited idle, so no GPU work can still read it.New test
agc_parked_import_unmap(--parked-import-unmap-only): imports a guest range on one device, imports it again on a second device (which parks the first import), then unmaps it withAPS5_PIN_WAIT_MS=3000. Onmainit fails after 3 s withguest allocation ... is still pinned by GPU work or an import (waited 3000 ms for the lease (APS5_PIN_WAIT_MS)). With the change it passes at once.Tested
Windows 11 Pro 26200, NVIDIA RTX 4070 (driver 617.14), i5-12600KF, WinLibs GCC 15.2.0 r7, Release.
agc_parked_import_unmap: fails onmainafter 3.7 s with thestill pinnederror above, passes with the change in 0.8 s.ctest: 935 of 937 passed.hardware_oracleneeds an AMD GPU on Linux.agc_driver_prepared_shaders_deferred_undecodableexited with 0xc0000374 once under--parallel 6; alone it passed 5 of 5 times with this change and 5 of 5 without it. It does not touch host imports.tools/check_conventions.py --base origin/main: passed.d16eb7f779d382d21e7f3374a3871e54cce3dea150a9e7de1603a9011833c9f9;eboot.binandsce_module/libc.prxunwrapped from fSELF), onmain34a16b7f0with #4030 applied for its flat interpolation stop. The title initialises AGC before its window exists, so a headless device is replaced atAttachWindow. Its firstmunmap(0x21f3d8000, 0x10000)then waited 60 s (about 1 million waiter rounds per second, allidle, no live import over the range, one parked import over it) with a black window, and returnedEINVAL. With the change the first frame is presented at once. Diagnosis:APS5_NO_HOST_IMPORT=1removes the wait. A local counter in the waiter showedparkedOverlap=1on every round.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)🤖 Generated with Claude Code