From owner-p4-projects@FreeBSD.ORG Sat Apr 11 11:17:43 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 372801065670; Sat, 11 Apr 2009 11:17:43 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB475106566C for ; Sat, 11 Apr 2009 11:17:42 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D98028FC08 for ; Sat, 11 Apr 2009 11:17:42 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n3BBHgPf016101 for ; Sat, 11 Apr 2009 11:17:42 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n3BBHgdO016099 for perforce@freebsd.org; Sat, 11 Apr 2009 11:17:42 GMT (envelope-from hselasky@FreeBSD.org) Date: Sat, 11 Apr 2009 11:17:42 GMT Message-Id: <200904111117.n3BBHgdO016099@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 160485 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2009 11:17:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=160485 Change 160485 by hselasky@hselasky_laptop001 on 2009/04/11 11:17:31 USB CORE: - fix a bug in the USB power daemon code where connection of multiple HUBs in series would result in incorrect device suspend. Bug reported by: Nicolas xxx@wanadoo.fr Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_hub.c#13 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_hub.c#13 (text+ko) ==== @@ -1786,12 +1786,10 @@ static void usb2_dev_suspend_peer(struct usb2_device *udev) { - struct usb2_device *hub; struct usb2_device *child; int err; uint8_t x; uint8_t nports; - uint8_t suspend_parent; repeat: /* be NULL safe */ @@ -1808,16 +1806,15 @@ DPRINTF("udev=%p\n", udev); - /* check if all devices on the parent hub are suspended */ - hub = udev->parent_hub; - if (hub != NULL) { - nports = hub->hub->nports; - suspend_parent = 1; + /* check if the current device is a HUB */ + if (udev->hub != NULL) { + nports = udev->hub->nports; + /* check if all devices on the HUB are suspended */ for (x = 0; x != nports; x++) { - child = usb2_bus_port_get_device(hub->bus, - hub->hub->ports + x); + child = usb2_bus_port_get_device(udev->bus, + udev->hub->ports + x); if (child == NULL) continue; @@ -1825,16 +1822,9 @@ if (child->pwr_save.suspended) continue; - if (child == udev) - continue; - - /* another device on the HUB is not suspended */ - suspend_parent = 0; - - break; + DPRINTFN(1, "Port %u is busy on the HUB!\n", x + 1); + return; } - } else { - suspend_parent = 0; } sx_xlock(udev->default_sx + 1); @@ -1877,11 +1867,9 @@ DPRINTFN(0, "Suspending port failed\n"); return; } - if (suspend_parent) { - udev = udev->parent_hub; - goto repeat; - } - return; + + udev = udev->parent_hub; + goto repeat; } /*------------------------------------------------------------------------*