Repository navigation
xhc-whb04b-6: bound the display control transfer timeout - #4838
Conversation
|
Thanks for tracking this down. The timeout of 0 in This conflicts with #4761, hdiethelm's xhc-whb04b-6 backport to 2.9. That PR already removes these asserts and brings in master's reconnect handling, so once it is merged your first commit isn't needed. Could you wait for #4761, then rebase and keep only the timeout commit? I'll take it to master with the next merge-up. |
|
Agreed on both counts. I checked #4761's head (
Marked the PR a draft in the meantime. Once #4761 is merged I will push the branch as a single timeout-only commit on top of the new Caveat that still stands: the field freeze is not reproduced, so the PR claims only that a stalled display transfer becomes an error the reconnect path can handle instead of an unbounded wait. If the machine catches one, its thread-state dump goes here as a comment. |
|
@hansfbaier #4761 merged |
a7f14d8 to
d211a91
Compare
|
Rebased onto |
|
The 1 s deadline makes sense to me. I tried to follow what happens after it fires, and I'm stuck on a few questions:
If those answers point the way I think they do, the loop keeps running with a 1 s stall per pass and |
d211a91 to
5d0bd58
Compare
|
All four point the same way, and you are right about the outcome: as pushed, the timeouts made the stall finite but nothing recovered. Answers against
Setting While the receiver stays wedged that cycle repeats every ~4 s, so Pushed |
sendDisplayData() sent each display block with a timeout of 0, which libusb reads as "wait as long as it takes". That call runs on the thread that pumps libusb events, so a receiver that stops completing the transfer freezes the whole component - jog dial included - while whb.pendant.is-connected stays TRUE until the receiver is unplugged. Bound the transfer to 1 s and report the failure through transferFailed, the flag Usb::process() already watches: it closes the device, sets mDoReconnect, and the component's outer loop re-enumerates. The second half is needed. The error branch only set mDoReconnect, which is read in Usb::init(), and init() is reached only after process() returns, which needs isDeviceOpen() - that is, deviceHandle - to be null. Nothing on the display path cleared it, so the loop retried the stalled write once per pass with the connection still reported healthy. A timed-out IN transfer is an idle tick and never sets transferFailed either, so a receiver that stops answering the HID control pipe produced no failure at all. Checked without hardware, against a stub libusb reporting a phantom receiver that times the IN transfer out every 750 ms like an idle pendant and returns LIBUSB_ERROR_TIMEOUT from the control transfer after 40 calls: with the timeout alone the log is 47 "transmission failed, try to reconnect ..." lines in 12 s and nothing else; with transferFailed it goes to "connection lost, cleaning up", the 3 s pause, re-enumeration, claiming the interface and "enabling reception ... ok". Field test on hardware is still outstanding.
5d0bd58 to
9784eaf
Compare
|
Correction to my previous message: The PR body describes what is actually in the branch now. |
|
Could you give it a check on actual hardware? |
|
Hardware log, from the machine this was found on (LinuxCNC 2.9.10, Pi 5, receiver Component log, from the display write that hit the dead device:
Sampler on the component's main thread, 5 s cadence, over the same window: Three forced disconnects, three recoveries, 4.5-5 s each. Before this change the same event left the component alive with Two limits on what this shows, so it is not read as more than it is: the build on the machine is the
|
Problem
A WHB04B-6 handwheel stops responding after a few hours of use, with no error
anywhere:
whb.pendant.is-connectedstays TRUE,dmesgis clean, the componentkeeps running, the mill keeps working. Unplugging and replugging the receiver
brings it back; power-cycling the pendant does not.
Usb::sendDisplayData()sends each display update withand libusb reads a timeout of 0 as "wait as long as it takes". The call runs on
the thread that pumps libusb events (
XhcWhb04b6Component::process()), so areceiver that stops completing the transfer stops the component: the jog dial is
dead, the input callback never runs again, and
is-connectedstays TRUE untilthe receiver is unplugged, which aborts the blocked transfer with NO_DEVICE.
Change
a millisecond, so the deadline costs nothing until something is wrong.
transferFailed, not onlymDoReconnect.Both are needed.
mDoReconnectis read in one place,Usb::init()(usb.cc:607),and
init()is reached only afterprocess()returns, which requiresisDeviceOpen()— that is,deviceHandle— to be null. The error branch clearednothing, so with the timeout alone the loop just retried the stalled write once
per pass: a 1 s stall instead of an infinite one, connection still reported
healthy.
transferFailedis the flagUsb::process()(usb.cc:750) acts on: itcloses the device, sets
mDoReconnect, and the outer loop inXhcWhb04b6Component::run()re-enumerates and reconnects.A timed-out IN transfer (
usb.cc:523) deliberately does not settransferFailed,because for an idle dial that timeout is normal. That is also why a receiver that
stops answering the HID control pipe produced no failure at all: the only event
that would have been noticed is the 750 ms idle timeout.
Testing
Builds and runs on LinuxCNC 2.9.10, Raspberry Pi 5 (arm64), receiver
10ce:eb93:starts, connects, updates the display, moves the axes. The freeze itself needs a
wedged receiver and was not reproduced on demand, so there is no field log yet.
The machine runs a 5 s sampler of the component's thread state plus a dump
script, and a field occurrence will be reported here.
Without hardware, the state machine was exercised against a stub libusb that
reports a phantom receiver, times the interrupt IN transfer out every 750 ms like
an idle pendant, and returns
LIBUSB_ERROR_TIMEOUTfrom the control transferafter 40 calls:
While the receiver stays wedged that cycle repeats every ~4 s, with
is-connecteddropping and returning instead of a silent freeze. A replug stillcures it as before, since NO_DEVICE reaches the same path.
Compile-checked against
2.9after #4761: builds, warning count unchangedcompared with the same tree without the patch (all
-Wvolatilefromhal_float_t).