git: e5ff940a81b5 - main - 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.
Hans Petter Selasky
hselasky at FreeBSD.org
Tue May 18 14:16:10 UTC 2021
The branch main has been updated by hselasky:
URL: https://cgit.FreeBSD.org/src/commit/?id=e5ff940a81b56cb236795e0059c44981053f8404
commit e5ff940a81b56cb236795e0059c44981053f8404
Author: Hans Petter Selasky <hselasky at FreeBSD.org>
AuthorDate: 2021-05-18 13:52:00 +0000
Commit: Hans Petter Selasky <hselasky at FreeBSD.org>
CommitDate: 2021-05-18 14:11:35 +0000
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
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking
---
sys/dev/usb/usb_hub.c | 23 +++++++++++++----------
1 file 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
More information about the dev-commits-src-main
mailing list