From owner-svn-src-stable@FreeBSD.ORG Tue Jul 16 06:50:23 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 3AFCB876; Tue, 16 Jul 2013 06:50:23 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 155C91C2; Tue, 16 Jul 2013 06:50:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6G6oMx5034219; Tue, 16 Jul 2013 06:50:22 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6G6oMv1034217; Tue, 16 Jul 2013 06:50:22 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201307160650.r6G6oMv1034217@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 16 Jul 2013 06:50:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r253379 - stable/9/sys/dev/usb/controller X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Jul 2013 06:50:23 -0000 Author: kib Date: Tue Jul 16 06:50:22 2013 New Revision: 253379 URL: http://svnweb.freebsd.org/changeset/base/253379 Log: MFC r253094: Use MSI for xhci(4), if supported. Approved by: re (delphij) Modified: stable/9/sys/dev/usb/controller/xhci.h stable/9/sys/dev/usb/controller/xhci_pci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/usb/controller/xhci.h ============================================================================== --- stable/9/sys/dev/usb/controller/xhci.h Tue Jul 16 06:43:37 2013 (r253378) +++ stable/9/sys/dev/usb/controller/xhci.h Tue Jul 16 06:50:22 2013 (r253379) @@ -436,6 +436,7 @@ struct xhci_softc { struct usb_device *sc_devices[XHCI_MAX_DEVICES]; struct resource *sc_io_res; + int sc_irq_rid; struct resource *sc_irq_res; void *sc_intr_hdl; Modified: stable/9/sys/dev/usb/controller/xhci_pci.c ============================================================================== --- stable/9/sys/dev/usb/controller/xhci_pci.c Tue Jul 16 06:43:37 2013 (r253378) +++ stable/9/sys/dev/usb/controller/xhci_pci.c Tue Jul 16 06:50:22 2013 (r253379) @@ -136,8 +136,7 @@ static int xhci_pci_attach(device_t self) { struct xhci_softc *sc = device_get_softc(self); - int err; - int rid; + int count, err, rid; /* XXX check for 64-bit capability */ @@ -159,9 +158,18 @@ xhci_pci_attach(device_t self) sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); sc->sc_io_size = rman_get_size(sc->sc_io_res); - rid = 0; - sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + sc->sc_irq_rid = 0; + count = pci_msi_count(self); + if (count >= 1) { + count = 1; + if (pci_alloc_msi(self, &count) == 0) { + if (bootverbose) + device_printf(self, "MSI enabled\n"); + sc->sc_irq_rid = 1; + } + } + sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, + &sc->sc_irq_rid, RF_SHAREABLE | RF_ACTIVE); if (sc->sc_irq_res == NULL) { device_printf(self, "Could not allocate IRQ\n"); goto error; @@ -232,7 +240,10 @@ xhci_pci_detach(device_t self) sc->sc_intr_hdl = NULL; } if (sc->sc_irq_res) { - bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res); + if (sc->sc_irq_rid == 1) + pci_release_msi(self); + bus_release_resource(self, SYS_RES_IRQ, sc->sc_irq_rid, + sc->sc_irq_res); sc->sc_irq_res = NULL; } if (sc->sc_io_res) {