diff options
author | Hans Petter Selasky <hselasky@FreeBSD.org> | 2021-05-18 13:52:00 +0000 |
---|---|---|
committer | Hans Petter Selasky <hselasky@FreeBSD.org> | 2021-06-02 11:25:20 +0000 |
commit | ad9d0df7c66a02db53f102e87e6f8414e8da67fc (patch) | |
tree | 5631b59f44639cc50250935b900dd9b9cefed41d | |
parent | ae9aba942b58ff235c5aafd599fe37821c8f79f5 (diff) | |
download | src-ad9d0df7c66a02db53f102e87e6f8414e8da67fc.tar.gz src-ad9d0df7c66a02db53f102e87e6f8414e8da67fc.zip |
Propagate down USB explore error codes, so that failures to enumerate USB HUBs
behind USB HUBs are detected and the USB reset counter logic will kick in
preventing enumeration of continuously failing ports.
Submitted by: phk@
Tested by: bz@
PR: 237666
Sponsored by: Mellanox Technologies // NVIDIA Networking
(cherry picked from commit e5ff940a81b56cb236795e0059c44981053f8404)
-rw-r--r-- | sys/dev/usb/usb_hub.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/dev/usb/usb_hub.c b/sys/dev/usb/usb_hub.c index 6ed30b64b1e0..52ac0a8a7ff7 100644 --- a/sys/dev/usb/usb_hub.c +++ b/sys/dev/usb/usb_hub.c @@ -513,7 +513,7 @@ uhub_explore_sub(struct uhub_softc *sc, struct usb_port *up) usb_error_t err; bus = sc->sc_udev->bus; - err = 0; + err = USB_ERR_NORMAL_COMPLETION; /* get driver added refcount from USB bus */ refcount = bus->driver_added_refcount; @@ -1013,7 +1013,7 @@ uhub_explore(struct usb_device *udev) if (udev->flags.self_suspended) { /* need to wait until the child signals resume */ DPRINTF("Device is suspended!\n"); - return (0); + return (USB_ERR_NORMAL_COMPLETION); } /* @@ -1022,6 +1022,12 @@ uhub_explore(struct usb_device *udev) */ do_unlock = usbd_enum_lock(udev); + /* + * Set default error code to avoid compiler warnings. + * Note that hub->nports cannot be zero. + */ + err = USB_ERR_NORMAL_COMPLETION; + for (x = 0; x != hub->nports; x++) { up = hub->ports + x; portno = x + 1; @@ -1090,13 +1096,11 @@ uhub_explore(struct usb_device *udev) break; } } - err = uhub_explore_sub(sc, up); - if (err) { - /* no device(s) present */ - continue; + + if (uhub_explore_sub(sc, up) == USB_ERR_NORMAL_COMPLETION) { + /* explore succeeded - reset restart counter */ + up->restartcnt = 0; } - /* explore succeeded - reset restart counter */ - up->restartcnt = 0; } if (do_unlock) @@ -1105,8 +1109,7 @@ uhub_explore(struct usb_device *udev) /* initial status checked */ sc->sc_flags |= UHUB_FLAG_DID_EXPLORE; - /* return success */ - return (USB_ERR_NORMAL_COMPLETION); + return (err); } int |