From nobody Wed Apr 27 19:34:50 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4B14C199CA6B; Wed, 27 Apr 2022 19:34:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KpTV31hSCz3Kwx; Wed, 27 Apr 2022 19:34:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651088091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FrCbFoa6GzL7SSHC9dgHv3peQY5O1GUnP3BSippxvEE=; b=XsS+BL9mkoYwHa/DkkDn6F4T+0jDc0iqx8mUBEW6lCaeMdU17GXrjj7o4PZzghYXsZIpyl iQfnKLpJIz0VPqB/5mggd538gfagyI5pf1WjFX+vwdow5fVPNbuItyif0IU72lfY+XhaqY arNTccdElQH0zsvO68RZPQr7ZCiwxIyOVgVKfoB7rqqW1LFY7JCKI9k0P323y1CDIbcnZ+ hGhWABMGfF9xdm3Lhumk06u2JbDmsZQDFHuRjfdy5Eyv4q9O5fszZGPSw+4W6c1pfk3QDz g17nHY+iJAasSuNkCIlN0BuncrI6cCFAac8yaDYyh9GH+6pbDRqWK/0MlJXPIQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0FA821FAB; Wed, 27 Apr 2022 19:34:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23RJYoHu060971; Wed, 27 Apr 2022 19:34:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RJYo3T060970; Wed, 27 Apr 2022 19:34:50 GMT (envelope-from git) Date: Wed, 27 Apr 2022 19:34:50 GMT Message-Id: <202204271934.23RJYo3T060970@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 245d5a65f580 - releng/13.1 - xhci(4): Ensure the so-called data toggle gets properly reset. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.1 X-Git-Reftype: branch X-Git-Commit: 245d5a65f5805864881e2601190e7783057d2768 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651088091; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FrCbFoa6GzL7SSHC9dgHv3peQY5O1GUnP3BSippxvEE=; b=bFhsiMSkMx69tOtc9cM8Sz/OlP2shb2/j/8EKS67KZZxCNYyAb3obguLf8pXjVzl7PXQfr UvmGEeredE6ejuBG9FaRy0fQ/qbG2IjiMS186ZZJ5t+Zq9q6HLTD9imWjjTkJEdx6ExPnl 71JrzOPKrVgBVemTpC/JEdnRfWercZZo2RjP4AjJWxgbMgaGUi1W55GPDY7hagaAXajGST zDKBeQHMBbha0KNn5N9MF6X6IlG+CZ0oqDM+Fq3XnazLVIb3mRPw7YBu+v3YrTUPzjmvU0 DF5WU+53844kitiO98hYLPdNW73JE3uUuUzxPNryEBB6f8zJ/rs//Ye4nYMdKw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651088091; a=rsa-sha256; cv=none; b=hOOrxjvcEZVPoEn/ZOrmKVJZDcb9OwM0uNmxHrUbKkX6NQxJu+8Gk/JlddFkeo0FV44/1v 6hqIQIjRIRVrfBv7d85oQqasI2L14fqBPGdMTaex7mNRHH1K9RPr6uJMsRn6CwY65AjUqc M9nQuGrkHtwkGaZOS9M5+nd3vLd/apzWp/vuO9zTDWG40ottp9MBav/7knHPUQt/fwFMyO +pqTFjMUxnQOe2ScjRWNeZbjYbQodX4FND7vEzvX0qh3QM7yPYrG5reApgoxy80qlPDSnd 0hxrOuip18JIVSx6+HvmKIftoDeiTulCRm1gcWwuDY6AWiae0UYYV9pYmadMZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=245d5a65f5805864881e2601190e7783057d2768 commit 245d5a65f5805864881e2601190e7783057d2768 Author: Hans Petter Selasky AuthorDate: 2022-04-21 14:59:09 +0000 Commit: Hans Petter Selasky CommitDate: 2022-04-27 19:33:34 +0000 xhci(4): Ensure the so-called data toggle gets properly reset. Use the drop and enable endpoint context commands to force a reset of the data toggle for USB 2.0 and USB 3.0 after: - clear endpoint halt command (when the driver wishes). - set config command (when the kernel or user-space wants). - set alternate setting command (only affected endpoints). Some XHCI HW implementations may not allow the endpoint reset command when the endpoint context is not in the halted state. Reported by: Juniper and Gary Jennejohn Approved by: re (gjb) Sponsored by: NVIDIA Networking (cherry picked from commit cda31e734925346328fd2369585ab3f6767ec225) --- sys/dev/usb/controller/xhci.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index 450f8dbbd9a3..3d551eab2d44 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -3822,6 +3822,7 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer) uint32_t mask; uint8_t index; uint8_t epno; + uint8_t drop; pepext = xhci_get_endpoint_ext(xfer->xroot->udev, xfer->endpoint->edesc); @@ -3863,15 +3864,19 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer) */ switch (xhci_get_endpoint_state(udev, epno)) { case XHCI_EPCTX_0_EPSTATE_DISABLED: - break; + drop = 0; + break; case XHCI_EPCTX_0_EPSTATE_STOPPED: + drop = 1; break; case XHCI_EPCTX_0_EPSTATE_HALTED: err = xhci_cmd_reset_ep(sc, 0, epno, index); - if (err != 0) + drop = (err != 0); + if (drop) DPRINTF("Could not reset endpoint %u\n", epno); break; default: + drop = 1; err = xhci_cmd_stop_ep(sc, 0, epno, index); if (err != 0) DPRINTF("Could not stop endpoint %u\n", epno); @@ -3892,11 +3897,25 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer) */ mask = (1U << epno); - xhci_configure_mask(udev, mask | 1U, 0); + + if (epno != 1 && drop != 0) { + /* drop endpoint context to reset data toggle value, if any. */ + xhci_configure_mask(udev, mask, 1); + err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index); + if (err != 0) { + DPRINTF("Could not drop " + "endpoint %u at slot %u.\n", epno, index); + } else { + sc->sc_hw.devs[index].ep_configured &= ~mask; + } + } + + xhci_configure_mask(udev, mask, 0); if (!(sc->sc_hw.devs[index].ep_configured & mask)) { - sc->sc_hw.devs[index].ep_configured |= mask; err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index); + if (err == 0) + sc->sc_hw.devs[index].ep_configured |= mask; } else { err = xhci_cmd_evaluate_ctx(sc, buf_inp.physaddr, index); }