Skip to content

Commit 140e2df

Browse files
Thinh Nguyengregkh
Thinh Nguyen
authored andcommitted
usb: dwc3: gadget: Check for L1/L2/U3 for Start Transfer
commit 63c4c32 upstream. The programming guide noted that the driver needs to verify if the link state is in U0 before executing the Start Transfer command. If it's not in U0, the driver needs to perform remote wakeup. This is not accurate. If the link state is in U1/U2, then the controller will not respond to link recovery request from DCTL.ULSTCHNGREQ. The Start Transfer command will trigger a link recovery if it is in U1/U2. A clarification will be added to the programming guide for all controller versions. The current implementation shouldn't cause any functional issue. It may occasionally report an invalid time out warning from failed link recovery request. The driver will still go ahead with the Start Transfer command if the remote wakeup fails. The new change only initiates remote wakeup where it is needed, which is when the link state is in L1/L2/U3. Fixes: c36d8e9 ("usb: dwc3: gadget: put link to U0 before Start Transfer") Cc: <[email protected]> Signed-off-by: Thinh Nguyen <[email protected]> Link: https://lore.kernel.org/r/05b4a5fbfbd0863fc9b1d7af934a366219e3d0b4.1635204761.git.Thinh.Nguyen@synopsys.com Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3abf746 commit 140e2df

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

drivers/usb/dwc3/gadget.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,24 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
310310
if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
311311
int link_state;
312312

313+
/*
314+
* Initiate remote wakeup if the link state is in U3 when
315+
* operating in SS/SSP or L1/L2 when operating in HS/FS. If the
316+
* link state is in U1/U2, no remote wakeup is needed. The Start
317+
* Transfer command will initiate the link recovery.
318+
*/
313319
link_state = dwc3_gadget_get_link_state(dwc);
314-
if (link_state == DWC3_LINK_STATE_U1 ||
315-
link_state == DWC3_LINK_STATE_U2 ||
316-
link_state == DWC3_LINK_STATE_U3) {
320+
switch (link_state) {
321+
case DWC3_LINK_STATE_U2:
322+
if (dwc->gadget->speed >= USB_SPEED_SUPER)
323+
break;
324+
325+
fallthrough;
326+
case DWC3_LINK_STATE_U3:
317327
ret = __dwc3_gadget_wakeup(dwc);
318328
dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n",
319329
ret);
330+
break;
320331
}
321332
}
322333

0 commit comments

Comments
 (0)