diff options
Diffstat (limited to 'payloads')
-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); } |