Skip to content

Commit 7838de1

Browse files
limeng-linuxgregkh
authored andcommitted
usb: dwc3: core: remove lock of otg mode during gadget suspend/resume to avoid deadlock
When config CONFIG_USB_DWC3_DUAL_ROLE is selected, and trigger system to enter suspend status with below command: echo mem > /sys/power/state There will be a deadlock issue occurring. Detailed invoking path as below: 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); <-- 2nd This issue is exposed by commit c7ebd81 ("usb: dwc3: gadget: Fix NULL pointer dereference in dwc3_gadget_suspend") that removes the code of checking whether dwc->gadget_driver is NULL or not. It causes the following code is executed and deadlock occurs when trying to get the spinlock. In fact, the root cause is the commit 5265397("usb: dwc3: Remove DWC3 locking during gadget suspend/resume") that forgot to remove the lock of otg mode. So, remove the redundant lock of otg mode during gadget suspend/resume. Fixes: 5265397 ("usb: dwc3: Remove DWC3 locking during gadget suspend/resume") Cc: Xu Yang <[email protected]> Cc: [email protected] Signed-off-by: Meng Li <[email protected]> Acked-by: Thinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c689426 commit 7838de1

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

drivers/usb/dwc3/core.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,7 +2250,6 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc)
22502250

22512251
static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
22522252
{
2253-
unsigned long flags;
22542253
u32 reg;
22552254
int i;
22562255

@@ -2293,9 +2292,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
22932292
break;
22942293

22952294
if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) {
2296-
spin_lock_irqsave(&dwc->lock, flags);
22972295
dwc3_gadget_suspend(dwc);
2298-
spin_unlock_irqrestore(&dwc->lock, flags);
22992296
synchronize_irq(dwc->irq_gadget);
23002297
}
23012298

@@ -2312,7 +2309,6 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
23122309

23132310
static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
23142311
{
2315-
unsigned long flags;
23162312
int ret;
23172313
u32 reg;
23182314
int i;
@@ -2366,9 +2362,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
23662362
if (dwc->current_otg_role == DWC3_OTG_ROLE_HOST) {
23672363
dwc3_otg_host_init(dwc);
23682364
} else if (dwc->current_otg_role == DWC3_OTG_ROLE_DEVICE) {
2369-
spin_lock_irqsave(&dwc->lock, flags);
23702365
dwc3_gadget_resume(dwc);
2371-
spin_unlock_irqrestore(&dwc->lock, flags);
23722366
}
23732367

23742368
break;

0 commit comments

Comments
 (0)