Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: dwc3: set pm runtime active before resume common

For device mode, if PM runtime autosuspend feature enabled, the
runtime power status of dwc3 may be suspended when run dwc3_resume(),
and dwc3 gadget would not be configured in dwc3_gadget_run_stop().
It would cause gadget connected failed if USB cable has been plugged
before PM resume. So move forward pm_runtime_set_active() to fix it.

Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Link: https://lore.kernel.org/r/20231206065939.16958-1-frank.wang@rock-chips.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Frank Wang and committed by
Greg Kroah-Hartman
68c26fe5 398aa9a7

+7 -4
+7 -4
drivers/usb/dwc3/core.c
··· 2315 2315 2316 2316 pinctrl_pm_select_default_state(dev); 2317 2317 2318 - ret = dwc3_resume_common(dwc, PMSG_RESUME); 2319 - if (ret) 2320 - return ret; 2321 - 2322 2318 pm_runtime_disable(dev); 2323 2319 pm_runtime_set_active(dev); 2320 + 2321 + ret = dwc3_resume_common(dwc, PMSG_RESUME); 2322 + if (ret) { 2323 + pm_runtime_set_suspended(dev); 2324 + return ret; 2325 + } 2326 + 2324 2327 pm_runtime_enable(dev); 2325 2328 2326 2329 return 0;