-
Notifications
You must be signed in to change notification settings - Fork 37
feat(usb_host): HID Host add suspend/resume events #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
3394856 to
f1525db
Compare
0a327e0 to
fc3c43b
Compare
fc3c43b to
494766b
Compare
494766b to
618176b
Compare
034e930 to
2aad240
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on November 20
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
|
|
||
| // start data transfer | ||
| HID_RETURN_ON_ERROR( usb_host_transfer_submit(iface->in_xfer), "Unable to start data transfer"); | ||
| return ESP_OK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Transfer resubmitted for interfaces not in ACTIVE state
The hid_host_resume_interface function unconditionally resubmits the transfer if in_xfer is not NULL, regardless of the interface's previous state. This causes transfers to be submitted for interfaces that were in HID_INTERFACE_STATE_READY state before suspension, violating the state machine where transfers should only be active when the interface is in HID_INTERFACE_STATE_ACTIVE state. The transfer should only be resubmitted when last_state equals HID_INTERFACE_STATE_ACTIVE.
|
|
||
| if (hid_iface_curr->parent && (hid_iface_curr->parent->dev_addr == hid_device->dev_addr)) { | ||
| hid_host_suspend_interface(hid_iface_curr, false); | ||
| hid_host_user_interface_callback(hid_iface_curr, HID_HOST_INTERFACE_EVENT_SUSPENDED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unchecked return values in suspend/resume device functions
The hid_host_suspend_interface return value is ignored in hid_host_device_suspended, allowing the suspended event callback to be delivered even if the suspend operation failed. This creates inconsistency between the actual interface state and the events delivered to the user. The same issue exists in hid_host_device_resumed at lines 691-692 where hid_host_resume_interface errors are ignored.
- usb_host lib supports global suspend and resume
- backward compatibility with older IDF releases
- HID Host target tests
2aad240 to
cfb9e08
Compare
roma-jam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more question from my side for now:
Description
This MR adds Suspend/Resume events for HID class driver as a follow-up for the Global/Suspend resume MR in esp-idf
Changes
Added Suspend and Resume HID Host interface events
As the global Suspend issued by the USB Host Halts and flushes all EPs of all connected devices. The HID Host driver must submit the in transfer upon Resuming the root port (similar to
hid_host_device_start()when a new device is connected)Related
Testing
Checklist
Before submitting a Pull Request, please ensure the following:
Note
Add global suspend/resume handling and events to HID Host, with state management updates and comprehensive tests.
HID_INTERFACE_STATE_SUSPENDEDandlast_stateto track suspend/resume.hid_host_suspend_interface(),hid_host_resume_interface(), plus device-level iterators to broadcast events per interface.USB_HOST_CLIENT_EVENT_DEV_SUSPENDED/DEV_RESUMEDand log others viaswitch.include/usb/hid_host.h):HID_HOST_SUSPEND_RESUME_API_SUPPORTED(gated byUSB_HOST_LIB_EVENT_FLAGS_AUTO_SUSPEND).HID_HOST_INTERFACE_EVENT_SUSPENDEDandHID_HOST_INTERFACE_EVENT_RESUMED.test_app):suspend_resume_basic,auto_suspend_timer,resume_by_transfer_submit,sudden_disconnect_suspended_device.USB_HOST_LIB_EVENT_FLAGS_AUTO_SUSPENDby suspending root port.CHANGELOG.mdunder[unreleased]with global suspend/resume support.Written by Cursor Bugbot for commit 2aad240. This will update automatically on new commits. Configure here.