[PATCH v4 0/3] Support dwc3 runtime suspend during bus suspend

From: Elson Roy Serrao
Date: Mon Aug 14 2023 - 14:52:04 EST


Changes in v4
- Changed the dt property name to 'snps,runtime-suspend-on-usb-suspend' as per
the feedback received.
- Separated the pending events handling to a different patch as it is an
independent fix
https://lore.kernel.org/all/b2ab8803-d4e0-bd63-7a64-bcc411e04cfe@xxxxxxxxxx/
- Moved the bus suspend checks to runtime_checks() API to make it more relevant
to runtime ops. Also added explicit run time check in resume common function.
- Instead of checking the link state for bus suspend, used dwc->suspended flag
as it directly reflects the gadget suspend/resume operations.

Changes in v3
- Added a dt property 'snps,allow-rtsusp-on-u3' to make this feature platform
dependent as per the feedback from Thinh N.
- Changed the RT idle/suspend/resume handling to device mode specific and dt
property dependent.
- Modified the cover letter to document how resume is handled on qcom platforms.

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
received.

The assumption here is that the dwc3 hibernation feature is not enabled and the
platform is responsible to detect resume events to bring the controller out of
suspend. On Qualcomm platforms the resume is handled through PHY sideband signalling.


The series is organized in below fashion:
Patch 1: This includes the modification needed from function drivers 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 (3):
usb: function: u_ether: Handle rx requests during suspend/resume
dt-bindings: usb: snps,dwc3: Add runtime-suspend-on-usb-suspend
property
usb: dwc3: Modify runtime pm ops to handle bus suspend

.../devicetree/bindings/usb/snps,dwc3.yaml | 5 ++
drivers/usb/dwc3/core.c | 28 ++++++++++-
drivers/usb/dwc3/core.h | 3 ++
drivers/usb/dwc3/gadget.c | 32 ++++++++++---
drivers/usb/gadget/function/u_ether.c | 47 +++++++++++++++----
5 files changed, 97 insertions(+), 18 deletions(-)

--
2.17.1