[PATCH] usb: dwc3: core: avoid reading register after bus clk is disabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The driver may go through below sequence when works as device mode:

dwc3_suspend()
  dwc3_suspend_common()
    dwc3_core_exit()
      dwc3_clk_disable()
	clk_disable_unprepare(dwc->bus_clk);
    dwc3_enable_susphy()
      dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(i));

Then the driver will read dwc3 register after bus clk is disabled. If this
happens, the kernel will hang there. This will move dwc3_enable_susphy()
ahead to avoid such issue.

Fixes: 705e3ce37bcc ("usb: dwc3: core: Fix system suspend on TI AM62 platforms")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Xu Yang <xu.yang_2@xxxxxxx>
---
 drivers/usb/dwc3/core.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index de434f78c560..b0f1e32d426f 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -2347,6 +2347,15 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
 			    (dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) &
 			    DWC3_GUSB3PIPECTL_SUSPHY);
 
+	if (!PMSG_IS_AUTO(msg)) {
+		/*
+		 * TI AM62 platform requires SUSPHY to be
+		 * enabled for system suspend to work.
+		 */
+		if (!dwc->susphy_state)
+			dwc3_enable_susphy(dwc, true);
+	}
+
 	switch (dwc->current_dr_role) {
 	case DWC3_GCTL_PRTCAP_DEVICE:
 		if (pm_runtime_suspended(dwc->dev))
@@ -2398,15 +2407,6 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
 		break;
 	}
 
-	if (!PMSG_IS_AUTO(msg)) {
-		/*
-		 * TI AM62 platform requires SUSPHY to be
-		 * enabled for system suspend to work.
-		 */
-		if (!dwc->susphy_state)
-			dwc3_enable_susphy(dwc, true);
-	}
-
 	return 0;
 }
 
-- 
2.34.1





[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux