diff options
author | Furquan Shaikh <furquan@google.com> | 2015-11-04 16:09:08 -0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-11-10 14:10:02 +0100 |
commit | 3d6c95c1cd8fa275d3e51e417ecbe0fef3562a7e (patch) | |
tree | ecfebac2d1081015bec244bb33f757ae8c1c2855 /payloads/libpayload/drivers | |
parent | e78a1bedc52b3c63f3c674202d6806ef065923ee (diff) | |
download | coreboot-3d6c95c1cd8fa275d3e51e417ecbe0fef3562a7e.tar.xz |
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>
Reviewed-on: http://review.coreboot.org/12347
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: build bot (Jenkins)
Diffstat (limited to 'payloads/libpayload/drivers')
-rw-r--r-- | payloads/libpayload/drivers/udc/dwc2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/payloads/libpayload/drivers/udc/dwc2.c b/payloads/libpayload/drivers/udc/dwc2.c index 32d6a5db9e..3c9b1576c2 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 up to 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); } |