libpayload: usb: dwc2: fix usb plug/unplug bug
Check device connect status while waiting for usb transfer complete Avoid coreboot get stuck when usb device unplugged BUG=chrome-os-partner:35525 TEST=None BRANCH=None Change-Id: Id103501aa0d8b31b0b81bef773679c0fad79f689 Signed-off-by: Yunzhi Li <lyz@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/292630 Reviewed-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Commit-Queue: Lin Huang <hl@rock-chips.com> Tested-by: Lin Huang <hl@rock-chips.com> (cherry picked from commit 2870609ceb56ccf81cda24f4cc2e10013f19adf7) Reviewed-on: https://chromium-review.googlesource.com/293300 Commit-Queue: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org>
This commit is contained in:
parent
a5803c59f0
commit
53b66a0d17
2 changed files with 17 additions and 1 deletions
|
|
@ -140,6 +140,16 @@ static void dwc2_shutdown(hci_t *controller)
|
|||
free(controller);
|
||||
}
|
||||
|
||||
/* Test root port device connect status */
|
||||
static int dwc2_disconnected(hci_t *controller)
|
||||
{
|
||||
dwc2_reg_t *reg = DWC2_REG(controller);
|
||||
hprt_t hprt;
|
||||
|
||||
hprt.d32 = readl(®->host.hprt);
|
||||
return !(hprt.prtena && hprt.prtconnsts);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function return the actual transfer length when the transfer successe
|
||||
* and if the transfer fail return an error code
|
||||
|
|
@ -179,8 +189,10 @@ wait_for_complete(endpoint_t *ep, uint32_t ch_num)
|
|||
else
|
||||
return -HCSTAT_UNKNOW;
|
||||
}
|
||||
} while (timeout--);
|
||||
|
||||
if (dwc2_disconnected(ep->dev->controller))
|
||||
return -HCSTAT_DISCONNECTED;
|
||||
} while (timeout--);
|
||||
/* Release the channel when hit timeout condition */
|
||||
hcchar.d32 = readl(®->host.hchn[ch_num].hccharn);
|
||||
if (hcchar.chen) {
|
||||
|
|
@ -309,6 +321,9 @@ dwc2_split_transfer(endpoint_t *ep, int size, int pid, ep_dir_t dir,
|
|||
/* Wait for next frame boundary */
|
||||
do {
|
||||
hfnum.d32 = readl(®->host.hfnum);
|
||||
|
||||
if (dwc2_disconnected(ep->dev->controller))
|
||||
return -HCSTAT_DISCONNECTED;
|
||||
} while (hfnum.frnum % 8 != 0);
|
||||
|
||||
/* Handle Start-Split */
|
||||
|
|
|
|||
|
|
@ -709,5 +709,6 @@ typedef enum {
|
|||
HCSTAT_NYET,
|
||||
HCSTAT_UNKNOW,
|
||||
HCSTAT_TIMEOUT,
|
||||
HCSTAT_DISCONNECTED,
|
||||
} hcstat_t;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue