On 15/02/2023 17:41, Alan Stern wrote: > On Wed, Feb 15, 2023 at 11:40:15AM +0200, Roger Quadros wrote: >> Hi Thinh, >> >> Currently dwc3 gadget disconnects from the bus in the system suspend >> path. i.e. dwc3_gadget_suspend()->dwc3_disconnect_gadget(). >> >> Is it reasonable to expect dwc3 gadget to do a USB suspend instead of >> a USB disconnect during system suspend? > > Gadgets can't initiate a USB suspend. Only the host can. > > Did you mean to ask the opposite question? I.e., is it reasonable for a > dwc3 gadget to go into system suspend when it gets a USB suspend? Yes. Thanks for correcting. ;) > > In general, it's easiest for gadgets to disconnect from the USB bus when > their system suspends, if they aren't already in USB suspend. This is > because they would be unable to respond to requests from the host while > sleeping. Oh in that case the gadget driver will have to prevent a system suspend till the gadget is put into USB suspend by the USB host. I think this is a reasonable expectation. It could be an application specific requirement. i.e. whether to disconnect on system suspend or wait for USB suspend before system suspend. > >> At USB resume, system can wake up and resume and then dwc3 gadget can >> resume. >> >> I'd like to know your opinion please if this is a reasonable >> expectation or something just not possible to achieve. Thanks! > > There can be exceptions, but it's a dicey thing. The UDC hardware would > have to be able to send handshake packets back to the host while > remaining in low power, it would have to be able to generate a wakeup > signal to bring its system back to full power, and the system would have > to be able to resume in time for the gadget to respond to a request from > the host before the request times out. > > The situation is different if the gadget is already in USB suspend. > Then it only needs to be able to wake up its system when it gets a USB > resume signal. But the system would still have to wake up reasonably > quickly. I was more interested in this case where USB is suspended and then system suspends. Waking up the system on USB activity (while suspended) is taken care of by hardware. But I'm not sure if gadget driver will be up in time to respond to the request reasonably quickly. It would take a couple of seconds and is not hard time bound. Is this time mandated by the USB Spec or is it host implementation specific? cheers, -roger