Skip to content

Commit

Permalink
usb: dwc3: re-enable runtime PM after failed resume
Browse files Browse the repository at this point in the history
When dwc3_resume_common() returns an error, runtime pm is left in
suspended and disabled state in dwc3_resume(). Since the device
is suspended, its parent devices (like the power domain or glue
driver) could also be suspended and may have released resources
that dwc requires. Consequently, calling dwc3_suspend_common() in
this situation could result in attempts to access unclocked or
unpowered registers.
To prevent these problems, runtime PM should always be re-enabled,
even after failed resume attempts. This ensures that
dwc3_suspend_common() is skipped in such cases.

Fixes: 68c26fe ("usb: dwc3: set pm runtime active before resume common")
Cc: [email protected]
Signed-off-by: Roy Luo <[email protected]>
Acked-by: Thinh Nguyen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Roy Luo authored and gregkh committed Oct 4, 2024
1 parent a6555cb commit 897e13a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/usb/dwc3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2552,22 +2552,20 @@ static int dwc3_suspend(struct device *dev)
static int dwc3_resume(struct device *dev)
{
struct dwc3 *dwc = dev_get_drvdata(dev);
int ret;
int ret = 0;

pinctrl_pm_select_default_state(dev);

pm_runtime_disable(dev);
pm_runtime_set_active(dev);

ret = dwc3_resume_common(dwc, PMSG_RESUME);
if (ret) {
if (ret)
pm_runtime_set_suspended(dev);
return ret;
}

pm_runtime_enable(dev);

return 0;
return ret;
}

static void dwc3_complete(struct device *dev)
Expand Down

0 comments on commit 897e13a

Please sign in to comment.