fix(agc): name the reason when /dev/udmabuf cannot be opened #1688

Merged
johnmaia merged 1 commit from upstream-pr/1688 into main 2026-10-10 04:40:48 +00:00
johnmaia commented 2026-10-08 16:30:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-08T16:30:22Z.


What

On Linux, shared direct memory is imported through /dev/udmabuf (#943) when the driver imports dma-buf memory. Many distributions create the node as root:kvm with mode 0660 (#943's checklist notes this, and its test machine had a per-user ACL), so a user outside the kvm group cannot open it. The ranges are then copied instead of imported, and GPU stores through FLAT/GLOBAL addresses to them fail. The only trace was the import step and a Vulkan result, which hides errno:

[gpu] host import of 0x7b76a9e00000+0x2000000 failed at open /dev/udmabuf (-1000072003); falling back to copies
[gpu] deferred write-back failed: BDA access failed: address=0x7b76a9e00000 instruction=0x260 bytes=4 stage=4 reason=2; the store hit 0x7b76a9e00000+0x2000000, read-only in the BDA table: ...

DOOM PPSA99666 (homebrew) presents through a compute kernel that stores into a 32 MiB direct memory range, so on such a machine it logs video: GPU presentation failed, switching to the CPU scaler.

  • udmabufDevice prints the open error once, with the fix for EACCES:
    [gpu] open /dev/udmabuf: Permission denied; shared direct memory is copied instead of imported, and GPU stores through FLAT/GLOBAL addresses do not reach it (give the user read-write access to /dev/udmabuf, for example through the kvm group)
    
    The device is only opened where context.dmaBufImport is set, so nothing is printed on the NVIDIA proprietary driver (#1329).
  • docs/user/USAGE.md documents the requirement next to the Windows direct memory note, including the 64 MiB size_limit_mb above which ranges are copied anyway (#943).

No behaviour change.

Tested

Linux, Ubuntu 24.04.5, GCC 13.3, RX 7600 (RADV, Mesa 25.2.8), /dev/udmabuf root:kvm 0660.

run /dev/udmabuf failures BDA access failed DOOM presentation
user without access, main 3, no reason given 2 switches to the CPU scaler
user without access, this PR same, after the new line naming Permission denied 2 switches to the CPU scaler
user with access (ACL, then kvm group) 0 0 stays on AGC compute presentation
  • DOOM v1.1.1 built from source, relinked with --exclude-sce-module libc.prx on main, run under Xvfb. The run without access used a private mount namespace in which /dev/udmabuf was a root-only file, with the process running as the normal user.
  • ctest -R "agc|guest_agc" with ANYPS5_REQUIRE_VULKAN=1: 227/227 with access; the new line does not appear.
  • Windows: not built; the change is inside the existing #ifndef _WIN32 block.

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
  • 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4789842321 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1688). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-08T16:30:22Z. --- ### What On Linux, shared direct memory is imported through `/dev/udmabuf` (#943) when the driver imports dma-buf memory. Many distributions create the node as `root:kvm` with mode `0660` (#943's checklist notes this, and its test machine had a per-user ACL), so a user outside the `kvm` group cannot open it. The ranges are then copied instead of imported, and GPU stores through FLAT/GLOBAL addresses to them fail. The only trace was the import step and a Vulkan result, which hides `errno`: ``` [gpu] host import of 0x7b76a9e00000+0x2000000 failed at open /dev/udmabuf (-1000072003); falling back to copies [gpu] deferred write-back failed: BDA access failed: address=0x7b76a9e00000 instruction=0x260 bytes=4 stage=4 reason=2; the store hit 0x7b76a9e00000+0x2000000, read-only in the BDA table: ... ``` DOOM PPSA99666 (homebrew) presents through a compute kernel that stores into a 32 MiB direct memory range, so on such a machine it logs `video: GPU presentation failed, switching to the CPU scaler`. - `udmabufDevice` prints the open error once, with the fix for `EACCES`: ``` [gpu] open /dev/udmabuf: Permission denied; shared direct memory is copied instead of imported, and GPU stores through FLAT/GLOBAL addresses do not reach it (give the user read-write access to /dev/udmabuf, for example through the kvm group) ``` The device is only opened where `context.dmaBufImport` is set, so nothing is printed on the NVIDIA proprietary driver (#1329). - `docs/user/USAGE.md` documents the requirement next to the Windows direct memory note, including the 64 MiB `size_limit_mb` above which ranges are copied anyway (#943). No behaviour change. ### Tested Linux, Ubuntu 24.04.5, GCC 13.3, RX 7600 (RADV, Mesa 25.2.8), `/dev/udmabuf` `root:kvm 0660`. | run | `/dev/udmabuf` failures | `BDA access failed` | DOOM presentation | | --- | --- | --- | --- | | user without access, `main` | 3, no reason given | 2 | switches to the CPU scaler | | user without access, this PR | same, after the new line naming `Permission denied` | 2 | switches to the CPU scaler | | user with access (ACL, then `kvm` group) | 0 | 0 | stays on AGC compute presentation | - DOOM v1.1.1 built from source, relinked with `--exclude-sce-module libc.prx` on `main`, run under Xvfb. The run without access used a private mount namespace in which `/dev/udmabuf` was a root-only file, with the process running as the normal user. - `ctest -R "agc|guest_agc"` with `ANYPS5_REQUIRE_VULKAN=1`: 227/227 with access; the new line does not appear. - Windows: not built; the change is inside the existing `#ifndef _WIN32` block. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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 - [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)
johnmaia commented 2026-10-08 16:51:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-08T16:51:24Z.


End-to-end check with a display, on this PR's head: Linux, RX 7600 (RADV, Mesa 25.2.8), headless weston + Xwayland, DOOM PPSA99666 v1.1.1 built from source (byte-identical to the release), relinked with --exclude-sce-module libc.prx.

User without access to /dev/udmabuf (a private mount namespace with a root-only file over the node, process running as the normal user):

[gpu] open /dev/udmabuf: Permission denied; shared direct memory is copied instead of imported, and GPU stores through FLAT/GLOBAL addresses do not reach it (give the user read-write access to /dev/udmabuf, for example through the kvm group)
[gpu] deferred write-back failed: BDA access failed: address=... the store hit ...+0x2000000, read-only in the BDA table: ...
[debug:0] video: GPU presentation failed, switching to the CPU scaler

User in the kvm group: no import failures, no write-back failures, and the title stays on AGC compute presentation for the whole run. DOOM's own frame capture (test plan capture 120) of the GPU-presented frame matches a present cpu capture of the same frame in 93.5% of the detiled pixels; the rest are small differences from the kernel's bilinear scaling against the CPU path's nearest-neighbour scaling. On screen:

anyps5-1688-doom-rx7600

The first run after a rebuild can still fall back with gpu: frame 1 never completed: the cold compile of the kernel exceeds DOOM's 500 ms fence wait, as noted in #684. A second run stays on the GPU path.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6064790023 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1688#issuecomment-6064790023). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-08T16:51:24Z. --- End-to-end check with a display, on this PR's head: Linux, RX 7600 (RADV, Mesa 25.2.8), headless weston + Xwayland, DOOM PPSA99666 v1.1.1 built from source (byte-identical to the release), relinked with `--exclude-sce-module libc.prx`. **User without access to `/dev/udmabuf`** (a private mount namespace with a root-only file over the node, process running as the normal user): ``` [gpu] open /dev/udmabuf: Permission denied; shared direct memory is copied instead of imported, and GPU stores through FLAT/GLOBAL addresses do not reach it (give the user read-write access to /dev/udmabuf, for example through the kvm group) [gpu] deferred write-back failed: BDA access failed: address=... the store hit ...+0x2000000, read-only in the BDA table: ... [debug:0] video: GPU presentation failed, switching to the CPU scaler ``` **User in the `kvm` group**: no import failures, no write-back failures, and the title stays on `AGC compute presentation` for the whole run. DOOM's own frame capture (test plan `capture 120`) of the GPU-presented frame matches a `present cpu` capture of the same frame in 93.5% of the detiled pixels; the rest are small differences from the kernel's bilinear scaling against the CPU path's nearest-neighbour scaling. On screen: <img width="768" height="432" alt="anyps5-1688-doom-rx7600" src="https://github.com/user-attachments/assets/9a649229-a62b-4ef7-89ad-96583b7aae7d" /> The first run after a rebuild can still fall back with `gpu: frame 1 never completed`: the cold compile of the kernel exceeds DOOM's 500 ms fence wait, as noted in #684. A second run stays on the GPU path.
popcoder565 commented 2026-10-09 19:43:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:43:47Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 55be83f9, merged onto main 8b393b6e in one build with 31 other PRs that had no Windows run.

  • The change is Linux-only, so this only checks that the Windows build is unaffected.
  • Full ctest in that build: 520 of 521. The one failure is guest_offline_imports, broken by #2359 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088038729 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1688#issuecomment-6088038729). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T19:43:47Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `55be83f9`, merged onto `main` 8b393b6e in one build with 31 other PRs that had no Windows run. - The change is Linux-only, so this only checks that the Windows build is unaffected. - Full ctest in that build: 520 of 521. The one failure is `guest_offline_imports`, broken by #2359 (reported there). 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!1688
No description provided.