feat(usb): gadget: f_hid: add wakeup_on_write support#57
Open
jlian wants to merge 1 commit intojetkvm:devfrom
Open
feat(usb): gadget: f_hid: add wakeup_on_write support#57jlian wants to merge 1 commit intojetkvm:devfrom
jlian wants to merge 1 commit intojetkvm:devfrom
Conversation
This was referenced Mar 2, 2026
Add an opt-in wakeup_on_write configfs attribute to the HID function driver. When enabled, each write to /dev/hidgN calls usb_gadget_wakeup() before queuing the USB request, allowing HID input to wake a suspended host. The configuration descriptor must also advertise remote wakeup capability (bmAttributes bit 5) for the host to arm the feature during enumeration. This is useful for KVM-over-IP devices that need to wake a sleeping host machine by sending keyboard or mouse input. Tested on JetKVM v2 (RV1106 SoC, DWC3 v3.30a) waking a Windows 11 host from S3 sleep via Intel xHCI USB 3.1 controller. Host wakes in ~4 seconds from HID keystroke. Closes: jetkvm/kvm#120 Closes: jetkvm/kvm#674
6761342 to
900c018
Compare
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.
Summary
Add a
wakeup_on_writeconfigfs attribute to the USB HID gadget function driver (f_hid). When enabled, the driver callsusb_gadget_wakeup()before writing each HID report, allowing the gadget to wake a suspended host via USB remote wakeup.This is the kernel-side prerequisite for USB remote wakeup on JetKVM. The companion Go app change sets
bmAttributes = 0xa0and enableswakeup_on_writeon all HID functions during gadget setup. The Go app side changed, required to make this feature work end to end, are at jetkvm/kvm#1235.Related: jetkvm/kvm#120, jetkvm/kvm#674.
How it works
wakeup_on_writeboolean attribute in the HID function's configfs directory0(off). Must be set to1before the function is allocated (same lifecycle asno_out_endpoint)f_hidg_write()callsusb_gadget_wakeup()at the top of each write. If the host hasn't negotiated remote wakeup or the bus isn't suspended, the call returns an error that is safely ignoredChanges
f_hid.c: Addwakeup_on_writefield tof_hidg, callusb_gadget_wakeup()inf_hidg_write(), register configfs attribute viaF_HID_OPTmacrou_hid.h: Addwakeup_on_writefield tof_hid_optsTesting
Tested on JetKVM v2 (RV1106, DWC3 v3.30a, kernel 5.10.160). Host: Windows 11 (S3 sleep), Intel Z390 xHCI.
wakeup_on_writeattribute appears in configfs for all HID functionsbmAttributes = 0xa0)usb_gadget_wakeup()→ DWC3 sends Recovery on the bus → host wakespowercfg /lastwakeconfirms wake source: Intel USB 3.1 eXtensible Host ControllerMore testing details at jetkvm/kvm#1235.