Repository navigation
usbhid: Retry fetching the report descriptor - #390
Merged
Merged
Conversation
So far only seen with a wireless mouse on a Logitech Unifying receiver. The receiver can time out on GET_DESCRIPTOR(REPORT) while still starting up after power is applied, for example after resume or when switched back through a USB switch. On failure, hms falls back to the boot protocol descriptor and the mouse loses its wheel. Wired mice have not shown the problem. Retry the request up to five times with a 100 ms pause, stopping early on a stall since that means the device has no descriptor. Linux usbhid retries this request in the same way.
Reviewer's GuideImplementationRetry report-descriptor requests up to five times with 100 ms pauses, stop immediately on a stall, and log successful retries.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Thank you for taking the time to contribute to FreeBSD!
Please review CONTRIBUTING.md, then update and push your branch again. |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="sys/dev/usb/input/usbhid.c" line_range="551-556" />
<code_context>
+ * right after resume. A failure makes hms fall back to the boot
+ * protocol descriptor and lose the wheel, so retry a few times.
+ */
+ for (retry = 0;; retry++) {
+ error = usbd_req_get_report_descriptor(sc->sc_udev, NULL,
+ buf, len, sc->sc_iface_index);
+ if (error == 0 || error == USB_ERR_STALLED || retry == 4)
+ break;
+ usb_pause_mtx(NULL, USB_MS_TO_TICKS(100));
+ }
</code_context>
<issue_to_address>
**Repeated timeouts delay device attachment**
When the descriptor request times out on all five attempts, a report-descriptor request that times out on every attempt consumes the 5-second default timeout each time, so this loop can block HID child attachment for roughly 25 seconds before returning failure.
Bound the total retry time or use a shorter timeout for each retry.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: sys/dev/usb/input/usbhid.c:556
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.
So far only seen with a wireless mouse on a Logitech Unifying receiver. The receiver can time out on GET_DESCRIPTOR(REPORT) while still starting up after power is applied, for example after resume or when switched back through a USB switch. On failure, hms falls back to the boot protocol descriptor and the mouse loses its wheel. Wired mice have not shown the problem.
Retry the request up to five times with a 100 ms pause, stopping early on a stall since that means the device has no descriptor. Linux usbhid retries this request in the same way.
Summary by Sourcery
Bug Fixes: