mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 01:45:18 +02:00
UPSTREAM: usb: dwc3: Avoid waking up gadget during startxfer
When operating in High-Speed, it is observed that DSTS[USBLNKST] doesn't update link state immediately after receiving the wakeup interrupt. Since wakeup event handler calls the resume callbacks, there is a chance that function drivers can perform an ep queue, which in turn tries to perform remote wakeup from send_gadget_ep_cmd(STARTXFER). This happens because DSTS[[21:18] wasn't updated to U0 yet, it's observed that the latency of DSTS can be in order of milli-seconds. Hence avoid calling gadget_wakeup during startxfer to prevent unnecessarily issuing remote wakeup to host. Fixes:c36d8e947a
("usb: dwc3: gadget: put link to U0 before Start Transfer") Cc: stable@vger.kernel.org Suggested-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Signed-off-by: Prashanth K <quic_prashk@quicinc.com> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Link: https://lore.kernel.org/r/20240828064302.3796315-1-quic_prashk@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Bug: 365464688 (cherry picked from commit00dcf2fa44
) Change-Id: If6b97cdd5c9326052ec3730e8183986606806687 Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
This commit is contained in:
parent
cd188cc0b5
commit
a338a543b3
|
@ -287,6 +287,23 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bool async);
|
||||||
*
|
*
|
||||||
* Caller should handle locking. This function will issue @cmd with given
|
* Caller should handle locking. This function will issue @cmd with given
|
||||||
* @params to @dep and wait for its completion.
|
* @params to @dep and wait for its completion.
|
||||||
|
*
|
||||||
|
* According to the programming guide, if the link state is in L1/L2/U3,
|
||||||
|
* then sending the Start Transfer command may not complete. The
|
||||||
|
* programming guide suggested to bring the link state back to ON/U0 by
|
||||||
|
* performing remote wakeup prior to sending the command. However, don't
|
||||||
|
* initiate remote wakeup when the user/function does not send wakeup
|
||||||
|
* request via wakeup ops. Send the command when it's allowed.
|
||||||
|
*
|
||||||
|
* Notes:
|
||||||
|
* For L1 link state, issuing a command requires the clearing of
|
||||||
|
* GUSB2PHYCFG.SUSPENDUSB2, which turns on the signal required to complete
|
||||||
|
* the given command (usually within 50us). This should happen within the
|
||||||
|
* command timeout set by driver. No additional step is needed.
|
||||||
|
*
|
||||||
|
* For L2 or U3 link state, the gadget is in USB suspend. Care should be
|
||||||
|
* taken when sending Start Transfer command to ensure that it's done after
|
||||||
|
* USB resume.
|
||||||
*/
|
*/
|
||||||
int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
|
int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
|
||||||
struct dwc3_gadget_ep_cmd_params *params)
|
struct dwc3_gadget_ep_cmd_params *params)
|
||||||
|
@ -327,30 +344,6 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned int cmd,
|
||||||
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
|
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DWC3_DEPCMD_CMD(cmd) == DWC3_DEPCMD_STARTTRANSFER) {
|
|
||||||
int link_state;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initiate remote wakeup if the link state is in U3 when
|
|
||||||
* operating in SS/SSP or L1/L2 when operating in HS/FS. If the
|
|
||||||
* link state is in U1/U2, no remote wakeup is needed. The Start
|
|
||||||
* Transfer command will initiate the link recovery.
|
|
||||||
*/
|
|
||||||
link_state = dwc3_gadget_get_link_state(dwc);
|
|
||||||
switch (link_state) {
|
|
||||||
case DWC3_LINK_STATE_U2:
|
|
||||||
if (dwc->gadget->speed >= USB_SPEED_SUPER)
|
|
||||||
break;
|
|
||||||
|
|
||||||
fallthrough;
|
|
||||||
case DWC3_LINK_STATE_U3:
|
|
||||||
ret = __dwc3_gadget_wakeup(dwc, false);
|
|
||||||
dev_WARN_ONCE(dwc->dev, ret, "wakeup failed --> %d\n",
|
|
||||||
ret);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For some commands such as Update Transfer command, DEPCMDPARn
|
* For some commands such as Update Transfer command, DEPCMDPARn
|
||||||
* registers are reserved. Since the driver often sends Update Transfer
|
* registers are reserved. Since the driver often sends Update Transfer
|
||||||
|
|
Loading…
Reference in New Issue
Block a user