From owner-svn-src-head@freebsd.org Thu Dec 24 09:40:31 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC724A4F81B; Thu, 24 Dec 2015 09:40:30 +0000 (UTC) (envelope-from andrew@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 mx1.freebsd.org (Postfix) with ESMTPS id AADC21833; Thu, 24 Dec 2015 09:40:30 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tBO9eTQn093783; Thu, 24 Dec 2015 09:40:29 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tBO9eTeQ093781; Thu, 24 Dec 2015 09:40:29 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201512240940.tBO9eTeQ093781@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Thu, 24 Dec 2015 09:40:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r292683 - head/sys/dev/usb/controller X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2015 09:40:31 -0000 Author: andrew Date: Thu Dec 24 09:40:29 2015 New Revision: 292683 URL: https://svnweb.freebsd.org/changeset/base/292683 Log: Ads support to the xhci pci attachment to use MSI-X interrupts when available. As with MSI interrupts these can be disabled by setting hw.usb.xhci.msix to 0 in the loader. MSI-X interrupts are needed on some hardware, for example the Cavium ThunderX only supports them, and with this we don't fall back to polling. PR: 204378 Reviewed by: hselasky, jhb MFC after: 1 week (after r292669) Sponsored by: ABT Systems Ltd Differential Revision: https://reviews.freebsd.org/D4698 Modified: head/sys/dev/usb/controller/xhci.h head/sys/dev/usb/controller/xhci_pci.c Modified: head/sys/dev/usb/controller/xhci.h ============================================================================== --- head/sys/dev/usb/controller/xhci.h Thu Dec 24 06:22:41 2015 (r292682) +++ head/sys/dev/usb/controller/xhci.h Thu Dec 24 09:40:29 2015 (r292683) @@ -465,6 +465,7 @@ struct xhci_softc { struct usb_device *sc_devices[XHCI_MAX_DEVICES]; struct resource *sc_io_res; struct resource *sc_irq_res; + struct resource *sc_msix_res; void *sc_intr_hdl; bus_size_t sc_io_size; Modified: head/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- head/sys/dev/usb/controller/xhci_pci.c Thu Dec 24 06:22:41 2015 (r292682) +++ head/sys/dev/usb/controller/xhci_pci.c Thu Dec 24 09:40:29 2015 (r292683) @@ -148,6 +148,8 @@ xhci_pci_probe(device_t self) static int xhci_use_msi = 1; TUNABLE_INT("hw.usb.xhci.msi", &xhci_use_msi); +static int xhci_use_msix = 1; +TUNABLE_INT("hw.usb.xhci.msix", &xhci_use_msix); static void xhci_interrupt_poll(void *_sc) @@ -188,7 +190,7 @@ static int xhci_pci_attach(device_t self) { struct xhci_softc *sc = device_get_softc(self); - int count, err, rid; + int count, err, msix_table, rid; uint8_t usemsi = 1; uint8_t usedma32 = 0; @@ -240,7 +242,27 @@ xhci_pci_attach(device_t self) usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0); rid = 0; - if (xhci_use_msi && usemsi) { + 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"); + } else { + 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); + sc->sc_msix_res = NULL; + } + } + } + if (rid == 0 && xhci_use_msi && usemsi) { count = 1; if (pci_alloc_msi(self, &count) == 0) { if (bootverbose) @@ -341,6 +363,11 @@ xhci_pci_detach(device_t self) 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);