On Fri, Oct 25, 2024 at 9:37 PM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > > On Thu, Oct 24, 2024 at 11:37:50AM +0200, Bart Van Severen wrote: > > Hi, > > > > We have a use case to remote control a pc through a composite gadget > > consisting of keyboard, mouse and tablet functions. > > The problem we face is that when the pc is sent to sleep, we cannot > > wake it by writing to the hid device, which is what you > > would expect to work. > > > > We're running on Xilinx Zynqmp soc/DWC3 290A. > > > > We have set the bmAttributes ch9 USB_CONFIG_ATT_WAKEUP bit and do see > > the set_feature request to enable remote > > wakeup, just before the pc goes to sleep. > > Do you see a wakeup request from the gadget to the host? No, I don't see any wakeup request towards the host. > > > We noticed the recent relevant work > > https://lore.kernel.org/linux-usb/1679694482-16430-1-git-send-email-quic_eserrao@xxxxxxxxxxx/, > > regarding function suspend/resume and remote wakeup improvements. > > > > However, the main question we have is: what would be the right place > > in the gadget framework to fix the issue where a hid write > > doesn't trigger a remote wake up when the usb device is suspended and > > the host has enabled remote wakeup. > > Probably the drivers/usb/gadget/function/f_hid.c file. I don't know > anything about how this gadget driver works, but the file doesn't have > any calls to usb_gadget_wakeup(), which means it won't generate a wakeup > request no matter what you write to it. > > Alan Stern > That's what my initial thought was also, and that certainly works. But then I wondered if it isn't a better idea to handle this further down, to avoid having to write similar code in all function drivers, say in the gadget core? > > Some further context: > > DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE are disabled by default > > (https://github.com/torvalds/linux/commit/799e9dc82968c66d6f8faf96d0bd01e515b0b2f2#diff-5e9721ccc2bd0a326d3b1a8cbcd9d91130774b1a7d06533c39074ad67aee7e96L1540), > > so dwc3 gadget driver isn't interrupted when host goes to sleep, but > > it does get DWC3_DEVICE_EVENT_WAKEUP when it wakes up. > > So the gadget device in turn is not suspended when the pc goes to sleep. > > > > dwc3_send_gadget_ep_cmd does issue __dwc3_gadget_wakeup when cmd is > > DWC3_DEPCMD_STARTTRANSFER. > > It has no provision for doing the same when cmd is DWC3_DEPCMD_UPDATETRANSFER, > > which is our current patch to make it work in a pragmatic way. > > > > Sorry if the mail format isn't what you normally expect, this is my > > first time posting... > > > > Br, > > > > Bart Van Severen > > Br, Bart