Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a5456df authored by Bar Weiner's avatar Bar Weiner
Browse files

usb: dwc3: gadget: Release gadget lock when handling suspend/resume



gadget_driver suspend/resume operations might require some
dwc3-gadget operations, such as enabling and disabling
endpoints. If the lock is not released, this can cause a
deadlock scenario.

Change-Id: I1e12de65e40492b115ab35de78c2352730649db5
Signed-off-by: default avatarBar Weiner <bweiner@codeaurora.org>
parent 47d53bf2
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -2736,7 +2736,13 @@ static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc)
	 */

	dbg_event(0xFF, "WAKEUP", 0);
	/*
	 * gadget_driver resume function might require some dwc3-gadget
	 * operations, such as ep_enable. Hence, dwc->lock must be released.
	 */
	spin_unlock(&dwc->lock);
	dwc->gadget_driver->resume(&dwc->gadget);
	spin_lock(&dwc->lock);
}

static void dwc3_gadget_linksts_change_interrupt(struct dwc3 *dwc,
@@ -2830,7 +2836,14 @@ static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc,

	if (next == DWC3_LINK_STATE_U3) {
		dbg_event(0xFF, "SUSPEND", 0);
		/*
		 * gadget_driver suspend function might require some dwc3-gadget
		 * operations, such as ep_disable. Hence, dwc->lock must be
		 * released.
		 */
		spin_unlock(&dwc->lock);
		dwc->gadget_driver->suspend(&dwc->gadget);
		spin_lock(&dwc->lock);
	}

	dwc->link_state = next;