Windows race condition fix#431
Conversation
When reinitializing USB on Windows, MainWindow now triggers a driver shutdown if the driver is connected and waits for a shutdownComplete signal before running reinitUsbStage2. The winUsbDriver gained a shutdownProcedure that stops timers, aborts and flushes pipes, waits (with a 3000ms timeout) for overlapped ISO transfers to complete, sets connection state, and emits shutdownComplete. Guards were added to isoTimerTick and resubmission paths to avoid scheduling work during shutdown. Header changes add shutdown flags, a transferPending array, a shutdownElapsed timer and the shutdownComplete signal. Also includes minor qDebug formatting fixes and an explanatory comment about MAX_OVERLAP in the destructor.
Make pipeID handling platform-aware and tidy winusb behavior. In the USB generic driver, the pipeID array is now conditionally sized (NUM_ISO_ENDPOINTS on Windows, legacy 3 otherwise) and debug output on Windows casts pipeID to int to avoid char printing issues (genericusbdriver.h/.cpp). In the winusb driver, the overlapping-handle release loop now uses NUM_FUTURE_CTX instead of MAX_OVERLAP to avoid a potential out-of-bounds assumption, and the killMe() call was removed from isoTimerTick under non-WINDOWS_32_BIT to prevent an immediate termination on frame phase errors.
Add Desktop_Interface/run_test_win, Desktop_Interface/build_test_win_custom, and Desktop_Interface/tools to .gitignore so generated test/build artifacts are not tracked. Keeps the existing Desktop_Interface/_install entry and adds a trailing newline to the file.
Labels for nets PDI_CLK and PDI_DATA swapped to match ATxmega32A4U pinout. saved as Kicad 9.0 files
|
I did a basic test with Multimeter (mode 5) on Windows 11 and it works. @turboencabulator would you perhaps have the time for a code review? |
|
"Frame phase error of 3" means that the data might be copying across into the buffer in the wrong order. Can you see any discontinuities when feeding back a "weird" waveform like a 792Hz sine wave into the scope CH1? |
I haven't tested that yet. I can put this PR as a draft and open it again when the frame phase error is corrected? Otherwise I can test it when I have time or someone else can feel free to check it out. |
just set it to DRAFT status |
turboencabulator
left a comment
There was a problem hiding this comment.
I've only got a few minor suggestions. This isn't a very thorough review, I'm not familiar with the Windows stuff and I don't have easy access to a Windows machine.
Improve the Windows USB reconnect path by making shutdown drain outstanding overlapped transfers before driver teardown and by withholding misaligned isochronous buffers until frames resynchronize after hotplug events. Also keep pipe ID debug output numeric across platforms for clearer diagnostics.
removed my comments on formatting. reordered winusbdriver members for the $$$cache$$$
…ster/Labrador into lobster-pr-clean-winfix
…freshLobster/Labrador into lobster-pr-clean-winfix" This reverts commit 7b25a52, reversing changes made to 71fbe9a.
hoping to god this works or I just wasted like 8 hours of my life This reverts commit 71fbe9a.
|
I could use some help on fixing this. I dont know what happened, but my local build got all messed up and I cant get it back to the state where it worked properly. |
this is the same patch I did for issue #333, but applied to the windows specific code. It builds, it runs fine, tests fine,
logs look good save for:Frame phase error of 3
in the logs which just tells me that there's some minor isochronous endpoint frame alignment that needs to be adjusted.
That should have it's own separate issue and PR though. this is for #333 and #382
Edit: fixed the alignment/ordering