From owner-svn-src-head@FreeBSD.ORG Sun Jun 2 12:28:30 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7DA518A1; Sun, 2 Jun 2013 12:28:30 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 704EC10E9; Sun, 2 Jun 2013 12:28:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r52CSULa061244; Sun, 2 Jun 2013 12:28:30 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r52CSULF061243; Sun, 2 Jun 2013 12:28:30 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201306021228.r52CSULF061243@svn.freebsd.org> From: Hans Petter Selasky Date: Sun, 2 Jun 2013 12:28:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251254 - head/sys/dev/usb/controller X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jun 2013 12:28:30 -0000 Author: hselasky Date: Sun Jun 2 12:28:29 2013 New Revision: 251254 URL: http://svnweb.freebsd.org/changeset/base/251254 Log: Correct the TD size computation. npkt should reflect the number of packets remaining after the current TRB has been executed. Refer to section 4.11.2.4 of the XHCI specification for USB. MFC after: 1 week Modified: head/sys/dev/usb/controller/xhci.c Modified: head/sys/dev/usb/controller/xhci.c ============================================================================== --- head/sys/dev/usb/controller/xhci.c Sun Jun 2 12:16:58 2013 (r251253) +++ head/sys/dev/usb/controller/xhci.c Sun Jun 2 12:28:29 2013 (r251254) @@ -1550,6 +1550,7 @@ xhci_setup_generic_chain_sub(struct xhci uint32_t buf_offset; uint32_t average; uint32_t len_old; + uint32_t npkt_off; uint32_t dword; uint8_t shortpkt_old; uint8_t precompute; @@ -1560,6 +1561,7 @@ xhci_setup_generic_chain_sub(struct xhci buf_offset = 0; shortpkt_old = temp->shortpkt; len_old = temp->len; + npkt_off = 0; precompute = 1; restart: @@ -1666,7 +1668,7 @@ restart: /* fill out buffer pointers */ if (average == 0) { - npkt = 1; + npkt = 0; memset(&buf_res, 0, sizeof(buf_res)); } else { usbd_get_page(temp->pc, temp->offset + @@ -1680,8 +1682,10 @@ restart: if (buf_res.length > XHCI_TD_PAGE_SIZE) buf_res.length = XHCI_TD_PAGE_SIZE; + npkt_off += buf_res.length; + /* setup npkt */ - npkt = (average + temp->max_packet_size - 1) / + npkt = (len_old - npkt_off + temp->max_packet_size - 1) / temp->max_packet_size; if (npkt > 31)