Skip to content

feat(usbd): submit and cancel asynchronous USB transfers - #2228

Closed
erick-dsnk wants to merge 2 commits into
boykopovar:mainfrom
erick-dsnk:codex/feat-usbd-async-transfers
Closed

erick-dsnk wants to merge 2 commits into
boykopovar:mainfrom
erick-dsnk:codex/feat-usbd-async-transfers

Conversation

@erick-dsnk

Copy link
Copy Markdown
Contributor

What

Depends on #2224.

Implement sceUsbdSubmitTransfer and sceUsbdCancelTransfer on the source-built libusb backend introduced by #2224. Submitted transfers now reach native USB I/O, completions copy status, byte counts and isochronous packet results back to the guest object, and cancellation completes through the same callback path. A separate native transfer invokes the original guest callback through the System V ABI, including on Windows. Supporting allocation/free changes preserve resubmission and freeing from callbacks, prevent freeing pending transfers, and release auto-free buffers through the guest heap.

This contribution adds 2 implementations beyond #2224: CPU libraries move from 2600/3044 (85.41%) to 2602/3044 (85.48%). The 22 synchronous implementations and dependency files visible in the current diff belong to #2224; they are inherited unchanged. This branch is based on its exact head 3dbf85f0d9be6a45baa955d28528b46058426e27 and should merge after it. sceUsbdCheckConnected still throws.

The asynchronous signatures follow OpenOrbis Usbd.h and shadPS4 declarations. Transfer ownership, flags and completion behavior follow libusb 1.0.30. There is no additional third-party dependency in this follow-up.

PS5 hardware ABI, Windows asynchronous execution, game behavior and physical control/interrupt payloads remain unverified. Linux native tests enumerate devices and read descriptors; transfer completion tests use a deterministic native submission/event backend. These limits are recorded in TechnicalDebt.

Tested

Linux x86-64, GCC 13.3.0, Release, BUILD_TESTING=ON:

  • Full CMake configure/build and --target libs: passed.
  • guest_usbd, guest_usbd_control, guest_usbd_async: passed. Native tests enumerated 17 host devices and read descriptors. The new asynchronous tests use real libusb allocations/context, wrapping only native allocation/free accounting and submit/cancel/event delivery. They verify error translation, double submission rejection, pending-free rejection, cancellation, guest callback identity and data, resubmission, freeing from callbacks, isochronous results, and guest-heap auto-free ownership.
  • AddressSanitizer and UndefinedBehaviorSanitizer asynchronous suite: passed.
  • Full ctest --parallel 2 --timeout 30: 512 passed, 1 skipped (agc_driver_storage_cache_budget), 2 failed (agc_driver_dcc_keys_first_write assertion and agc_driver_flat_store timeout). Neither involves USB.
  • Serial recheck on this head: DCC assertion reproduced; flat-store still exceeded 30 s. On the exact feat(usbd): add native synchronous USB backend #2224 parent, after normal configure/full build/libs, the identical DCC assertion reproduced and flat-store passed in 29.14 s. That test is close to the fixed 30-second limit; no AGC code or timeout was changed.
  • Conventions check against current upstream/main: passed.
  • Windows build/runtime and a game/homebrew: not tested locally for this follow-up.

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: feat(usbd): add native synchronous USB backend #2224
  • AI-assisted: yes

Привалов Александр Владимирович and others added 2 commits October 9, 2026 15:09
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2351 docs/dev/TechnicalDebt.md L246
#2364 docs/dev/TechnicalDebt.md L23-24

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing with #2224: no title reaches the async Usbd calls on main. Please reopen when one does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants