From owner-p4-projects@FreeBSD.ORG Thu Apr 26 18:46:09 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1BFE116A409; Thu, 26 Apr 2007 18:46:09 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E36E816A400 for ; Thu, 26 Apr 2007 18:46:08 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id D2CAC13C4BA for ; Thu, 26 Apr 2007 18:46:08 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l3QIk8vw097513 for ; Thu, 26 Apr 2007 18:46:08 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l3QIk83N097510 for perforce@freebsd.org; Thu, 26 Apr 2007 18:46:08 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 26 Apr 2007 18:46:08 GMT Message-Id: <200704261846.l3QIk83N097510@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 118839 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: Thu, 26 Apr 2007 18:46:09 -0000 http://perforce.freebsd.org/chv.cgi?CH=118839 Change 118839 by hselasky@hselasky_mini_itx on 2007/04/26 18:45:16 Improve handling of zero length BULK transfers. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/ehci.c#28 edit .. //depot/projects/usb/src/sys/dev/usb/ohci.c#22 edit .. //depot/projects/usb/src/sys/dev/usb/uhci.c#23 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/ehci.c#28 (text+ko) ==== @@ -1538,6 +1538,7 @@ htole32(EHCI_QTD_SET_CERR(3)); u_int8_t isread; u_int8_t shortpkt = 0; + u_int8_t force_short; ehci_qtd_t *td; ehci_qtd_t *td_last = NULL; ehci_qh_t *qh; @@ -1552,6 +1553,8 @@ buf_offset = 0; usbd_get_page(&(xfer->buf_data), buf_offset, &buf_res); + force_short = (xfer->flags & USBD_FORCE_SHORT_XFER) ? 1 : 0; + if(xfer->pipe->methods == &ehci_device_ctrl_methods) { /* the first byte is "bmRequestType" */ @@ -1603,14 +1606,14 @@ { isread = (UE_GET_DIR(xfer->endpoint) == UE_DIR_IN); - if(xfer->length == 0) - { - /* must allow access to "td_last", - * so xfer->length cannot be zero! + if (xfer->length == 0) { + /* When the length is zero we + * queue a short packet! + * This also makes "td_last" + * non-zero. */ - printf("%s: setting USBD_FORCE_SHORT_XFER!\n", - __FUNCTION__); - xfer->flags |= USBD_FORCE_SHORT_XFER; + DPRINTFN(0, ("short transfer!\n")); + force_short = 1; } } @@ -1631,7 +1634,7 @@ { if(len == 0) { - if(xfer->flags & USBD_FORCE_SHORT_XFER) + if (force_short) { if(shortpkt) { ==== //depot/projects/usb/src/sys/dev/usb/ohci.c#22 (text+ko) ==== @@ -1265,6 +1265,7 @@ u_int32_t len = xfer->length; u_int8_t isread; u_int8_t shortpkt = 0; + u_int8_t force_short; ohci_td_t *td; ohci_td_t *td_last = NULL; ohci_ed_t *ed; @@ -1278,6 +1279,8 @@ buf_offset = 0; usbd_get_page(&(xfer->buf_data), buf_offset, &buf_res); + force_short = (xfer->flags & USBD_FORCE_SHORT_XFER) ? 1 : 0; + if(xfer->pipe->methods == &ohci_device_ctrl_methods) { /* the first byte is "bmRequestType" */ @@ -1323,14 +1326,14 @@ { isread = (UE_GET_DIR(xfer->endpoint) == UE_DIR_IN); - if(xfer->length == 0) - { - /* must allow access to "td_last", - * so xfer->length cannot be zero! + if (xfer->length == 0) { + /* When the length is zero we + * queue a short packet! + * This also makes "td_last" + * non-zero. */ - printf("%s: setting USBD_FORCE_SHORT_XFER!\n", - __FUNCTION__); - xfer->flags |= USBD_FORCE_SHORT_XFER; + DPRINTFN(0, ("short transfer!\n")); + force_short = 1; } } @@ -1361,7 +1364,7 @@ { if(len == 0) { - if(xfer->flags & USBD_FORCE_SHORT_XFER) + if (force_short) { if(shortpkt) { ==== //depot/projects/usb/src/sys/dev/usb/uhci.c#23 (text+ko) ==== @@ -1362,6 +1362,7 @@ u_int32_t len = xfer->length; u_int8_t isread; u_int8_t shortpkt = 0; + u_int8_t force_short; uhci_td_t *td; uhci_td_t *td_last = NULL; @@ -1389,6 +1390,8 @@ td_status |= htole32(UHCI_TD_SPD); } + force_short = (xfer->flags & USBD_FORCE_SHORT_XFER) ? 1 : 0; + if(xfer->pipe->methods == &uhci_device_ctrl_methods) { /* the first byte is "bmRequestType" */ @@ -1433,13 +1436,14 @@ { isread = (UE_GET_DIR(xfer->endpoint) == UE_DIR_IN); - if(xfer->length == 0) - { - /* must allow access to "td_last", - * so xfer->length cannot be zero! + if (xfer->length == 0) { + /* When the length is zero we + * queue a short packet! + * This also makes "td_last" + * non-zero. */ - printf("%s: setting USBD_FORCE_SHORT_XFER!\n", __FUNCTION__); - xfer->flags |= USBD_FORCE_SHORT_XFER; + DPRINTFN(0, ("short transfer!\n")); + force_short = 1; } } @@ -1458,7 +1462,7 @@ { if(len == 0) { - if(xfer->flags & USBD_FORCE_SHORT_XFER) + if (force_short) { if(shortpkt) {