diff mbox series

usb: dwc3: core: remove spin_lock/unlock_* to avoid deadlock when suspend gadget

Message ID 20240524162535.129694-1-xu.yang_2@nxp.com (mailing list archive)
State Superseded
Headers show
Series usb: dwc3: core: remove spin_lock/unlock_* to avoid deadlock when suspend gadget | expand

Commit Message

Xu Yang May 24, 2024, 4:25 p.m. UTC
In current design, spin_lock_irqsave() will run twice when suspend gadget
device if the controller is using OTG block:

dwc3_suspend_common()
  spin_lock_irqsave(&dwc->lock, flags);      <-- 1st
  dwc3_gadget_suspend(dwc);
    dwc3_gadget_soft_disconnect(dwc);
      spin_lock_irqsave(&dwc->lock, flags);  <-- 2rd

This will cause deadlock on the suspend path. To let it work, just remove
spin_lock/unlock_* in dwc3_suspend_common() since they are redundant.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
 drivers/usb/dwc3/core.c | 3 ---
 1 file changed, 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 7ee61a89520b..b8193edc41bd 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -2250,7 +2250,6 @@  static int dwc3_core_init_for_resume(struct dwc3 *dwc)
 
 static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
 {
-	unsigned long	flags;
 	u32 reg;
 	int i;
 
@@ -2293,9 +2292,7 @@  static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
 			break;
 
 		if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) {
-			spin_lock_irqsave(&dwc->lock, flags);
 			dwc3_gadget_suspend(dwc);
-			spin_unlock_irqrestore(&dwc->lock, flags);
 			synchronize_irq(dwc->irq_gadget);
 		}