Skip to content

Commit 2b94b05

Browse files
xhackerustcgregkh
authored andcommitted
usb: dwc2: fix hang during suspend if set as peripheral
dwc2 on most platforms needs phy controller, clock and power supply. All of them must be enabled/activated to properly operate. If dwc2 is configured as peripheral mode, then all the above three hardware resources are disabled at the end of the probe: /* Gadget code manages lowlevel hw on its own */ if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) dwc2_lowlevel_hw_disable(hsotg); But the dwc2_suspend() tries to read the dwc2's reg to check whether is_device_mode or not, this would result in hang during suspend if dwc2 is configured as peripheral mode. Fix this hang by bypassing suspend/resume if lowlevel hw isn't enabled. Fixes: 09a75e8 ("usb: dwc2: refactor common low-level hw code to platform.c") Signed-off-by: Jisheng Zhang <jszhang@kernel.org> Link: https://patch.msgid.link/20251104002503.17158-3-jszhang@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b6ebcfd commit 2b94b05

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/usb/dwc2/platform.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,13 @@ static int dwc2_driver_probe(struct platform_device *dev)
649649
static int __maybe_unused dwc2_suspend(struct device *dev)
650650
{
651651
struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev);
652-
bool is_device_mode = dwc2_is_device_mode(dwc2);
652+
bool is_device_mode;
653653
int ret = 0;
654654

655+
if (!dwc2->ll_hw_enabled)
656+
return 0;
657+
658+
is_device_mode = dwc2_is_device_mode(dwc2);
655659
if (is_device_mode)
656660
dwc2_hsotg_suspend(dwc2);
657661

@@ -728,6 +732,9 @@ static int __maybe_unused dwc2_resume(struct device *dev)
728732
struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev);
729733
int ret = 0;
730734

735+
if (!dwc2->ll_hw_enabled)
736+
return 0;
737+
731738
if (dwc2->phy_off_for_suspend && dwc2->ll_hw_enabled) {
732739
ret = __dwc2_lowlevel_hw_enable(dwc2);
733740
if (ret)

0 commit comments

Comments
 (0)