vadimgrn / usbip-win2

USB/IP Client for Windows
GNU General Public License v3.0
469 stars 40 forks source link

USB device disconnect and shutdown #74

Open jrogala opened 5 months ago

jrogala commented 5 months ago

I try to make a VRS Wheel Base work via usbip. I have my host (ubuntu, fresh install) and client (windows, VRS driver installed). I can declare and bind my usb wheel base but whenever I attach to it, I lose the connection to it and I have to do a hard reboot of the wheel base (pluging/unpluging does not work).

Of course if I plug directly I have none of this and everything works fine.

I believe it may have to do with the firmware of the controller itself, but I don't have any experience on this low level stuff so I cannot pinpoint where is the problem. Isn't it supposed to be passthrough?

Here are the log:

vadimgrn commented 5 months ago

I see that the couple of IRPs (seqnum 61, 63) were not completed during the detaching, that causes this issue. I'll give you a build to test if I make a fix.

[3]14dc bulk_or_interrupt_transfer:req 6236f2a8 -> PipeHandle a04c6ca0, IN|SHORT_OK, TransferBufferLength 64
[3]14dc send:req 6236f2a8 -> 48{seqnum 59, devid 0x1000e, in[1]}, cmd_submit: flags 0, length 64, start_frame 0, isoc[-1], interval 4
[3]14dc recv_loop:req 62c8ff68 <- 111{seqnum 57, devid 0, in[0]}, ret_submit: status 0, actual_length 63, start_frame 0, isoc[0], error_count 0

[3]14dc bulk_or_interrupt_transfer:req 5ba212d8 -> PipeHandle a04c6ca0, IN|SHORT_OK, TransferBufferLength 64
[3]14dc send:req 5ba212d8 -> 48{seqnum 61, devid 0x1000e, in[1]}, cmd_submit: flags 0, length 64, start_frame 0, isoc[-1], interval 4
[3]14dc recv_loop:req 6236f2a8 <- 111{seqnum 59, devid 0, in[0]}, ret_submit: status 0, actual_length 63, start_frame 0, isoc[0], error_count 0

[3]14dc bulk_or_interrupt_transfer:req 62c8ff68 -> PipeHandle a04c6ca0, IN|SHORT_OK, TransferBufferLength 64
[3]14dc send:req 62c8ff68 -> 48{seqnum 63, devid 0x1000e, in[1]}, cmd_submit: flags 0, length 64, start_frame 0, isoc[-1], interval 4

[11]14dc TRACE_LEVEL_VERBOSE usbip::recv_thread_function:dev 62e32238, detaching
[3]14dc TRACE_LEVEL_INFORMATION `anonymous namespace'::detach:dev 62e32238, connection closed
[3]14dc TRACE_LEVEL_VERBOSE usbip::vhci::device_state_changed:192.168.1.19:3240/1-1, port 1, disconnected, subscribers 0
[3]14dc detach:dev 62e32238
vadimgrn commented 5 months ago

I've found a deadlock in the detach code, will give the test build tomorrow.

vadimgrn commented 5 months ago

Please try this build https://drive.google.com/file/d/1CLo_iCieqlxLeUukgpsXGiEdGEULO8YJ/view?usp=sharing

jrogala commented 5 months ago

Hello, thanks for your quick answer and build, it still does it with the newest build.

Here are the new log: usbip-ude.txt usbip-flt.txt

Thanks for your time!

vadimgrn commented 5 months ago

I did not expect that this will fix the issue, I just fixed the deadlock during the detach. I think usbip server is closing the connection for some reason. To make sure you could set -flag 0x1F instead of 0xF in command tracelog.exe -start %NAME%-ude -guid #ed18c9c5-8322-48ae-bf78-d01d898a1562 -f %NAME%-ude.etl -flag 0xF -level 5