From owner-svn-src-all@freebsd.org Fri Oct 23 18:18:45 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA81044C961; Fri, 23 Oct 2020 18:18:45 +0000 (UTC) (envelope-from kib@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CHstY50spz4S5V; Fri, 23 Oct 2020 18:18:45 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 753F3B8A5; Fri, 23 Oct 2020 18:18:45 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09NIIjc5067669; Fri, 23 Oct 2020 18:18:45 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09NIIj5x067668; Fri, 23 Oct 2020 18:18:45 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202010231818.09NIIj5x067668@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 23 Oct 2020 18:18:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366978 - head/sys/dev/usb/controller X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/dev/usb/controller X-SVN-Commit-Revision: 366978 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Oct 2020 18:18:45 -0000 Author: kib Date: Fri Oct 23 18:18:45 2020 New Revision: 366978 URL: https://svnweb.freebsd.org/changeset/base/366978 Log: xhci: Handle the case when MSI-X BAR is the same as IO BAR. PCIe allows for MSI-X BAR to be either dedicated, or MSI-X Table may be co-located in some functional BAR. In the later case xhci(4) is unable to allocate active resource for the table because BAR is already activated. Handle it by checking for this special case, and not try to alloc resource if MSI-X BAR is IO. Reported and tested by: emaste Reviewed by: emaste, hselasky Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D26913 Modified: head/sys/dev/usb/controller/xhci_pci.c Modified: head/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- head/sys/dev/usb/controller/xhci_pci.c Fri Oct 23 16:35:23 2020 (r366977) +++ head/sys/dev/usb/controller/xhci_pci.c Fri Oct 23 18:18:45 2020 (r366978) @@ -277,21 +277,29 @@ xhci_pci_attach(device_t self) rid = 0; if (xhci_use_msix && (msix_table = pci_msix_table_bar(self)) >= 0) { - sc->sc_msix_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, - &msix_table, RF_ACTIVE); - if (sc->sc_msix_res == NULL) { - /* May not be enabled */ - device_printf(self, - "Unable to map MSI-X table \n"); + if (msix_table == PCI_XHCI_CBMEM) { + sc->sc_msix_res = sc->sc_io_res; } else { + sc->sc_msix_res = bus_alloc_resource_any(self, + SYS_RES_MEMORY, &msix_table, RF_ACTIVE); + if (sc->sc_msix_res == NULL) { + /* May not be enabled */ + device_printf(self, + "Unable to map MSI-X table\n"); + } + } + if (sc->sc_msix_res != NULL) { count = 1; if (pci_alloc_msix(self, &count) == 0) { if (bootverbose) device_printf(self, "MSI-X enabled\n"); rid = 1; } else { - bus_release_resource(self, SYS_RES_MEMORY, - msix_table, sc->sc_msix_res); + if (sc->sc_msix_res != sc->sc_io_res) { + bus_release_resource(self, + SYS_RES_MEMORY, + msix_table, sc->sc_msix_res); + } sc->sc_msix_res = NULL; } } @@ -387,15 +395,15 @@ xhci_pci_detach(device_t self) sc->sc_irq_res = NULL; pci_release_msi(self); } + if (sc->sc_msix_res != NULL && sc->sc_msix_res != sc->sc_io_res) { + bus_release_resource(self, SYS_RES_MEMORY, + rman_get_rid(sc->sc_msix_res), sc->sc_msix_res); + sc->sc_msix_res = NULL; + } if (sc->sc_io_res) { bus_release_resource(self, SYS_RES_MEMORY, PCI_XHCI_CBMEM, sc->sc_io_res); sc->sc_io_res = NULL; - } - if (sc->sc_msix_res) { - bus_release_resource(self, SYS_RES_MEMORY, - rman_get_rid(sc->sc_msix_res), sc->sc_msix_res); - sc->sc_msix_res = NULL; } xhci_uninit(sc);