[PATCH v2 0/2] Support dwc3 runtime suspend during bus suspend

From: Elson Roy Serrao
Date: Fri May 26 2023 - 18:46:02 EST

Changes in v2
- Used pm_runtime_resume_and_get() API instead of pm_runtime_get_sync()
as suggested by Dan.
- Handled the return value in ether_wakeup_host to print error message.

When a USB link is idle, the host sends a bus suspend event to the device
so that the device can save power. But true power savings during bus
suspend can be seen only if we let the USB controller enter low power
mode and turn off the clocks. Vendor drivers may have their own runtime
power management framework to power up/down the controller. But since
vendor drivers' runtime suspend/resume routines depend on the dwc3 child
node we would need a framework to trigger dwc3 runtime pm ops whenever a
bus suspend is received. If the device wants to exit from bus suspend
state it can send a wakeup signal to the host by first bringing out the
controller from low power mode. This series implements the needed
framework to achieve this functionality when a bus suspend interupt is

The series is organized in below fashion:
Patch 1: This includes the modification needed from function driver u_ether
to let UDC enter low power mode.
Patch 2: This has the modification needed in the UDC driver to trigger runtime
suspend whene a bus suspend interrupt is received. This also handles resume
and remote wakeup features from power management perspective.

Elson Roy Serrao (2):
usb: function: u_ether: Handle rx requests during suspend/resume
usb: dwc3: Modify runtime pm ops to handle bus suspend

drivers/usb/dwc3/core.c | 19 ++++++++++++++
drivers/usb/dwc3/gadget.c | 40 +++++++++++++++++++++++------
drivers/usb/gadget/function/u_ether.c | 47 ++++++++++++++++++++++++++++-------
3 files changed, 90 insertions(+), 16 deletions(-)