From owner-p4-projects@FreeBSD.ORG Tue Sep 25 21:41:29 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DA89816A469; Tue, 25 Sep 2007 21:41:28 +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 A349216A41A for ; Tue, 25 Sep 2007 21:41:28 +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 6B9F313C45B for ; Tue, 25 Sep 2007 21:41:28 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l8PLfSbN002025 for ; Tue, 25 Sep 2007 21:41:28 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l8PLfR9Z002022 for perforce@freebsd.org; Tue, 25 Sep 2007 21:41:27 GMT (envelope-from hselasky@FreeBSD.org) Date: Tue, 25 Sep 2007 21:41:27 GMT Message-Id: <200709252141.l8PLfR9Z002022@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 126804 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: Tue, 25 Sep 2007 21:41:29 -0000 http://perforce.freebsd.org/chv.cgi?CH=126804 Change 126804 by hselasky@hselasky_laptop001 on 2007/09/25 21:41:18 Print out USB transfer status information per "ehci_non_isoc_done_sub()" call. Don't access index "xfer->nframes" of "xfer->frlengths[]". Add explicit check for this. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/ehci.c#39 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/ehci.c#39 (text+ko) ==== @@ -1069,7 +1069,7 @@ return(last); } -static uint32_t +static usbd_status ehci_non_isoc_done_sub(struct usbd_xfer *xfer) { ehci_qtd_t *td; @@ -1100,7 +1100,7 @@ DPRINTFN(0, ("Invalid status length, " "0x%04x/0x%04x bytes\n", len, td->len)); status |= EHCI_QTD_HALTED; - } else { + } else if (xfer->aframes != xfer->nframes) { xfer->frlengths[xfer->aframes] -= len; } @@ -1155,7 +1155,24 @@ xfer->pipe->toggle_next = last_toggle; - return status; +#ifdef USB_DEBUG + if (status & EHCI_QTD_STATERRS) { + DPRINTFN(10, ("error, addr=%d, endpt=0x%02x, frame=0x%02x" + "status=%s%s%s%s%s%s%s%s\n", + xfer->address, xfer->endpoint, xfer->aframes, + (status & EHCI_QTD_ACTIVE) ? "[ACTIVE]" : "[NOT_ACTIVE]", + (status & EHCI_QTD_HALTED) ? "[HALTED]" : "", + (status & EHCI_QTD_BUFERR) ? "[BUFERR]" : "", + (status & EHCI_QTD_BABBLE) ? "[BABBLE]" : "", + (status & EHCI_QTD_XACTERR) ? "[XACTERR]" : "", + (status & EHCI_QTD_MISSEDMICRO) ? "[MISSED]" : "", + (status & EHCI_QTD_SPLITXSTATE) ? "[SPLIT]" : "", + (status & EHCI_QTD_PINGSTATE) ? "[PING]" : "")); + } +#endif + + return ((status & EHCI_QTD_HALTED) ? + USBD_STALLED : USBD_NORMAL_COMPLETION); } static void @@ -1164,7 +1181,7 @@ static void ehci_non_isoc_done(struct usbd_xfer *xfer) { - u_int32_t status = 0; + usbd_status err = 0; DPRINTFN(12, ("xfer=%p pipe=%p transfer done\n", xfer, xfer->pipe)); @@ -1182,7 +1199,7 @@ if (xfer->flags_int.control_xfr && xfer->flags_int.control_hdr) { - status = ehci_non_isoc_done_sub(xfer); + err = ehci_non_isoc_done_sub(xfer); xfer->aframes = 1; @@ -1196,7 +1213,7 @@ if ((!xfer->flags_int.control_xfr) || (xfer->frlengths[xfer->aframes] > 0)) { - status = ehci_non_isoc_done_sub(xfer); + err = ehci_non_isoc_done_sub(xfer); } xfer->aframes ++; @@ -1209,37 +1226,21 @@ if (xfer->flags_int.control_xfr && !xfer->flags_int.control_act) { - status = ehci_non_isoc_done_sub(xfer); + err = ehci_non_isoc_done_sub(xfer); } done: - -#ifdef USB_DEBUG - if (status & EHCI_QTD_STATERRS) { - DPRINTFN(10, - ("error, addr=%d, endpt=0x%02x, " - "status=%s%s%s%s%s%s%s%s\n", - xfer->address, - xfer->endpoint, - (status & EHCI_QTD_ACTIVE) ? "ACTIVE" : "NOT_ACTIVE", - (status & EHCI_QTD_HALTED) ? "-HALTED" : "", - (status & EHCI_QTD_BUFERR) ? "-BUFERR" : "", - (status & EHCI_QTD_BABBLE) ? "-BABBLE" : "", - (status & EHCI_QTD_XACTERR) ? "-XACTERR" : "", - (status & EHCI_QTD_MISSEDMICRO) ? "-MISSED" : "", - (status & EHCI_QTD_SPLITXSTATE) ? "-SPLIT" : "", - (status & EHCI_QTD_PINGSTATE) ? "-PING" : "")); - } -#endif - ehci_device_done(xfer, (status & EHCI_QTD_HALTED) ? - USBD_STALLED : - USBD_NORMAL_COMPLETION); + ehci_device_done(xfer, err); return; } -/* returns one when transfer is finished - * and callback must be called else zero - */ +/*------------------------------------------------------------------------* + * ehci_check_transfer + * + * Return values: + * 0: USB transfer is not finished + * Else: USB transfer is finished + *------------------------------------------------------------------------*/ static u_int8_t ehci_check_transfer(struct usbd_xfer *xfer, struct thread *ctd) {