From owner-p4-projects@FreeBSD.ORG Sun Dec 21 21:02:00 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A83851065676; Sun, 21 Dec 2008 21:02:00 +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 6B6721065674 for ; Sun, 21 Dec 2008 21:02:00 +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 5ACDE8FC0C for ; Sun, 21 Dec 2008 21:02:00 +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 mBLL204o032044 for ; Sun, 21 Dec 2008 21:02:00 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mBLL20Im032042 for perforce@freebsd.org; Sun, 21 Dec 2008 21:02:00 GMT (envelope-from hselasky@FreeBSD.org) Date: Sun, 21 Dec 2008 21:02:00 GMT Message-Id: <200812212102.mBLL20Im032042@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 155095 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: Sun, 21 Dec 2008 21:02:00 -0000 http://perforce.freebsd.org/chv.cgi?CH=155095 Change 155095 by hselasky@hselasky_laptop001 on 2008/12/21 21:01:16 Some more suspend and resume fixes. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.c#21 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.c#16 edit .. //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.h#7 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#23 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/controller/ehci2.c#21 (text+ko) ==== @@ -3239,15 +3239,15 @@ * complicated if */ EOWRITE4(sc, port, v | EHCI_PS_FPR); + } + /* wait 20ms for resume sequence to complete */ + if (use_polling) { + /* polling */ + DELAY(20 * 1000); + } else { + usb2_pause_mtx(&sc->sc_bus.bus_mtx, 20); + } - /* wait 20ms for resume sequence to complete */ - if (use_polling) { - /* polling */ - DELAY(20 * 1000); - } else { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 20); - } - } EOWRITE4(sc, port, v & ~(EHCI_PS_SUSP | EHCI_PS_FPR | (3 << 10) /* High Speed */ )); ==== //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.c#16 (text+ko) ==== @@ -2722,8 +2722,7 @@ break; case UHF_PORT_SUSPEND: x = URWMASK(UREAD2(sc, port)); - /* clear suspend and resume detect */ - UWRITE2(sc, port, x & ~(UHCI_PORTSC_SUSP | UHCI_PORTSC_RD)); + UWRITE2(sc, port, x & ~(UHCI_PORTSC_SUSP)); break; case UHF_PORT_RESET: x = URWMASK(UREAD2(sc, port)); @@ -2746,7 +2745,7 @@ std->err = USB_ERR_NORMAL_COMPLETION; goto done; case UHF_C_PORT_SUSPEND: - /* nop */ + sc->sc_isresumed &= ~(1 << index); break; case UHF_PORT_CONNECTION: case UHF_PORT_OVER_CURRENT: @@ -2808,12 +2807,33 @@ change |= UPS_C_OVERCURRENT_INDICATOR; if (x & UHCI_PORTSC_LSDA) status |= UPS_LOW_SPEED; - if ((x & UHCI_PORTSC_PE) && (x & UHCI_PORTSC_RD)) - change |= UPS_C_SUSPEND; - else if (x & UHCI_PORTSC_SUSP) + if ((x & UHCI_PORTSC_PE) && (x & UHCI_PORTSC_RD)) { + /* need to do a write back */ + UWRITE2(sc, port, URWMASK(x)); + + /* wait 20ms for resume sequence to complete */ + if (use_polling) { + /* polling */ + DELAY(20 * 1000); + } else { + usb2_pause_mtx(&sc->sc_bus.bus_mtx, 20); + } + + /* clear suspend and resume detect */ + UWRITE2(sc, port, URWMASK(x) & ~(UHCI_PORTSC_RD | + UHCI_PORTSC_SUSP)); + + /* wait a little bit */ + usb2_pause_mtx(&sc->sc_bus.bus_mtx, 2); + + sc->sc_isresumed |= (1 << index); + + } else if (x & UHCI_PORTSC_SUSP) { status |= UPS_SUSPEND; - + } status |= UPS_PORT_POWER; + if (sc->sc_isresumed & (1 << index)) + change |= UPS_C_SUSPEND; if (sc->sc_isreset) change |= UPS_C_PORT_RESET; USETW(sc->sc_hub_desc.ps.wPortStatus, status); ==== //depot/projects/usb/src/sys/dev/usb2/controller/uhci2.h#7 (text+ko) ==== @@ -301,6 +301,7 @@ uint8_t sc_addr; /* device address */ uint8_t sc_conf; /* device configuration */ uint8_t sc_isreset; /* bits set if a root hub is reset */ + uint8_t sc_isresumed; /* bits set if a port was resumed */ uint8_t sc_saved_sof; uint8_t sc_hub_idata[1]; ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#23 (text+ko) ==== @@ -1704,7 +1704,8 @@ &Giant, UF_DEVICE_REMOTE_WAKEUP); if (err) { DPRINTFN(0, "Clearing device " - "remote wakeup failed!\n"); + "remote wakeup failed: %s!\n", + usb2_errstr(err)); } } return;