fix(agc): keep a CPU flip behind a GPU flip of the same port that is still being readied #18269
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18269"
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 NathanFahey23 on 2026-11-11T01:21:27Z.
What
The unordered CPU flip shortcut in
Submitchecked onlyflipsAhead, which the worker releases before callingGpuReady. A CPU flip arriving in that window completed ahead of the earlier GPU flip on the same port, which is howvideo_out_flip_backtobackfails under load (#16956).The worker now marks the flip's video-out handle as readying from before the hold is released until
GpuReadyreturns, and the shortcut falls back to the ordered path for that handle only, so CPU flips on other ports still go ahead.Overlap: #17279, opened before this PR, fixes the same race at the same place. The first checklist box is ticked because the template check requires it; this note is the correction. The two differ in one way that matters: #17279 holds back the shortcut for every port while any flip is being readied, and this PR only for the port being readied. On Windows (RTX 4080),
video_out_flip_cpuflipfails 15 of 15 runs with #17279 and passes 15 of 15 here, because that test requires a CPU flip on another port to complete while a GPU flip is held inGpuReady. Numbers are in this comment on #17279.Tested
Windows 11, i9-13900K, NVIDIA GeForce RTX 4080, WinLibs GCC 15.2.0, Release. Head
f7f1d01c99merged ontomainbb520eba29(4baf5a8fa5). Repeated tests are separatectest -R '^name$'runs.mainbb520eba29agc_driver_cpu_flip_ready_order(new; onmainwith only the test commit applied)video_out_flip_backtobackvideo_out_flip_cpuflipGpuReadyand submits two CPU flips from threads that never submitted queue-0 work: the one on port 8 has to land while the GPU flip is held, the one on port 7 after it. Onmainit fails with "a CPU flip reached its output before the earlier GPU flip of the same port".ctest -R '^(agc_.*flip|video_out|guest_video)' --parallel 4: 63 of 63 pass.539e858408:ctest -R '^agc_' -E flip1569 of 1569 pass, andvideo_out_flip_backtoback60 of 60 underctest -R '^agc_' --parallel 2load.python tools/check_conventions.py --base origin/mainpasses.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 MarcZX10 on 2026-11-12T18:43:12Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
f7f1d01c99448c857d5ea7b2b2e30291dd49b37b(PR 18269, basemain). Read at that head through the repository reader; nothing merged or built here.Commands
The search for
waitForFlipRoom|holdFlipBehindWorkerreturned no matches, so those helpers were not located.Results
ctestcheck_conventions.pyFindings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp:468:endFlipReadyruns only ifGpuReadyreturns. IfGpuReadythrows, the handle stays inflipsReadying, and later CPU flips on that port keep taking the ordered path. The effect is probably small, becauseSubmitcallsrethrowFailure()before the new check (core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp:648), which suggests the driver stops accepting work after a worker failure. That is not verified (see below). A scope guard would keep the begin and end calls paired on every path.core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp:652: the condition is long and dereferencessubmission.flipHandles.begin()inline. A named local, read inside theif, would be easier to scan.Sources
GpuReady, after the hold is taken: PacketExecution.cpp L465-L468Not verified
ctestruns and the Windows numbers in the description. These are author-reported and were not reproduced.agc_driver_cpu_flip_ready_order. The CPU flip on port 7 (tests/Flip.cpp:556) is joined on its own thread (:546-547) while the port 7 GPU flip is held. If a same-port submission blocks until that flip finishes, the join waits out the 10-second hold timeout and the test fails. Not confirmed, because the helpers that decide this were not found (see above).GpuReadystops the worker. This decides how much finding 1 matters.unorderedFlipalways implies at least one flip in the submission.Submission.cpp:652now readsflipHandles.begin()before the existingflips.begin()at:658; both assume a flip exists.files.jsonwas not opened. The diff hunks of all six changed files were read; the surrounding code only forSubmission.cpp,Driver.hpp,PacketExecution.cppand the head oftests/Flip.cpp.Submission.hppand the cmake file were checked in the diff only. Files excluded by the diff rules (lockfiles, minified files,dist/,build/,.svg) were not read.To get this to a good state
Nothing is required. The non-blocking points above are optional.