From c5dcd6b9c283f279e57768ee7234f2e4e4543753 Mon Sep 17 00:00:00 2001 From: hselasky Date: Thu, 19 Dec 2013 07:17:18 +0000 Subject: [PATCH] MFC r259248 and r259462: Set chain bit correctly. This will fix some problems sending and receiving Zero Length Packets, ZLPs. See comment in code for more information. git-svn-id: svn://svn.freebsd.org/base/stable/8@259605 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/usb/controller/xhci.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index da225b2d8..8eed9600f 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -1858,7 +1858,16 @@ restart: td->td_trb[x].dwTrb2 = htole32(dword); dword = XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_LINK) | - XHCI_TRB_3_CYCLE_BIT | XHCI_TRB_3_IOC_BIT; + XHCI_TRB_3_CYCLE_BIT | XHCI_TRB_3_IOC_BIT | + /* + * CHAIN-BIT: Ensure that a multi-TRB IN-endpoint + * frame only receives a single short packet event + * by setting the CHAIN bit in the LINK field. In + * addition some XHCI controllers have problems + * sending a ZLP unless the CHAIN-BIT is set in + * the LINK TRB. + */ + XHCI_TRB_3_CHAIN_BIT; td->td_trb[x].dwTrb3 = htole32(dword); @@ -1896,9 +1905,11 @@ restart: } /* clear TD SIZE to zero, hence this is the last TRB */ - /* remove chain bit because this is the last TRB in the chain */ + /* remove chain bit because this is the last data TRB in the chain */ td->td_trb[td->ntrb - 1].dwTrb2 &= ~htole32(XHCI_TRB_2_TDSZ_SET(15)); td->td_trb[td->ntrb - 1].dwTrb3 &= ~htole32(XHCI_TRB_3_CHAIN_BIT); + /* remove CHAIN-BIT from last LINK TRB */ + td->td_trb[td->ntrb].dwTrb3 &= ~htole32(XHCI_TRB_3_CHAIN_BIT); usb_pc_cpu_flush(td->page_cache); -- 2.45.0