From a955cde7120bad6758d8d5e200151a6c9fed8cdb Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 9 Apr 2014 06:27:04 +0000 Subject: [PATCH] Fix for infinite XHCI reset loops when the set address USB request fails. MFC after: 2 days --- sys/dev/usb/controller/xhci.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 238bd552884e..2764207bf7fa 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -1218,8 +1218,20 @@ retry: */ if (timeout == 0 && xhci_reset_command_queue_locked(sc) == 0) { - timeout = 1; - goto retry; + temp = le32toh(trb->dwTrb3); + + /* + * Avoid infinite XHCI reset loops if the set + * address command fails to respond due to a + * non-enumerating device: + */ + if (XHCI_TRB_3_TYPE_GET(temp) == XHCI_TRB_TYPE_ADDRESS_DEVICE && + (temp & XHCI_TRB_3_BSR_BIT) == 0) { + DPRINTF("Set address timeout\n"); + } else { + timeout = 1; + goto retry; + } } else { DPRINTF("Controller reset!\n"); usb_bus_reset_async_locked(&sc->sc_bus);