mbox series

[v2,0/5] Add function suspend/resume and remote wakeup support

Message ID 1673992507-7823-1-git-send-email-quic_eserrao@quicinc.com (mailing list archive)
Headers show
Series Add function suspend/resume and remote wakeup support | expand

Message

Elson Roy Serrao Jan. 17, 2023, 9:55 p.m. UTC
Changes in v2
 - Added a flag to indicate whether the device is remote wakeup capable.
 - Added an async parameter to _dwc3_gadget_wakeup() API and few cosmetic
   changes.
 - Added flags to reflect the state of  function suspend and function remote
   wakeup to usb_function struct rather than function specific struct (f_ecm).
 - Changed the dwc3_gadget_func__wakeup() API to run synchronously by first
   checking the link state and then sending the device notification. Also
   added debug log for DEVICE_NOTIFICATION generic cmd.
 - Added changes to arm the device for remotewakeup/function remotewakeup
   only if device is capable.

An usb device can initate a remote wakeup and bring the link out of
suspend as dictated by the DEVICE_REMOTE_WAKEUP feature selector.
To achieve this an interface can invoke gadget_wakeup op and wait for the
device to come out of LPM. But the current polling based implementation
fails if the host takes a long time to drive the resume signaling specially
in high speed capable devices. Switching to an interrupt based approach is
more robust and efficient. This can be leveraged by enabling link status
change events and triggering a gadget resume when the link comes to active
state.

If the device is enhanced super-speed capable, individual interfaces can
also be put into suspend state. An interface can be in function suspend
state even when the device is not in suspend state. Function suspend state
is retained throughout the device suspend entry and exit process.
A function can be put to function suspend through FUNCTION_SUSPEND feature
selector sent by the host. This setup packet also decides whether that
function is capable of initiating a function remote wakeup. When the
function sends a wakeup notification to the host the link must be first
brought to a non-U0 state and then this notification is sent.

This change adds the infrastructure needed to support the above
functionalities.

Elson Roy Serrao (5):
  usb: gadget: Add remote wakeup capable flag
  usb: dwc3: Add remote wakeup handling
  usb: gadget: Add function wakeup support
  usb: dwc3: Add function suspend and function wakeup support
  usb: gadget: f_ecm: Add suspend/resume and remote wakeup support

 drivers/usb/dwc3/core.h               |  4 ++
 drivers/usb/dwc3/debug.h              |  2 +
 drivers/usb/dwc3/ep0.c                | 16 +++---
 drivers/usb/dwc3/gadget.c             | 93 ++++++++++++++++++++++++++++++++---
 drivers/usb/gadget/composite.c        | 29 +++++++++++
 drivers/usb/gadget/function/f_ecm.c   | 69 ++++++++++++++++++++++++++
 drivers/usb/gadget/function/u_ether.c | 63 ++++++++++++++++++++++++
 drivers/usb/gadget/function/u_ether.h |  4 ++
 drivers/usb/gadget/udc/core.c         | 19 +++++++
 include/linux/usb/composite.h         |  6 +++
 include/linux/usb/gadget.h            |  4 ++
 11 files changed, 294 insertions(+), 15 deletions(-)