From owner-svn-src-head@FreeBSD.ORG Fri Jun 7 22:35:59 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 31C458AE; Fri, 7 Jun 2013 22:35:59 +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 13981189B; Fri, 7 Jun 2013 22:35:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r57MZwsP087227; Fri, 7 Jun 2013 22:35:58 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r57MZw03087226; Fri, 7 Jun 2013 22:35:58 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201306072235.r57MZw03087226@svn.freebsd.org> From: Hans Petter Selasky Date: Fri, 7 Jun 2013 22:35:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251515 - 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: Fri, 07 Jun 2013 22:35:59 -0000 Author: hselasky Date: Fri Jun 7 22:35:58 2013 New Revision: 251515 URL: http://svnweb.freebsd.org/changeset/base/251515 Log: Fix some recent regression issues: 1) Only multi-TD isochronous transfers should use NORMAL type after specific type as per XHCI specification. 2) BEI bit is only available in NORMAL and ISOCHRONOUS TRB types. Don't use this bit for other types to avoid hardware asserts. Reserved bits should be don't care though ... MFC after: 1 week PR: usb/179342 Modified: head/sys/dev/usb/controller/xhci.c Modified: head/sys/dev/usb/controller/xhci.c ============================================================================== --- head/sys/dev/usb/controller/xhci.c Fri Jun 7 22:01:06 2013 (r251514) +++ head/sys/dev/usb/controller/xhci.c Fri Jun 7 22:35:58 2013 (r251515) @@ -1561,6 +1561,7 @@ xhci_setup_generic_chain_sub(struct xhci struct xhci_td *td; struct xhci_td *td_next; struct xhci_td *td_alt_next; + struct xhci_td *td_first; uint32_t buf_offset; uint32_t average; uint32_t len_old; @@ -1569,7 +1570,6 @@ xhci_setup_generic_chain_sub(struct xhci uint8_t shortpkt_old; uint8_t precompute; uint8_t x; - uint8_t first_trb = 1; td_alt_next = NULL; buf_offset = 0; @@ -1581,7 +1581,7 @@ xhci_setup_generic_chain_sub(struct xhci restart: td = temp->td; - td_next = temp->td_next; + td_next = td_first = temp->td_next; while (1) { @@ -1717,48 +1717,55 @@ restart: td->td_trb[x].dwTrb2 = htole32(dword); - /* BEI: Interrupts are inhibited until EOT */ - dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | - XHCI_TRB_3_BEI_BIT | - XHCI_TRB_3_TBC_SET(temp->tbc) | - XHCI_TRB_3_TLBPC_SET(temp->tlbpc); - - if (first_trb != 0) { - first_trb = 0; - dword |= XHCI_TRB_3_TYPE_SET(temp->trb_type); - /* - * Remove cycle bit from the first TRB - * if we are stepping them: - */ - if (temp->step_td != 0) - dword &= ~XHCI_TRB_3_CYCLE_BIT; - } else { - dword |= XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_NORMAL); - } - if (temp->trb_type == XHCI_TRB_TYPE_ISOCH) { - if (temp->do_isoc_sync != 0) { + switch (temp->trb_type) { + case XHCI_TRB_TYPE_ISOCH: + /* BEI: Interrupts are inhibited until EOT */ + dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | + XHCI_TRB_3_BEI_BIT | + XHCI_TRB_3_TBC_SET(temp->tbc) | + XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + if (td != td_first) { + dword |= XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_NORMAL); + } else if (temp->do_isoc_sync != 0) { temp->do_isoc_sync = 0; - dword |= XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8); + /* wait until "isoc_frame" */ + dword |= XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_ISOCH) | + XHCI_TRB_3_FRID_SET(temp->isoc_frame / 8); } else { - dword |= XHCI_TRB_3_ISO_SIA_BIT; + /* start data transfer at next interval */ + dword |= XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_ISOCH) | + XHCI_TRB_3_ISO_SIA_BIT; } + if (temp->direction == UE_DIR_IN) + dword |= XHCI_TRB_3_DIR_IN | XHCI_TRB_3_ISP_BIT; + break; + case XHCI_TRB_TYPE_DATA_STAGE: + dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | + XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_DATA_STAGE) | + XHCI_TRB_3_TBC_SET(temp->tbc) | + XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + if (temp->direction == UE_DIR_IN) + dword |= XHCI_TRB_3_DIR_IN | XHCI_TRB_3_ISP_BIT; + break; + case XHCI_TRB_TYPE_STATUS_STAGE: + dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | + XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_STATUS_STAGE) | + XHCI_TRB_3_TBC_SET(temp->tbc) | + XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + if (temp->direction == UE_DIR_IN) + dword |= XHCI_TRB_3_DIR_IN; + break; + default: /* XHCI_TRB_TYPE_NORMAL */ + /* BEI: Interrupts are inhibited until EOT */ + dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | + XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_NORMAL) | + XHCI_TRB_3_BEI_BIT | + XHCI_TRB_3_TBC_SET(temp->tbc) | + XHCI_TRB_3_TLBPC_SET(temp->tlbpc); + if (temp->direction == UE_DIR_IN) + dword |= XHCI_TRB_3_DIR_IN | XHCI_TRB_3_ISP_BIT; + break; } - if (temp->direction == UE_DIR_IN) { - dword |= XHCI_TRB_3_DIR_IN; - - /* - * NOTE: Only the SETUP stage should - * use the IDT bit. Else transactions - * can be sent using the wrong data - * toggle value. - */ - if (temp->trb_type != - XHCI_TRB_TYPE_SETUP_STAGE && - temp->trb_type != - XHCI_TRB_TYPE_STATUS_STAGE) - dword |= XHCI_TRB_3_ISP_BIT; - } - td->td_trb[x].dwTrb3 = htole32(dword); average -= buf_res.length; @@ -1793,10 +1800,8 @@ restart: td->td_trb[x].dwTrb2 = htole32(dword); - /* BEI: interrupts are inhibited until EOT */ dword = XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_LINK) | - XHCI_TRB_3_CYCLE_BIT | XHCI_TRB_3_IOC_BIT | - XHCI_TRB_3_BEI_BIT; + XHCI_TRB_3_CYCLE_BIT | XHCI_TRB_3_IOC_BIT; td->td_trb[x].dwTrb3 = htole32(dword); @@ -1824,10 +1829,13 @@ restart: goto restart; } - /* need to force an interrupt if we are stepping the TRBs */ - if ((temp->direction & UE_DIR_IN) != 0 && temp->multishort == 0) { - /* make sure the last LINK event generates an interrupt */ - td->td_trb[td->ntrb].dwTrb3 &= ~htole32(XHCI_TRB_3_BEI_BIT); + /* + * Remove cycle bit from the first TRB if we are + * stepping them: + */ + if (temp->step_td != 0) { + td_first->td_trb[0].dwTrb3 &= ~htole32(XHCI_TRB_3_CYCLE_BIT); + usb_pc_cpu_flush(td_first->page_cache); } /* remove chain bit because this is the last TRB in the chain */