diff options
author | Wesley Cheng <quic_wcheng@quicinc.com> | 2023-04-20 14:27:58 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-02-23 08:55:16 +0100 |
commit | 9ae312f7f3c23ee218d9b014f06f439a2295e352 (patch) | |
tree | 21bad1f85fbbe9d11460892f5ca15865b8d3404f | |
parent | 921acacb92b71d52e359d42f175b1ad0c7a2b892 (diff) | |
download | linux-stable-9ae312f7f3c23ee218d9b014f06f439a2295e352.tar.gz linux-stable-9ae312f7f3c23ee218d9b014f06f439a2295e352.tar.bz2 linux-stable-9ae312f7f3c23ee218d9b014f06f439a2295e352.zip |
usb: dwc3: gadget: Execute gadget stop after halting the controller
commit 39674be56fba1cd3a03bf4617f523a35f85fd2c1 upstream.
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: c96683798e27 ("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>
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index ccacbe6a2c57..7665e8beb4ae 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2517,7 +2517,6 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) * bit. */ dwc3_stop_active_transfers(dwc); - __dwc3_gadget_stop(dwc); spin_unlock_irqrestore(&dwc->lock, flags); /* @@ -2547,7 +2546,19 @@ static int dwc3_gadget_soft_disconnect(struct dwc3 *dwc) * remaining event generated by the controller while polling for * DSTS.DEVCTLHLT. */ - return dwc3_gadget_run_stop(dwc, false); + ret = dwc3_gadget_run_stop(dwc, false); + + /* + * Stop the gadget after controller is halted, so that if needed, the + * events to update EP0 state can still occur while the run/stop + * routine polls for the halted state. DEVTEN is cleared as part of + * gadget stop. + */ + spin_lock_irqsave(&dwc->lock, flags); + __dwc3_gadget_stop(dwc); + spin_unlock_irqrestore(&dwc->lock, flags); + + return ret; } static int dwc3_gadget_soft_connect(struct dwc3 *dwc) |