Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Jun 2021 12:24:53 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ad9d0df7c66a - stable/13 - 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.
Message-ID:  <202106021224.152COrst019206@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=ad9d0df7c66a02db53f102e87e6f8414e8da67fc

commit ad9d0df7c66a02db53f102e87e6f8414e8da67fc
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2021-05-18 13:52:00 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2021-06-02 11:25:20 +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
    Sponsored by:   Mellanox Technologies // NVIDIA Networking
    
    (cherry picked from commit e5ff940a81b56cb236795e0059c44981053f8404)
---
 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106021224.152COrst019206>