Files
John Lian a8141daaca feat(usb): gadget: f_hid: add wakeup_on_write support (#57)
* usb: gadget: f_hid: add wakeup_on_write support

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: https://github.com/jetkvm/kvm/issues/120
Closes: https://github.com/jetkvm/kvm/issues/674

* fix: guard func.config dereference in f_hidg_write

Move the hidg->func.config->cdev dereference inside the
wakeup_on_write guard block and add a NULL check on func.config
before accessing cdev. This prevents a potential NULL pointer
dereference if f_hidg_write races with unbind, where func.config
can be NULL before the spinlock is acquired.

The cdev variable was only used for the wakeup call, so scoping
it to the guard block is safe.
2026-04-08 12:36:08 +02:00
..
2025-11-24 19:26:54 +02:00