Re: [PATCH v2] usb: dwc3: core: Avoid redundant system suspend/resume callbacks

From: Alan Stern
Date: Thu Mar 13 2025 - 10:27:38 EST


On Wed, Mar 12, 2025 at 10:34:34PM +0000, Roy Luo wrote:
> dwc3 device suspend/resume callbacks were being triggered during system
> suspend and resume even if the device was already runtime-suspended.
> This is redundant for device mode because the suspend and resume routines
> are essentially identical for system PM and runtime PM.
>
> To prevent these unnecessary callbacks, indicate to the PM core that it
> can safely leave the device in runtime suspend if it's already
> runtime-suspended in device mode by returning a positive value in
> prepare() callback. This optimization only applies to devices without
> pinctrl, as pinctrl has distinct logic tied to system suspend/resume.
>
> Signed-off-by: Roy Luo <royluo@xxxxxxxxxx>

Out of curiosity: What happens if the USB controller is already in
runtime suspend (with wakeup interrupts enabled) when a system suspend
occurs? Does the fact that the interrupts are enabled mean the
controller will remain able to wake up the system even if
device_may_wakeup() is false?

Alan Stern