Skip to content

Commit c96e312

Browse files
Prashanth Kgregkh
authored andcommitted
usb: dwc3: Wait for EndXfer completion before restoring GUSB2PHYCFG
DWC3 programming guide mentions that when operating in USB2.0 speeds, if GUSB2PHYCFG[6] or GUSB2PHYCFG[8] is set, it must be cleared prior to issuing commands and may be set again after the command completes. But currently while issuing EndXfer command without CmdIOC set, we wait for 1ms after GUSB2PHYCFG is restored. This results in cases where EndXfer command doesn't get completed and causes SMMU faults since requests are unmapped afterwards. Hence restore GUSB2PHYCFG after waiting for EndXfer command completion. Cc: [email protected] Fixes: 1d26ba0 ("usb: dwc3: Wait unconditionally after issuing EndXfer command") Signed-off-by: Prashanth K <[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 ffe85c2 commit c96e312

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,10 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
438438
dwc3_gadget_ep_get_transfer_index(dep);
439439
}
440440

441+
if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_ENDTRANSFER &&
442+
!(cmd & DWC3_DEPCMD_CMDIOC))
443+
mdelay(1);
444+
441445
if (saved_config) {
442446
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
443447
reg |= saved_config;
@@ -1715,12 +1719,10 @@ static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool int
17151719
WARN_ON_ONCE(ret);
17161720
dep->resource_index = 0;
17171721

1718-
if (!interrupt) {
1719-
mdelay(1);
1722+
if (!interrupt)
17201723
dep->flags &= ~DWC3_EP_TRANSFER_STARTED;
1721-
} else if (!ret) {
1724+
else if (!ret)
17221725
dep->flags |= DWC3_EP_END_TRANSFER_PENDING;
1723-
}
17241726

17251727
dep->flags &= ~DWC3_EP_DELAY_STOP;
17261728
return ret;

0 commit comments

Comments
 (0)