From nobody Mon May 2 22:25:10 2022 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 093CA1AA8230; Mon, 2 May 2022 22:25:12 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ksd2H6rPKz3Kxl; Mon, 2 May 2022 22:25:11 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651530312; 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: in-reply-to:in-reply-to:references:references; bh=gVxH9l1ukYGuiM6Uu59H15rSRQ7l5L02YLN6QPPa6xU=; b=HiMv4sNJx7wBMxKi6bGPSZKDFQEPXuICnih6eEPTHQ9CQLwuoKOVgyF3aVueZPBsG5aNch o0KUCajK3gjde9Le/aA+3IPgLzPVGkM0J1IilRXk1hwZs+c3Kae8Wn0VWL6KMWHDpPU0xU Z7W672wpVnPSYUn3hDIJoaL3lgrRhI8/zWWYvmyc/DSn0jsK7WtDkeqnzjBpDP7sZAhqsA rZOj2qOwOGbECBfo9jUG9ODUyUh1q5Q7i3Z75FNJXKKSRffeypkm17AguYqTmvCyOb3Eb8 3B+J5rb38TKsPlOI5b97SfQ+PWQIR4mpm8n4AAk4pmxZeUnPpC8bUlJI9Npvgw== Received: from [IPV6:2601:405:4a00:acd:5d9:1486:bf4c:f6c8] (unknown [IPv6:2601:405:4a00:acd:5d9:1486:bf4c:f6c8]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: nwhitehorn/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 984F7ECFE; Mon, 2 May 2022 22:25:11 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Message-ID: <7af2c933-c907-6da0-1ea2-5e9afba50f78@freebsd.org> Date: Mon, 2 May 2022 18:25:10 -0400 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: en-US To: Hans Petter Selasky , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202204211502.23LF2g2L010181@gitrepo.freebsd.org> From: Nathan Whitehorn Subject: Re: git: cda31e734925 - main - xhci(4): Ensure the so-called data toggle gets properly reset. In-Reply-To: <202204211502.23LF2g2L010181@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651530312; 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: in-reply-to:in-reply-to:references:references; bh=gVxH9l1ukYGuiM6Uu59H15rSRQ7l5L02YLN6QPPa6xU=; b=QqHOTq+ewKUKG+pDp6soEu6GqUENFX+Ta1mep4ij1XPisRdMr0eghsDg7cHmjsXeKyxXMF NtFNG92WBxak4oxupo4ddLuAHZ7ZU7ypa/CfEUTPBGJCvcImzr4H1AFNfJaJky3XcBws9/ 1NWNl0n97Gc21L3yDRX/iSldEj+uoYRjJh3ngiKQEWwmTYbxVQ/dF77/45cSG1lxKhDg8K hIxeHb4OfUlDHjbp//0QTO8NR33qE9Oe6OEqPYsDE6qh5nfi0OWL1Kl4q/qGxU+PLjKPvt BuGj8c6xqSG1X+/cnOkh+ZvSFuOhsTh3ghnAVZ2G8ff6kdqVb+JG3xX4njPtAg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651530312; a=rsa-sha256; cv=none; b=n3GB2OLgNk9mpp2QTYbEalmVCr5RTRb2dB0GXAcayIOBzLXyGq0CSRrYJ/dlcSRzMeMTvu V51BhlzXCrx0IFuXrda05e4/EN0TDHTU+OTpJUc1RfhD+3bbekTdfAlUiHYxUPwrUOpMeo jdY9KWU1n//i0YPAUj+cqQijKeMzoZYxnIu4fvJj4ppT3keMScZC3Zpfba1pbRDcRNtzZz TkCGuXr0T11BAGkuRYqi3sXbmLruzt1s3NzPlsHH3U1ahdecW9ErUdn8oiOMlBwGKyUPTQ 4Edi4W+/WWw86fHanNvnJphd9O0KYmxAphz6FZvW4ZIAyX2kCA3jIjXuaFCE1A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N After this change, I cannot use devices attached to the USB 3 hub in my Dell monitor anymore. The hub appears properly, but any device plugged into it just leaves this in dmesg: ugen0.3: at usbus0 (disconnected) Note that there is no corresponding connected message or anything else. This is with an AMD XHCI controller: xhci0@pci0:2:0:0:       class=0x0c0330 rev=0x02 hdr=0x00 vendor=0x1022 device=0x43bb subvendor=0x1b21 subdevice=0x1142     vendor     = 'Advanced Micro Devices, Inc. [AMD]'     device     = '300 Series Chipset USB 3.1 xHCI Controller' -Nathan On 4/21/22 11:02, Hans Petter Selasky wrote: > The branch main has been updated by hselasky: > > URL: https://cgit.FreeBSD.org/src/commit/?id=cda31e734925346328fd2369585ab3f6767ec225 > > commit cda31e734925346328fd2369585ab3f6767ec225 > Author: Hans Petter Selasky > AuthorDate: 2022-04-21 14:59:09 +0000 > Commit: Hans Petter Selasky > CommitDate: 2022-04-21 15:01:13 +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 > MFC after: 1 week > Sponsored by: NVIDIA Networking > --- > 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 f95996b7ab32..72d1ff5e0ae5 100644 > --- a/sys/dev/usb/controller/xhci.c > +++ b/sys/dev/usb/controller/xhci.c > @@ -3772,6 +3772,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); > @@ -3813,15 +3814,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); > @@ -3842,11 +3847,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); > } >