Date: Fri, 6 Nov 2020 00:35:36 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367411 - stable/12/sys/dev/usb/controller Message-ID: <202011060035.0A60Za8Y087035@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Fri Nov 6 00:35:36 2020 New Revision: 367411 URL: https://svnweb.freebsd.org/changeset/base/367411 Log: MFC r366978: xhci: Handle the case when MSI-X BAR is the same as IO BAR. Modified: stable/12/sys/dev/usb/controller/xhci_pci.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- stable/12/sys/dev/usb/controller/xhci_pci.c Fri Nov 6 00:15:52 2020 (r367410) +++ stable/12/sys/dev/usb/controller/xhci_pci.c Fri Nov 6 00:35:36 2020 (r367411) @@ -281,21 +281,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; } } @@ -391,15 +399,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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202011060035.0A60Za8Y087035>