Patrick Georgi (pgeorgi@google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/12347
-gerrit
commit a88aeb8fe6a276a119bdef59038da38e52e3a4f6 Author: Furquan Shaikh furquan@google.com Date: Wed Nov 4 16:09:08 2015 -0800
libpayload/udc: dwc2: Add timeout for shutdown operation
BUG=b:24676003 BRANCH=None TEST=Verified that udc shutdown returns after the timeout.
Change-Id: I5df598c4eddecbecb353343ef5a4e44eae4fc20b Signed-off-by: Patrick Georgi pgeorgi@chromium.org Original-Commit-Id: 268913f21adea9969c9f88e3cb759341a60719f0 Original-Change-Id: I3ee059791d6e821f83f9ac41fd7c5385bd60e21e Original-Signed-off-by: Furquan Shaikh furquan@google.com Original-Reviewed-on: https://chromium-review.googlesource.com/310983 Original-Commit-Ready: Furquan Shaikh furquan@chromium.org Original-Tested-by: Furquan Shaikh furquan@chromium.org Original-Reviewed-by: Aaron Durbin adurbin@chromium.org --- payloads/libpayload/drivers/udc/dwc2.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/payloads/libpayload/drivers/udc/dwc2.c b/payloads/libpayload/drivers/udc/dwc2.c index 32d6a5d..2397f8c 100644 --- a/payloads/libpayload/drivers/udc/dwc2.c +++ b/payloads/libpayload/drivers/udc/dwc2.c @@ -695,7 +695,12 @@ static void dwc2_shutdown(struct usbdev_ctrl *this) int i, j; int is_empty = 0;
- while (!is_empty) { + uint64_t shutdown_timer_us = timer_us(0); + /* Wait upto 3 seconds for packets to be flushed out. */ + uint64_t shutdown_timeout_us = 3 * 1000 * 1000UL; + + while ((!is_empty) && + (timer_us(shutdown_timer_us) < shutdown_timeout_us)) { is_empty = 1; this->poll(this); for (i = 0; i < 16; i++) @@ -704,6 +709,9 @@ static void dwc2_shutdown(struct usbdev_ctrl *this) is_empty = 0; }
+ if (timer_us(shutdown_timer_us) >= shutdown_timeout_us) + usb_debug("Error: Failed to empty queues.. timeout\n"); + dwc2_force_shutdown(this); }