From owner-svn-src-all@freebsd.org Thu May 3 07:38:47 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D568FFC7B4C; Thu, 3 May 2018 07:38:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 85F7E6E706; Thu, 3 May 2018 07:38:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 80C7E1CC90; Thu, 3 May 2018 07:38:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w437ckeY002474; Thu, 3 May 2018 07:38:46 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w437ckEj002471; Thu, 3 May 2018 07:38:46 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201805030738.w437ckEj002471@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 3 May 2018 07:38:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r333203 - stable/10/sys/dev/usb/controller X-SVN-Group: stable-10 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/10/sys/dev/usb/controller X-SVN-Commit-Revision: 333203 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2018 07:38:47 -0000 Author: hselasky Date: Thu May 3 07:38:45 2018 New Revision: 333203 URL: https://svnweb.freebsd.org/changeset/base/333203 Log: MFC r333100: Improve fix in r304629 by allowing configuration of the behaviour through a SYSCTL instead of a compile time define. Add quirk by default for all LynxPoint XHCI controllers. PR: 227602 Sponsored by: Mellanox Technologies Modified: stable/10/sys/dev/usb/controller/xhci.c stable/10/sys/dev/usb/controller/xhci.h stable/10/sys/dev/usb/controller/xhci_pci.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/10/sys/dev/usb/controller/xhci.c Thu May 3 07:37:49 2018 (r333202) +++ stable/10/sys/dev/usb/controller/xhci.c Thu May 3 07:38:45 2018 (r333203) @@ -99,6 +99,7 @@ static int xhcidebug; static int xhciroute; static int xhcipolling; static int xhcidma32; +static int xhcictlstep; SYSCTL_INT(_hw_usb_xhci, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &xhcidebug, 0, "Debug level"); @@ -112,9 +113,13 @@ TUNABLE_INT("hw.usb.xhci.use_polling", &xhcipolling); SYSCTL_INT(_hw_usb_xhci, OID_AUTO, dma32, CTLFLAG_RWTUN, &xhcidma32, 0, "Set to only use 32-bit DMA for the XHCI controller"); TUNABLE_INT("hw.usb.xhci.dma32", &xhcidma32); +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, ctlstep, CTLFLAG_RWTUN, + &xhcictlstep, 0, "Set to enable control endpoint status stage stepping"); +TUNABLE_INT("hw.usb.xhci.ctlstep", &xhcictlstep); #else #define xhciroute 0 #define xhcidma32 0 +#define xhcictlstep 0 #endif #define XHCI_INTR_ENDPT 1 @@ -2244,11 +2249,17 @@ xhci_setup_generic_chain(struct usb_xfer *xfer) * Send a DATA1 message and invert the current * endpoint direction. */ -#ifdef XHCI_STEP_STATUS_STAGE - temp.step_td = (xfer->nframes != 0); -#else - temp.step_td = 0; -#endif + if (xhcictlstep || temp.sc->sc_ctlstep) { + /* + * Some XHCI controllers will not delay the + * status stage until the next SOF. Force this + * behaviour to avoid failed control + * transfers. + */ + temp.step_td = (xfer->nframes != 0); + } else { + temp.step_td = 0; + } temp.direction = UE_GET_DIR(xfer->endpointno) ^ UE_DIR_IN; temp.len = 0; temp.pc = NULL; Modified: stable/10/sys/dev/usb/controller/xhci.h ============================================================================== --- stable/10/sys/dev/usb/controller/xhci.h Thu May 3 07:37:49 2018 (r333202) +++ stable/10/sys/dev/usb/controller/xhci.h Thu May 3 07:38:45 2018 (r333203) @@ -506,6 +506,8 @@ struct xhci_softc { uint8_t sc_noport; /* root HUB device configuration */ uint8_t sc_conf; + /* step status stage of all control transfers */ + uint8_t sc_ctlstep; /* root HUB port event bitmap, max 256 ports */ uint8_t sc_hub_idata[32]; Modified: stable/10/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- stable/10/sys/dev/usb/controller/xhci_pci.c Thu May 3 07:37:49 2018 (r333202) +++ stable/10/sys/dev/usb/controller/xhci_pci.c Thu May 3 07:38:45 2018 (r333203) @@ -240,6 +240,7 @@ xhci_pci_attach(device_t self) */ sc->sc_port_route = &xhci_pci_port_route; sc->sc_imod_default = XHCI_IMOD_DEFAULT_LP; + sc->sc_ctlstep = 1; break; }