xemu icon indicating copy to clipboard operation
xemu copied to clipboard

OHCI: Fixed a bug in the OHCI implementation from QEMU

Open faha223 opened this issue 1 year ago • 5 comments

This fixes the issue with USB passthrough in which a race condition is created when using the async api in libusb to write to and read from multiple endpoints simultaneously

Addresses this bug: https://github.com/xemu-project/xemu/issues/1239

faha223 avatar Sep 23 '23 14:09 faha223

Since this an issue with QEMU, should this perhaps be posted to the ML for comments / future merge?

GXTX avatar Sep 23 '23 15:09 GXTX

Yes, it should. I'll need to look into what their patch submission process is

faha223 avatar Sep 23 '23 15:09 faha223

This fixes the issue with USB passthrough in which a race condition is created when using the async api in libusb to write to and read from multiple endpoints simultaneously

Can you share more specifics about the race condition to help me understand the root cause of the issue?

mborgerson avatar Oct 17 '23 23:10 mborgerson

Every USBEndpoint that shares a single OCHI Controller shares a single buffer for reading and writing data. The libsub async API returns after sending a request and responses are handled later.

If a read request is sent and a write request is sent after the read request is sent but before the response comes in, then the read request has a chance to return data from the write request. I observed this while using the Steel Battalion controller but also while using the gamepad.

Converting the libusb passthrough code to use the sync API fixes the issue by blocking on every read and write request. This introduces latency so fixing the code to work properly with the async API is preferred.

faha223 avatar Oct 22 '23 21:10 faha223

And here I was, spending my day thinking I borked something in my USB driver.

This PR appears to resolve the issue stated in #1239. I was able to verify this with Stellar's Xbox One driver where we were running into endpoint data appearing in endpoint interrupts under xemu. With the patch, I was able to verify that the correct behavior matches that of our hw tests.

I look forward to reviewing the patch once @mborgerson's comments are addressed.

@faha223 would you mind dropping me an email? ([email protected]). Thank you for your contribution.

LoveMHz avatar Nov 16 '23 20:11 LoveMHz