From a81524f559ddc82ed7d2bf03704e490b2e9750a5 Mon Sep 17 00:00:00 2001 From: hselasky Date: Fri, 11 Apr 2014 06:18:24 +0000 Subject: [PATCH] MFC r264294: Fix for infinite XHCI reset loops when the set address USB request fails. git-svn-id: svn://svn.freebsd.org/base/stable/8@264339 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- 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 d5b940726..8bdde2501 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -1184,8 +1184,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); -- 2.45.0