From nobody Fri Jan 13 10:19:31 2023 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 4Ntcpr1LXtz2p2x5; Fri, 13 Jan 2023 10:19:32 +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 4Ntcpr0pyDz3ktr; Fri, 13 Jan 2023 10:19:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673605172; 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=Jm0mwmzXhHzXbVKw8zbypZL2rPI6gSq4jnb748f42Ps=; b=IlkDbLiJqE9jzrU8gLCZZSa0O27yBI5KjkPv2x5EbQcalAAy09oRJMu5c6tXhBSUjKKzGN aF5GoIYPFmtZV6EbZmBDfctN59JGAWrDfcWxLmm8XXs9wib/AGEA/Yh99h3O3R2QEzFh4N k7tkXcYV7N+0oKH2DH2EGwVWF2dbGu5+2kpIDuRgg2sR/u7RK7BphAa1jmdMIMOmjaoIcm /OsEm8H5ERO0cL7JMNaU8DcVpz/cQHG8NLDmFo0bx2gpVh2U+nPqitu7bIAVA+95Uv3s3d wIWfPUcB8JZDtvdDRf0B/bRrVKwhNVL0mBjYdmM0LuxcYrOfIcxO+8LAB2GhxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1673605172; 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=Jm0mwmzXhHzXbVKw8zbypZL2rPI6gSq4jnb748f42Ps=; b=jIq3ljhOti2aiBkKj4TdZskzXxi60GuHIKg24O2A74aCFBonfYhYJ1pTwhi8/KMAgOp1xt YXyguSPa20zG1/Ey41zor0M+fsrfmPFh4BadTF4iNXMjT6UnELY8ETdYIWU5yxrPggWnmW Gw95YZCE+i70uDljqPmqmvepQx0vL8c9c4Kab8orhYhCnC56z5B5GN+44W0aIxJ654E6m4 7JJezZkRXITAMJvc4vxK5nt+oyXqvsgeWiZGJxFFLPIBEITsYNDtQqVa315H9IbWsIadhZ dzlFCEgmDarlE+RqPgHsojW8O0W47MwqggU7C2mfKAewaY+XPin0jLc/Md+ogQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1673605172; a=rsa-sha256; cv=none; b=SbosgIaGQfxQ0L9bfJnztl6HzEKxzKPLor/DKeQmYDSJtZCdEa032pddwuLcQOddd+4BS1 a5QuJQZzY3mxZy+FoNDlrbFem3TyDrXj3RyKQHl2mQh1LNr1Vek9apbTxPUcfoz8TL0fbl LbQfq8ITtKh8BR2GGMhqXhlji+iatUinm8ZHYxL1e9skKwCSzj1q+Ax12TV1Mdg+U1Go0X dHCRrL2602V86/mw4BLydeZGEfG2DORCytyDy6DfTE7nnRQVn7jkoTcl1LDvFhdIxQATOZ QBbaYq0tPym5VnHmj+Uk6QUdE3nKPHqkelcp7yN0xS7xtwnDRXcGvinyxer6/w== 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 4Ntcpq71t4z13dn; Fri, 13 Jan 2023 10:19:31 +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 30DAJVhM081945; Fri, 13 Jan 2023 10:19:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30DAJVgB081944; Fri, 13 Jan 2023 10:19:31 GMT (envelope-from git) Date: Fri, 13 Jan 2023 10:19:31 GMT Message-Id: <202301131019.30DAJVgB081944@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 8685d7b5cb75 - main - xhci(4): Make sure allocated bandwidth is freed in hardware by unconfiguring endpoint. 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/main X-Git-Reftype: branch X-Git-Commit: 8685d7b5cb759b4f688dea93dbe1c38f9e833e4e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=8685d7b5cb759b4f688dea93dbe1c38f9e833e4e commit 8685d7b5cb759b4f688dea93dbe1c38f9e833e4e Author: Cheng, Huiming AuthorDate: 2022-12-15 22:30:11 +0000 Commit: Hans Petter Selasky CommitDate: 2023-01-13 10:18:19 +0000 xhci(4): Make sure allocated bandwidth is freed in hardware by unconfiguring endpoint. MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/dev/usb/controller/xhci.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/sys/dev/usb/controller/xhci.c b/sys/dev/usb/controller/xhci.c index ba8360e54152..161f443631b2 100644 --- a/sys/dev/usb/controller/xhci.c +++ b/sys/dev/usb/controller/xhci.c @@ -4030,7 +4030,47 @@ xhci_ep_init(struct usb_device *udev, struct usb_endpoint_descriptor *edesc, static void xhci_ep_uninit(struct usb_device *udev, struct usb_endpoint *ep) { + struct xhci_softc *sc = XHCI_BUS2SC(udev->bus); + const struct usb_endpoint_descriptor *edesc = ep->edesc; + struct usb_page_search buf_inp; + struct usb_page_cache *pcinp; + uint32_t mask; + uint8_t index; + uint8_t epno; + usb_error_t err; + + if (udev->parent_hub == NULL) { + /* root HUB has special endpoint handling */ + return; + } + + if ((edesc->bEndpointAddress & UE_ADDR) == 0) { + /* control endpoint is never unconfigured */ + return; + } + XHCI_CMD_LOCK(sc); + index = udev->controller_slot_id; + epno = XHCI_EPNO2EPID(edesc->bEndpointAddress); + mask = 1U << epno; + + if (sc->sc_hw.devs[index].ep_configured & mask) { + USB_BUS_LOCK(udev->bus); + xhci_configure_mask(udev, mask, 1); + USB_BUS_UNLOCK(udev->bus); + + pcinp = &sc->sc_hw.devs[index].input_pc; + usbd_get_page(pcinp, 0, &buf_inp); + err = xhci_cmd_configure_ep(sc, buf_inp.physaddr, 0, index); + if (err) { + DPRINTF("Unconfiguring endpoint failed: %d\n", err); + } else { + USB_BUS_LOCK(udev->bus); + sc->sc_hw.devs[index].ep_configured &= ~mask; + USB_BUS_UNLOCK(udev->bus); + } + } + XHCI_CMD_UNLOCK(sc); } static void