From nobody Wed Aug 26 20:52:13 2026 X-Original-To: dev-commits-src-main@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 4hVcKB14HDz6phZk for ; Wed, 26 Aug 2026 20:52:14 +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 4hVcKB07DFz3lYk for ; Wed, 26 Aug 2026 20:52:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787777534; 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=QEwfiKhxZEGb8pSXPyjoviyGBYTtbhmq7YBUu+JnyEs=; b=v8o6eS9+Ow7XKLkJDRcCDNoo6CThVomy+oKxYYOJT/N8/ehHPuRB7vua/5hArbq0BI1LTv NzYY5l4y0ZMHwrv8GOihy+VecPRn5/6Pt+CLRzXhhZr+a06AjvSkVwPr2d+Jsfb2LGTYSq 6vies0TRrLYqo5MLuNRj0JNUPvalkynZZ4SgNAgmknsdQPsYdnlvr0C3j3xHcITINQoqak oZ7D9eWbbCRURuPndZO6XPolOi8HhbdNMR2LqBca3wEuq7FXXV6QVxtvrA4xBTeSzy24Nc NpOyCkEgYH78m8IpmM58vQNXF+/AS1l8K7dewm2Zwj+pD88MPuoBszGOfBrUNQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787777534; a=rsa-sha256; cv=none; b=pV1Xz3IF2KiuZE9/mpZPI6cd3bmTIVK9syHyNNsvw1GOd8RV/dT7qeoGFEQuRqPwc7TWUk vikSxGj1hgHpWnjerqLTbLedC9fOQGgWgkTu0GfxMI/MwvJJC6FVoWAqYUpuwAsK8CO1Nc PiT3IsMKFv57UZeUiGkgPTsptnI4dM/yzel8vneKOGfMDJcnv25WVvzprqMu762DORAXm5 yd8Pfr/XflgRg7TWObzL4kKLNvdq0o8q/b1ZiG7kgTo837DT3RD6yvK73sN33uEMboP/j4 VEuprO4AV1+xFk9UtaiYSVKN6dyk7VdPad5S/5+pe1GiE3HCqGU0w9quMxpbUw== 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=1787777534; 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=QEwfiKhxZEGb8pSXPyjoviyGBYTtbhmq7YBUu+JnyEs=; b=GAZ7/72z7dtwqfTdEtUWok0Qm5txq6ChhQQ4QOtRF88l+dZ24/O/2mH4OLCWrkI3LRDd3X 9CxbDN8GQ0ALeTb4bqBQG2vyKlVuAHWrvB2VEE9K2a0sm+zNSMbGkcZ+od2vSmmgOsRP8H qXs45WJ/FoCaHZb4Jn16YEKf6h6jO0KAMQObm2rpkCuvvIZD7o0b34rJbO9PiRvpKlFMUx 84y/OS5Q/bmNufBebqiYwfeS29tF5I7YpTz2LSMqahX2NTZAK6AMiETfwIWnBVJtVOY7qk s2NeUL4RWZKqsQMWz1l6/RyhCHaJwZFKOCIF9P5EZ4DINE0S90j8H7mbpIagdQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hVcK95XVnztqr for ; Wed, 26 Aug 2026 20:52:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 25540 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 26 Aug 2026 20:52:13 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: ShengYi Hung Subject: git: 0f59df83869d - main - xhci: Only reset the data toggle value when the USB stack asks for it List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: aokblast X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0f59df83869d3734a33d96b01381823e6a3ef3ff Auto-Submitted: auto-generated Date: Wed, 26 Aug 2026 20:52:13 +0000 Message-Id: <6a8f51fd.25540.12d82200@gitrepo.freebsd.org> The branch main has been updated by aokblast: URL: https://cgit.FreeBSD.org/src/commit/?id=0f59df83869d3734a33d96b01381823e6a3ef3ff commit 0f59df83869d3734a33d96b01381823e6a3ef3ff Author: ShengYi Hung AuthorDate: 2026-08-24 17:51:41 +0000 Commit: ShengYi Hung CommitDate: 2026-08-26 20:52:11 +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") MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D59186 --- 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 c385631f22d7..72a0b704b9b6 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -3940,6 +3940,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 */ @@ -3957,14 +3962,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: /* @@ -3974,9 +3981,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; } @@ -4241,6 +4249,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; };