From c39770e2f593468aa77222d175cce30887dd363d Mon Sep 17 00:00:00 2001 From: Yunzhi Li Date: Thu, 10 Sep 2015 11:42:30 +0800 Subject: [PATCH] libpayload: usb: dwc2: check device connect state before enable channel If the device has already been disconnected then we shouldn't enable host channel to start any transfer, otherwise this channel goes into an odd state the channel is enabled but can not be disabled by set hcchar.chdis=1. So we need check the device connect status before enable channel. BRANCH=None BUG=chrome-os-partner:44534 TEST=None Change-Id: Ib3ecf486649ca11b302144f9c00a5e88424e90fa Signed-off-by: Yunzhi Li Reviewed-on: https://chromium-review.googlesource.com/298402 Reviewed-by: Julius Werner Commit-Queue: Lin Huang Tested-by: Lin Huang (cherry picked from commit ea96f947b5304fdde2e0991d23febaeba209dde1) Reviewed-on: https://chromium-review.googlesource.com/298992 Reviewed-by: David Hendricks --- payloads/libpayload/drivers/usb/dwc2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/payloads/libpayload/drivers/usb/dwc2.c b/payloads/libpayload/drivers/usb/dwc2.c index f5e8c74563..3ad0cb7737 100644 --- a/payloads/libpayload/drivers/usb/dwc2.c +++ b/payloads/libpayload/drivers/usb/dwc2.c @@ -274,6 +274,9 @@ dwc2_do_xfer(endpoint_t *ep, int size, int pid, ep_dir_t dir, if (do_copy && (dir == EPDIR_OUT)) memcpy(aligned_buf, data_buf, size); + if (dwc2_disconnected(ep->dev->controller)) + return -HCSTAT_DISCONNECTED; + writel(hctsiz.d32, ®->host.hchn[ch_num].hctsizn); writel((uint32_t)aligned_buf, ®->host.hchn[ch_num].hcdman); writel(hcchar.d32, ®->host.hchn[ch_num].hccharn);