From nobody Fri Sep 04 18:49:15 2026 X-Original-To: dev-commits-src-branches@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 4hc5975CZ7z6r5W7 for ; Fri, 04 Sep 2026 18:49:15 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hc5973l2rz3Bt1 for ; Fri, 04 Sep 2026 18:49:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788547755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LHeOSAkivlQcDFJ+71gH5JKaDg9vKWk9YPkRE1Lh02k=; b=FWUyBI+nGz+LUtP+0ycKZFNDwm5D+FcaZcC69+B2OJedxv/ZyNIJMAIBh1fb+9g50SWh1x WbiO2uBwrdHAi2idOknfygqrnZEsAeMErdgovy3snvER/kMwItuA1gbjsCqTS9MSXeas2K +rdpj/H7Uj3uePGyvbmkg9oEidc4cegqgRG59t2zATI8MA31b+ExvRAUxJM0TQfUkJxoVb Xo9vsbQ+UdaPfpFWV8gNDw+QqZuFlB+g7GVISxLM23+AS5og/xO3USQw89KFb1ir3c+jHG WMhzrsdU/PmKf36bbNXJ2OS9N7Oi56fnDlp9iuGqZ1dM3Dy8Uu6kwuiMddgE7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788547755; a=rsa-sha256; cv=none; b=BnQaqpIlRclUHbkpu/R6i7DGjVczIZdxSIrtN/QDuoXPPkCvfLfol8cAOLuXB0Br0WFhWS V+jJ77OYrM3JqfEKo/orzhM6CzAkk0nNsHocL7qL7gscZay50Jen4RUUNokqDo6GKZp5Mh VlsyFez+dblJ3V/PpMePSIv04dVU66ypo6vLJB+HKK2V8dNUwm4U+wHnZ82axsXaw2C7S4 Q9ktKEYCqWiXnrszsn09Y7fndvSUEcG1ni/jwAJmk7wVZYBDPPd11dXyc6SsMOSpqC0nNe RchASrXwtZ8zvHsQwuvoLsDDh+8Nxzsbv5TkHd9Ii7a4ttv+ZENS7VY2ZW8cag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788547755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LHeOSAkivlQcDFJ+71gH5JKaDg9vKWk9YPkRE1Lh02k=; b=I+Y61EjSW19gY5xRxEfvESDtOY818myUFz54sakcCE1GqZMjnvdXNiZL+7fAvFJr/4/ZKx RT6NZDiVmrwNULlk6gbwwz/DDd7N2m5sFL3jEuvf8fhoTblSBClD7smc5NLH8BKMpf7UPy AkavlWFR9igH7kH715bK/0es/sFeeQ9SYTpHpeFQkGlbq4yAx8jntmH6IyYvoL4bDaGI8f Hcluhagaz1zxBReEXT5ebzQYIlJpSvOT1yjInsFI9E1CYc7g6kBPWLbX0bCr3yM+DJBHQQ NEFzlmP0QtktGYUqgSF6Zkl02RXZrxWeFfhD2Ta3G/I45gr6vs30K16SNLhOUQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hc59717kfz1B9n for ; Fri, 04 Sep 2026 18:49:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2102b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 04 Sep 2026 18:49:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: ShengYi Hung From: Kyle Evans Subject: git: 96dfa566fc16 - stable/15 - xhci: Only reset the data toggle value when the USB stack asks for it List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 96dfa566fc168fa386710451e5d1f036ac387cf6 Auto-Submitted: auto-generated Date: Fri, 04 Sep 2026 18:49:15 +0000 Message-Id: <6a9b12ab.2102b.7c426f1b@gitrepo.freebsd.org> The branch stable/15 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=96dfa566fc168fa386710451e5d1f036ac387cf6 commit 96dfa566fc168fa386710451e5d1f036ac387cf6 Author: ShengYi Hung AuthorDate: 2026-08-24 17:51:41 +0000 Commit: Kyle Evans CommitDate: 2026-09-04 17:56:15 +0000 xhci: Only reset the data toggle value when the USB stack asks for it The previous patch assumes that we don't want to reset toggle bit in STOPPED_STEP. However, a device can explicitly call usbd_clear_data_toggle if necessary. As a result, instead of not dropping the bit unconditionally, we added a field in xhci to specify that we want to drop it, so that usbd_clear_data_toggle can handle it correctly. Reported by: oh Reviewed by: kevans Tested by: oh Fixes: 28d85db46b48 ("xhci: Do not drop and add bits in xhci") (cherry picked from commit 0f59df83869d3734a33d96b01381823e6a3ef3ff) --- sys/dev/usb/controller/xhci.c | 23 ++++++++++++++++++----- sys/dev/usb/controller/xhci.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index b6ea3b9660e1..3e1be78aded7 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -3881,6 +3881,11 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer) if (epno == 0) return (USB_ERR_NO_PIPE); /* invalid */ + USB_BUS_LOCK(udev->bus); + drop = pepext->trb_toggle_reset; + pepext->trb_toggle_reset = 0; + USB_BUS_UNLOCK(udev->bus); + XHCI_CMD_LOCK(sc); /* configure endpoint */ @@ -3898,14 +3903,16 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer) */ switch (xhci_get_endpoint_state(udev, epno)) { case XHCI_EPCTX_0_EPSTATE_DISABLED: - case XHCI_EPCTX_0_EPSTATE_STOPPED: drop = 0; break; + case XHCI_EPCTX_0_EPSTATE_STOPPED: + break; case XHCI_EPCTX_0_EPSTATE_HALTED: err = xhci_cmd_reset_ep(sc, 0, epno, index); - drop = (err != 0); - if (drop) + if (err != 0) { + drop = 1; DPRINTF("Could not reset endpoint %u\n", epno); + } break; default: /* @@ -3915,9 +3922,10 @@ xhci_configure_reset_endpoint(struct usb_xfer *xfer) * result, xHCI may refuse to receive or process the packet. */ err = xhci_cmd_stop_ep(sc, 0, epno, index); - drop = (err != 0); - if (drop) + if (err != 0) { + drop = 1; DPRINTF("Could not stop endpoint %u\n", epno); + } break; } @@ -4182,6 +4190,11 @@ xhci_ep_clear_stall(struct usb_device *udev, struct usb_endpoint *ep) USB_BUS_LOCK(udev->bus); pepext->trb_halted = 1; pepext->trb_running = 0; + /* + * The USB stack has cleared its own data toggle value and expects + * the hardware data toggle value to be cleared as well: + */ + pepext->trb_toggle_reset = 1; USB_BUS_UNLOCK(udev->bus); } diff --git a/sys/dev/usb/controller/xhci.h b/sys/dev/usb/controller/xhci.h index 3758815238ad..c2e6cde8ad77 100644 --- a/sys/dev/usb/controller/xhci.h +++ b/sys/dev/usb/controller/xhci.h @@ -419,6 +419,7 @@ struct xhci_endpoint_ext { uint8_t trb_index[XHCI_MAX_STREAMS]; uint8_t trb_halted; uint8_t trb_running; + uint8_t trb_toggle_reset; uint8_t trb_ep_mode; uint8_t trb_ep_maxp; };