From owner-freebsd-usb@FreeBSD.ORG Wed Jan 28 18:29:13 2015 Return-Path: Delivered-To: freebsd-usb@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C6AD3E75 for ; Wed, 28 Jan 2015 18:29:13 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 94EC593C for ; Wed, 28 Jan 2015 18:29:13 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id t0SITDbN057025 for ; Wed, 28 Jan 2015 18:29:13 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-usb@FreeBSD.org Subject: [Bug 156596] [ehci] Extremely high interrupt rate on ehci/uhci IRQ16 80% cpu utilization on CPU0 Date: Wed, 28 Jan 2015 18:29:12 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: usb X-Bugzilla-Version: 8.2-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: tcberner@gmail.com X-Bugzilla-Status: In Progress X-Bugzilla-Priority: Normal X-Bugzilla-Assigned-To: freebsd-usb@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jan 2015 18:29:13 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=156596 Tobias Berner changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tcberner@gmail.com --- Comment #14 from Tobias Berner --- Hi I think I got bitten by the same bug -- monitor detached from dvi: interrupt total rate irq16: ehci0 465310134 142166 irq23: ehci1 8786 2 cpu0:timer 1485088 453 irq264: mps0 387611 118 irq265: hdac0 7 0 irq266: xhci0 28208 8 irq268: hdac1 105 0 irq269: igb0:que 0 8763 2 irq270: igb0:que 1 128669 39 irq271: igb0:que 2 1012967 309 irq272: igb0:que 3 491974 150 irq273: igb0:link 2 0 irq274: ahci0 6 0 irq275: ahci1 551817 168 cpu1:timer 1482123 452 cpu7:timer 1475647 450 cpu6:timer 1477623 451 cpu2:timer 1555822 475 cpu4:timer 2821875 862 cpu3:timer 1502125 458 cpu5:timer 1426102 435 Total 481155454 147007 FreeBSD odo.firefly 11.0-CURRENT FreeBSD 11.0-CURRENT #6 r277147: Tue Jan 13 22:15:03 CET 2015 Tobias@odo.firefly:/usr/obj/usr/src/sys/ODO amd64 dev.ehci.0.%desc: Intel Lynx Point USB 2.0 controller USB-B -- You are receiving this mail because: You are the assignee for the bug. From owner-freebsd-usb@FreeBSD.ORG Thu Jan 29 12:42:26 2015 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 79EA2FD4 for ; Thu, 29 Jan 2015 12:42:26 +0000 (UTC) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by mx1.freebsd.org (Postfix) with ESMTP id 1B0DF31E for ; Thu, 29 Jan 2015 12:42:25 +0000 (UTC) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile14) with ESMTP id t0TCPosl018615 for ; Thu, 29 Jan 2015 21:25:50 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili12) with ESMTP id t0TCPpo22269 for ; Thu, 29 Jan 2015 21:25:51 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi13) id t0TCPpPw003613; Thu, 29 Jan 2015 21:25:51 +0900 Received: from localhost by lomi13.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id t0TCPpPK003601; Thu, 29 Jan 2015 21:25:51 +0900 Date: Thu, 29 Jan 2015 21:25:50 +0900 (JST) Message-Id: <20150129.212550.434561541001871867.okuno.kohji@jp.panasonic.com> To: freebsd-usb@freebsd.org Subject: [Bug?] Control Transfers in xHCI From: Kohji Okuno Organization: Panasonic Corporation X-Mailer: Mew version 6.6 on Emacs 24.4 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2015 12:42:26 -0000 Hi HPS, I found a bug in xHCI device driver. Acording to extensible-host-controler-interface-usb-xhci.pdf:"3.2.9 Control Transfers"... A Data Stage TD consists of a Data Stage TRB followed by zero or more Normal TRBs. If the data is not physically contiguous, Normal TRBs may be chained to the Data Stage TRB. But, in the current imprementation, when two or more TRBs are needed, the device driver set XHCI_TRB_TYPE_DATA_STAGE to all TRBs. This is the violation of the spec. In my minor xHCI, I encountered strange bubble error in a control transfer. After I changed as the following, I succeeded its control transfer. Would you check the following (****)? Best Regards, Kohji Okuno 1785 /* check wLength */ 1786 if (td->td_trb[0].qwTrb0 & 1787 htole64(XHCI_TRB_0_WLENGTH_MASK)) { 1788 if (td->td_trb[0].qwTrb0 & 1789 htole64(XHCI_TRB_0_DIR_IN_MASK)) 1790 dword |= XHCI_TRB_3_TRT_IN; 1791 else 1792 dword |= XHCI_TRB_3_TRT_OUT; 1793 } 1794 1795 td->td_trb[0].dwTrb3 = htole32(dword); 1796 #ifdef USB_DEBUG 1797 xhci_dump_trb(&td->td_trb[x]); 1798 #endif **** #if 1 /* my patch begin */ **** if (temp->trb_type == XHCI_TRB_TYPE_DATA_STAGE){ **** temp->trb_type = XHCI_TRB_TYPE_NORMAL; **** } **** #endif /* my patch end */ 1799 x++; From owner-freebsd-usb@FreeBSD.ORG Thu Jan 29 15:03:23 2015 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D3343BE5 for ; Thu, 29 Jan 2015 15:03:23 +0000 (UTC) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5B195797 for ; Thu, 29 Jan 2015 15:03:22 +0000 (UTC) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 3543A1FE023; Thu, 29 Jan 2015 16:03:13 +0100 (CET) Message-ID: <54CA4BE3.2090706@selasky.org> Date: Thu, 29 Jan 2015 16:04:03 +0100 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Kohji Okuno , freebsd-usb@freebsd.org Subject: Re: [Bug?] Control Transfers in xHCI References: <20150129.212550.434561541001871867.okuno.kohji@jp.panasonic.com> In-Reply-To: <20150129.212550.434561541001871867.okuno.kohji@jp.panasonic.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2015 15:03:23 -0000 On 01/29/15 13:25, Kohji Okuno wrote: > Hi HPS, > > I found a bug in xHCI device driver. > > Acording to extensible-host-controler-interface-usb-xhci.pdf:"3.2.9 > Control Transfers"... > > A Data Stage TD consists of a Data Stage TRB followed by zero or more > Normal TRBs. If the data is not physically contiguous, Normal TRBs may > be chained to the Data Stage TRB. > > > But, in the current imprementation, when two or more TRBs are needed, > the device driver set XHCI_TRB_TYPE_DATA_STAGE to all TRBs. > This is the violation of the spec. > > In my minor xHCI, I encountered strange bubble error in a control > transfer. After I changed as the following, I succeeded its control > transfer. > > Would you check the following (****)? > Hi Kohji, You are correct there is a bug, but your patch is not correct. In FreeBSD we allow SETUP and DATA stages to be done as separate jobs. That means at the entry of creating a new DATA chain, we need to check if it is there first DATA packet or not. Can you test the attached patch and see if it works for you? Thank you! --HPS From owner-freebsd-usb@FreeBSD.ORG Thu Jan 29 15:32:29 2015 Return-Path: Delivered-To: freebsd-usb@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 905F057F for ; Thu, 29 Jan 2015 15:32:29 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 77C21B3A for ; Thu, 29 Jan 2015 15:32:29 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id t0TFWTMn024529 for ; Thu, 29 Jan 2015 15:32:29 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-usb@FreeBSD.org Subject: [Bug 195811] Problem with axge driver for AX88179 Date: Thu, 29 Jan 2015 15:32:29 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: usb X-Bugzilla-Version: 10.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: jseidel@unixsystem.org X-Bugzilla-Status: Closed X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-usb@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: resolution bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2015 15:32:29 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195811 jseidel@unixsystem.org changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|New |Closed --- Comment #2 from jseidel@unixsystem.org --- Seems to be fixed in 10.1-STABLE. -- You are receiving this mail because: You are the assignee for the bug. From owner-freebsd-usb@FreeBSD.ORG Thu Jan 29 19:57:27 2015 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2333F46F for ; Thu, 29 Jan 2015 19:57:27 +0000 (UTC) Received: from dchagin.static.corbina.net (dchagin.static.corbina.ru [78.107.232.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "dchagin.static.corbina.net", Issuer "dchagin.static.corbina.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9FD3BFCB for ; Thu, 29 Jan 2015 19:57:25 +0000 (UTC) Received: from dchagin.static.corbina.net (localhost [127.0.0.1]) by dchagin.static.corbina.net (8.14.9/8.14.9) with ESMTP id t0TJvFfc003754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 29 Jan 2015 22:57:15 +0300 (MSK) (envelope-from dchagin@dchagin.static.corbina.net) Received: (from dchagin@localhost) by dchagin.static.corbina.net (8.14.9/8.14.9/Submit) id t0TJvEXQ003753; Thu, 29 Jan 2015 22:57:14 +0300 (MSK) (envelope-from dchagin) Date: Thu, 29 Jan 2015 22:57:14 +0300 From: Chagin Dmitry To: Hans Petter Selasky Subject: Re: [Bug?] Control Transfers in xHCI Message-ID: <20150129195714.GA3683@dchagin.static.corbina.net> References: <20150129.212550.434561541001871867.okuno.kohji@jp.panasonic.com> <54CA4BE3.2090706@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <54CA4BE3.2090706@selasky.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2015 19:57:27 -0000 On Thu, Jan 29, 2015 at 04:04:03PM +0100, Hans Petter Selasky wrote: > On 01/29/15 13:25, Kohji Okuno wrote: > > Hi HPS, > > > > I found a bug in xHCI device driver. > > > > Acording to extensible-host-controler-interface-usb-xhci.pdf:"3.2.9 > > Control Transfers"... > > > > A Data Stage TD consists of a Data Stage TRB followed by zero or more > > Normal TRBs. If the data is not physically contiguous, Normal TRBs may > > be chained to the Data Stage TRB. > > > > > > But, in the current imprementation, when two or more TRBs are needed, > > the device driver set XHCI_TRB_TYPE_DATA_STAGE to all TRBs. > > This is the violation of the spec. > > > > In my minor xHCI, I encountered strange bubble error in a control > > transfer. After I changed as the following, I succeeded its control > > transfer. > > > > Would you check the following (****)? > > >=20 > Hi Kohji, >=20 > You are correct there is a bug, but your patch is not correct. >=20 > In FreeBSD we allow SETUP and DATA stages to be done as separate jobs.=20 > That means at the entry of creating a new DATA chain, we need to check=20 > if it is there first DATA packet or not. >=20 > Can you test the attached patch and see if it works for you? >=20 patch is lost somewhere, Hans. --=20 Have fun! chd From owner-freebsd-usb@FreeBSD.ORG Thu Jan 29 19:59:20 2015 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BBAD34DA; Thu, 29 Jan 2015 19:59:20 +0000 (UTC) Received: from mail.turbocat.net (heidi.turbocat.net [88.198.202.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5E57BFEC; Thu, 29 Jan 2015 19:59:19 +0000 (UTC) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 36B111FE023; Thu, 29 Jan 2015 20:59:14 +0100 (CET) Message-ID: <54CA9144.4030601@selasky.org> Date: Thu, 29 Jan 2015 21:00:04 +0100 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Chagin Dmitry Subject: Re: [Bug?] Control Transfers in xHCI References: <20150129.212550.434561541001871867.okuno.kohji@jp.panasonic.com> <54CA4BE3.2090706@selasky.org> <20150129195714.GA3683@dchagin.static.corbina.net> In-Reply-To: <20150129195714.GA3683@dchagin.static.corbina.net> Content-Type: multipart/mixed; boundary="------------020607040003040609030404" Cc: freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2015 19:59:20 -0000 This is a multi-part message in MIME format. --------------020607040003040609030404 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 01/29/15 20:57, Chagin Dmitry wrote: > On Thu, Jan 29, 2015 at 04:04:03PM +0100, Hans Petter Selasky wrote: >> On 01/29/15 13:25, Kohji Okuno wrote: >>> Hi HPS, >>> >>> I found a bug in xHCI device driver. >>> >>> Acording to extensible-host-controler-interface-usb-xhci.pdf:"3.2.9 >>> Control Transfers"... >>> >>> A Data Stage TD consists of a Data Stage TRB followed by zero or more >>> Normal TRBs. If the data is not physically contiguous, Normal TRBs may >>> be chained to the Data Stage TRB. >>> >>> >>> But, in the current imprementation, when two or more TRBs are needed, >>> the device driver set XHCI_TRB_TYPE_DATA_STAGE to all TRBs. >>> This is the violation of the spec. >>> >>> In my minor xHCI, I encountered strange bubble error in a control >>> transfer. After I changed as the following, I succeeded its control >>> transfer. >>> >>> Would you check the following (****)? >>> >> >> Hi Kohji, >> >> You are correct there is a bug, but your patch is not correct. >> >> In FreeBSD we allow SETUP and DATA stages to be done as separate jobs. >> That means at the entry of creating a new DATA chain, we need to check >> if it is there first DATA packet or not. >> >> Can you test the attached patch and see if it works for you? >> > patch is lost somewhere, Hans. > Trying again. I think Kohji got it. --HPS --------------020607040003040609030404 Content-Type: text/x-patch; name="xhci.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xhci.patch" Index: sys/dev/usb/controller/xhci.c =================================================================== --- sys/dev/usb/controller/xhci.c (revision 277724) +++ sys/dev/usb/controller/xhci.c (working copy) @@ -1866,6 +1866,15 @@ XHCI_TRB_3_TYPE_SET(XHCI_TRB_TYPE_DATA_STAGE); if (temp->direction == UE_DIR_IN) dword |= XHCI_TRB_3_DIR_IN | XHCI_TRB_3_ISP_BIT; + /* + * Section 3.2.9 in the XHCI + * specification about control + * transfers says that we should use a + * normal-TRB if there are more TRBs + * extending the data-stage + * TRB. Update the "trb_type". + */ + temp->trb_type = XHCI_TRB_TYPE_NORMAL; break; case XHCI_TRB_TYPE_STATUS_STAGE: dword = XHCI_TRB_3_CHAIN_BIT | XHCI_TRB_3_CYCLE_BIT | @@ -2106,7 +2115,8 @@ mult = 1; temp.isoc_delta = 0; temp.isoc_frame = 0; - temp.trb_type = XHCI_TRB_TYPE_DATA_STAGE; + temp.trb_type = usbd_control_transfer_did_data(xfer) ? + XHCI_TRB_TYPE_NORMAL : XHCI_TRB_TYPE_DATA_STAGE; } else { x = 0; mult = 1; Index: sys/dev/usb/usb_transfer.c =================================================================== --- sys/dev/usb/usb_transfer.c (revision 277724) +++ sys/dev/usb/usb_transfer.c (working copy) @@ -1409,6 +1409,31 @@ } /*------------------------------------------------------------------------* + * usbd_control_transfer_did_data + * + * This function returns non-zero in USB host mode if a control + * endpoint has done the first DATA packet after the SETUP packet. + * Else it return zero. + *------------------------------------------------------------------------*/ +uint8_t +usbd_control_transfer_did_data(struct usb_xfer *xfer) +{ + struct usb_device_request req; + + if (xfer->flags_int.usb_mode == USB_MODE_DEVICE || + xfer->flags_int.control_xfr == 0) + return (0); + + /* copy out the USB request header */ + + usbd_copy_out(xfer->frbuffers, 0, &req, sizeof(req)); + + /* compare remainder to the initial value */ + + return (xfer->flags_int.control_rem != UGETW(req.wLength)); +} + +/*------------------------------------------------------------------------* * usbd_setup_ctrl_transfer * * This function handles initialisation of control transfers. Control Index: sys/dev/usb/usbdi.h =================================================================== --- sys/dev/usb/usbdi.h (revision 277724) +++ sys/dev/usb/usbdi.h (working copy) @@ -529,6 +529,7 @@ void usbd_transfer_stop(struct usb_xfer *xfer); void usbd_transfer_unsetup(struct usb_xfer **pxfer, uint16_t n_setup); void usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max); +uint8_t usbd_control_transfer_did_data(struct usb_xfer *xfer); void usbd_set_parent_iface(struct usb_device *udev, uint8_t iface_index, uint8_t parent_index); uint8_t usbd_get_bus_index(struct usb_device *udev); --------------020607040003040609030404-- From owner-freebsd-usb@FreeBSD.ORG Thu Jan 29 23:26:02 2015 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D99175C3; Thu, 29 Jan 2015 23:26:02 +0000 (UTC) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by mx1.freebsd.org (Postfix) with ESMTP id 79C15A51; Thu, 29 Jan 2015 23:26:01 +0000 (UTC) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile11) with ESMTP id t0TNPxvM019831; Fri, 30 Jan 2015 08:25:59 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili16) with ESMTP id t0TNPxM01201; Fri, 30 Jan 2015 08:25:59 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi12) id t0TNPxpo008983; Fri, 30 Jan 2015 08:25:59 +0900 Received: from localhost by lomi12.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id t0TNPxCR008949; Fri, 30 Jan 2015 08:25:59 +0900 Date: Fri, 30 Jan 2015 08:25:58 +0900 (JST) Message-Id: <20150130.082558.455141361554256806.okuno.kohji@jp.panasonic.com> To: hps@selasky.org Subject: Re: [Bug?] Control Transfers in xHCI From: Kohji Okuno In-Reply-To: <54CA9144.4030601@selasky.org> References: <54CA4BE3.2090706@selasky.org> <20150129195714.GA3683@dchagin.static.corbina.net> <54CA9144.4030601@selasky.org> Organization: Panasonic Corporation X-Mailer: Mew version 6.6 on Emacs 24.4 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jan 2015 23:26:02 -0000 From: Hans Petter Selasky Subject: Re: [Bug?] Control Transfers in xHCI Date: Thu, 29 Jan 2015 21:00:04 +0100 > On 01/29/15 20:57, Chagin Dmitry wrote: >> On Thu, Jan 29, 2015 at 04:04:03PM +0100, Hans Petter Selasky wrote: >>> On 01/29/15 13:25, Kohji Okuno wrote: >>>> Hi HPS, >>>> >>>> I found a bug in xHCI device driver. >>>> >>>> Acording to extensible-host-controler-interface-usb-xhci.pdf:"3.2.9 >>>> Control Transfers"... >>>> >>>> A Data Stage TD consists of a Data Stage TRB followed by zero or more >>>> Normal TRBs. If the data is not physically contiguous, Normal TRBs may >>>> be chained to the Data Stage TRB. >>>> >>>> >>>> But, in the current imprementation, when two or more TRBs are needed, >>>> the device driver set XHCI_TRB_TYPE_DATA_STAGE to all TRBs. >>>> This is the violation of the spec. >>>> >>>> In my minor xHCI, I encountered strange bubble error in a control >>>> transfer. After I changed as the following, I succeeded its control >>>> transfer. >>>> >>>> Would you check the following (****)? >>>> >>> >>> Hi Kohji, >>> >>> You are correct there is a bug, but your patch is not correct. >>> >>> In FreeBSD we allow SETUP and DATA stages to be done as separate jobs. >>> That means at the entry of creating a new DATA chain, we need to check >>> if it is there first DATA packet or not. >>> >>> Can you test the attached patch and see if it works for you? >>> >> patch is lost somewhere, Hans. >> > > Trying again. > > I think Kohji got it. > > --HPS Hi, HPS, Thank you for your commet. I will test your patch next week. Thanks, Kohji Okuno