ACK mailbox messages + logging fixes - #44
Merged
Merged
Conversation
avtolstoy
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
wiring/sleep20suite against a device, the runner intermittently sawUsbError(LIBUSB_TRANSFER_STALL) on the control IN that reads a mailbox message. The runner treated that as a request failure, closed the device, and on the next iteration_open()triggered a kernel iSerial probe that re-hit the samexhci_hcdbug, turning one transient stall into a multi-second cascade that escalated to a fixture-reset of both DUT and tester and desynced the suite.cycleUSBwithPortPathsilently no-op'd when uhubctl wasn't configured or installed, but its four call sites indevice.jslogged"Cycled USB hub.port device is attached to"either way, so logs claimed a recovery had happened when it hadn't.Solution
ackMailbox(id)that issues ac:'A'request to the device after each successfulreadMailbox. This is what completes the device-side mailbox entry and, by inserting a vendor control transaction (whose IN reads carry no payload, so they're the kernel-bug-safe variety) between the heavy-payload readMailbox and getStatus exchanges, suppresses the phantom-EPIPE stalls the kernel otherwise produces.waitTest's mailbox handler so local state (expectingReset/expectingSafeMode/mboxMessages) is set beforeawait ackMailbox, andsetWillDetach(true)+close()are deferred until after the ACK lands. CallingsetWillDetach(true)first made_open()'sisAttached()return false and broke ACK retries.UsbErrorin_request. Closing forced an_open()cycle whose iSerial probe re-triggered the kernel bug; leaving the handle open lets the next request retry cleanly.UsbErrorswallow inwaitTest's status-request path beyond safe-mode so a single transient stall reportsSTATUS_RUNNINGand retries, instead of escalating to a fixture-recovery reset.cycleUSBwithPortPathreturntrue/falseto indicate whether the cycle actually happened, and update the four call sites indevice.jsto log"Hub-cycle disabled, ..."(warn) when the feature is off instead of misleadingly claiming a cycle succeeded.Testing
wiring/sleep20on the affected Linux rig: 46/46 tests passing, zero application-level USB stalls in usbmon captures.References
fix/mailbox-usb-stall(indevice-os-test-runner)fix/test-runner-mailbox-usb-stall