fix(agc): fail a failed submission's flips before reporting the failure #2246

Merged
zmeizy merged 2 commits from upstream-pr/2246 into main 2026-10-10 04:46:02 +00:00
zmeizy commented 2026-10-09 13:06:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zmeizy on 2026-10-09T13:06:53Z.


What

When a queue worker fails, Driver::run calls ReportFailure(error) and only then calls Fail on the flips of the submission it was executing. ReportFailure publishes the failure and wakes the idle waiters, so a thread returning from AgcDriverWaitIdle with the failure can still see one of those flips neither completed nor failed. agc_driver_flip hits this in testFailure: failed flip was completed successfully.

This fails the executing submission's flips first, as ReportFailure already does for the pending submissions it drops before it notifies. One line moved in QueueWorker.cpp.

The only IFlipRequest::Fail outside the tests (VideoOut's FlipRequest::Fail) takes only its own config mutex and does not call into the driver, and the only AgcDriverWaitIdle call outside the guest is the VideoOut constructor, before its threads start, so failing the flips first cannot deadlock.

Tested

Ubuntu 24.04, GCC 13.3, lavapipe (Mesa 25.2.8, LLVM 20), 4 cores.

  • agc_driver_flip with four copies running at once: 2 of 240 runs failed before the change; 0 of 480 after it on a8b032b2 and 0 of 480 on 745b775e.
  • With the old order and a 50 ms sleep between ReportFailure and the flips' Fail, 5 of 5 runs fail with failed flip was completed successfully.
  • Full ctest --parallel 4 --timeout 120 on d70b8998 with this change and the two other test fixes applied: 513 tests, 0 failures.

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 in TechnicalDebt (n/a)
  • 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 (n/a)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4800819626 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2246). Originally posted by [zmeizy](https://github.com/zmeizy) on 2026-10-09T13:06:53Z. --- ### What When a queue worker fails, `Driver::run` calls `ReportFailure(error)` and only then calls `Fail` on the flips of the submission it was executing. `ReportFailure` publishes the failure and wakes the idle waiters, so a thread returning from `AgcDriverWaitIdle` with the failure can still see one of those flips neither completed nor failed. `agc_driver_flip` hits this in `testFailure`: `failed flip was completed successfully`. This fails the executing submission's flips first, as `ReportFailure` already does for the pending submissions it drops before it notifies. One line moved in `QueueWorker.cpp`. The only `IFlipRequest::Fail` outside the tests (VideoOut's `FlipRequest::Fail`) takes only its own config mutex and does not call into the driver, and the only `AgcDriverWaitIdle` call outside the guest is the VideoOut constructor, before its threads start, so failing the flips first cannot deadlock. ### Tested Ubuntu 24.04, GCC 13.3, lavapipe (Mesa 25.2.8, LLVM 20), 4 cores. - `agc_driver_flip` with four copies running at once: 2 of 240 runs failed before the change; 0 of 480 after it on `a8b032b2` and 0 of 480 on `745b775e`. - With the old order and a 50 ms sleep between `ReportFailure` and the flips' `Fail`, 5 of 5 runs fail with `failed flip was completed successfully`. - Full `ctest --parallel 4 --timeout 120` on `d70b8998` with this change and the two other test fixes applied: 513 tests, 0 failures. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt (n/a) - [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 (n/a) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Ha6Tsy62AFUyp9a5Mf7vjA
popcoder565 commented 2026-10-09 15:24:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:24:56Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 15a87789, merged onto main d70b8998 in one build with 33 other AGC/shader PRs that had no Windows run.

  • This PR has no test of its own. It builds, and the full suite passes apart from the failure below.
  • Full ctest in that build: 514 of 515. The one failure is #2257's new test, which is registered without the Windows PATH setup.

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083915108 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2246#issuecomment-6083915108). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:24:56Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `15a87789`, merged onto `main` d70b8998 in one build with 33 other AGC/shader PRs that had no Windows run. - This PR has no test of its own. It builds, and the full suite passes apart from the failure below. - Full ctest in that build: 514 of 515. The one failure is #2257's new test, which is registered without the Windows `PATH` setup. No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
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!2246
No description provided.