Skip to content

Commit 34f3fa2

Browse files
wcheng-engsmb49
authored andcommitted
usb: dwc3: gadget: Execute gadget stop after halting the controller
BugLink: https://bugs.launchpad.net/bugs/2028580 [ Upstream commit 39674be ] Do not call gadget stop until the poll for controller halt is completed. DEVTEN is cleared as part of gadget stop, so the intention to allow ep0 events to continue while waiting for controller halt is not happening. Fixes: c966837 ("usb: dwc3: ep0: Don't prepare beyond Setup stage") Cc: stable@vger.kernel.org Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com> Link: https://lore.kernel.org/r/20230420212759.29429-2-quic_wcheng@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent f79d247 commit 34f3fa2

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

drivers/usb/dwc3/gadget.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,7 +2546,6 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc)
25462546
* bit.
25472547
*/
25482548
dwc3_stop_active_transfers(dwc);
2549-
__dwc3_gadget_stop(dwc);
25502549
spin_unlock_irqrestore(&dwc->lock, flags);
25512550

25522551
/*
@@ -2583,7 +2582,19 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc)
25832582
* remaining event generated by the controller while polling for
25842583
* DSTS.DEVCTLHLT.
25852584
*/
2586-
return dwc3_gadget_run_stop(dwc, false);
2585+
ret = dwc3_gadget_run_stop(dwc, false);
2586+
2587+
/*
2588+
* Stop the gadget after controller is halted, so that if needed, the
2589+
* events to update EP0 state can still occur while the run/stop
2590+
* routine polls for the halted state. DEVTEN is cleared as part of
2591+
* gadget stop.
2592+
*/
2593+
spin_lock_irqsave(&dwc->lock, flags);
2594+
__dwc3_gadget_stop(dwc);
2595+
spin_unlock_irqrestore(&dwc->lock, flags);
2596+
2597+
return ret;
25872598
}
25882599

25892600
static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)

0 commit comments

Comments
 (0)