Skip to content

Commit ec96bcf

Browse files
Prashanth Kgregkh
authored andcommitted
usb: dwc3: Wait unconditionally after issuing EndXfer command
commit 1d26ba0 upstream. Currently all controller IP/revisions except DWC3_usb3 >= 310a wait 1ms unconditionally for ENDXFER completion when IOC is not set. This is because DWC_usb3 controller revisions >= 3.10a supports GUCTL2[14: Rst_actbitlater] bit which allows polling CMDACT bit to know whether ENDXFER command is completed. Consider a case where an IN request was queued, and parallelly soft_disconnect was called (due to ffs_epfile_release). This eventually calls stop_active_transfer with IOC cleared, hence send_gadget_ep_cmd() skips waiting for CMDACT cleared during EndXfer. For DWC3 controllers with revisions >= 310a, we don't forcefully wait for 1ms either, and we proceed by unmapping the requests. If ENDXFER didn't complete by this time, it leads to SMMU faults since the controller would still be accessing those requests. Fix this by ensuring ENDXFER completion by adding 1ms delay in __dwc3_stop_active_transfer() unconditionally. Cc: stable@vger.kernel.org Fixes: b353eb6 ("usb: dwc3: gadget: Skip waiting for CMDACT cleared during endxfer") Signed-off-by: Prashanth K <quic_prashk@quicinc.com> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Link: https://lore.kernel.org/r/20240502044103.1066350-1-quic_prashk@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 71df2cb commit ec96bcf

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,6 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)
17181718
*/
17191719
static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool interrupt)
17201720
{
1721-
struct dwc3 *dwc = dep->dwc;
17221721
struct dwc3_gadget_ep_cmd_params params;
17231722
u32 cmd;
17241723
int ret;
@@ -1743,8 +1742,7 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
17431742
dep->resource_index = 0;
17441743

17451744
if (!interrupt) {
1746-
if (!DWC3_IP_IS(DWC3) || DWC3_VER_IS_PRIOR(DWC3, 310A))
1747-
mdelay(1);
1745+
mdelay(1);
17481746
dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
17491747
} else if (!ret) {
17501748
dep->flags |= DWC3_EP_END_TRANSFER_PENDING;

0 commit comments

Comments
 (0)