Skip to content

Commit

Permalink
usb: dwc3: support continuous runtime PM with dual role
Browse files Browse the repository at this point in the history
The DRD module calls dwc3_set_mode() on role switches, i.e. when a device is
being plugged in. In order to support continuous runtime power management when
plugging in / unplugging a cable, we need to call pm_runtime_get_sync() in
this path.

Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
  • Loading branch information
Martin Kepplinger authored and Felipe Balbi committed May 5, 2020
1 parent e2e77a9 commit c2cd345
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/usb/dwc3/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,19 @@ static void __dwc3_set_mode(struct work_struct *work)
if (dwc->dr_mode != USB_DR_MODE_OTG)
return;

pm_runtime_get_sync(dwc->dev);

if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_OTG)
dwc3_otg_update(dwc, 0);

if (!dwc->desired_dr_role)
return;
goto out;

if (dwc->desired_dr_role == dwc->current_dr_role)
return;
goto out;

if (dwc->desired_dr_role == DWC3_GCTL_PRTCAP_OTG && dwc->edev)
return;
goto out;

switch (dwc->current_dr_role) {
case DWC3_GCTL_PRTCAP_HOST:
Expand Down Expand Up @@ -190,6 +192,9 @@ static void __dwc3_set_mode(struct work_struct *work)
break;
}

out:
pm_runtime_mark_last_busy(dwc->dev);
pm_runtime_put_autosuspend(dwc->dev);
}

void dwc3_set_mode(struct dwc3 *dwc, u32 mode)
Expand Down

0 comments on commit c2cd345

Please sign in to comment.