From owner-svn-src-stable-9@FreeBSD.ORG Fri Apr 25 21:28:42 2014 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 64832FA6; Fri, 25 Apr 2014 21:28:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 378F81952; Fri, 25 Apr 2014 21:28:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3PLSgva049364; Fri, 25 Apr 2014 21:28:42 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3PLSgHA049363; Fri, 25 Apr 2014 21:28:42 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201404252128.s3PLSgHA049363@svn.freebsd.org> From: Marius Strobl Date: Fri, 25 Apr 2014 21:28:42 +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: r264941 - stable/9/sys/dev/bge 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-9@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2014 21:28:42 -0000 Author: marius Date: Fri Apr 25 21:28:41 2014 New Revision: 264941 URL: http://svnweb.freebsd.org/changeset/base/264941 Log: MFC: r260045 - Simplify MSI allocation and release. For a single one, we don't need to fiddle with the MSI count and pci_release_msi(9) is smart enough to just do nothing in case of INTx. - Don't allocate MSI as RF_SHAREABLE. Modified: stable/9/sys/dev/bge/if_bge.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/bge/if_bge.c ============================================================================== --- stable/9/sys/dev/bge/if_bge.c Fri Apr 25 21:28:39 2014 (r264940) +++ stable/9/sys/dev/bge/if_bge.c Fri Apr 25 21:28:41 2014 (r264941) @@ -3326,7 +3326,7 @@ bge_attach(device_t dev) struct bge_softc *sc; uint32_t hwcfg = 0, misccfg, pcistate; u_char eaddr[ETHER_ADDR_LEN]; - int capmask, error, msicount, reg, rid, trys; + int capmask, error, reg, rid, trys; sc = device_get_softc(dev); sc->bge_dev = dev; @@ -3335,11 +3335,11 @@ bge_attach(device_t dev) TASK_INIT(&sc->bge_intr_task, 0, bge_intr_task, sc); callout_init_mtx(&sc->bge_stat_ch, &sc->bge_mtx, 0); - /* - * Map control/status registers. - */ pci_enable_busmaster(dev); + /* + * Allocate control/status registers. + */ rid = PCIR_BAR(0); sc->bge_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); @@ -3649,13 +3649,8 @@ bge_attach(device_t dev) rid = 0; if (pci_find_cap(sc->bge_dev, PCIY_MSI, ®) == 0) { sc->bge_msicap = reg; - if (bge_can_use_msi(sc)) { - msicount = pci_msi_count(dev); - if (msicount > 1) - msicount = 1; - } else - msicount = 0; - if (msicount == 1 && pci_alloc_msi(dev, &msicount) == 0) { + reg = 1; + if (bge_can_use_msi(sc) && pci_alloc_msi(dev, ®) == 0) { rid = 1; sc->bge_flags |= BGE_FLAG_MSI; } @@ -3672,7 +3667,7 @@ bge_attach(device_t dev) #endif sc->bge_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + RF_ACTIVE | (rid != 0 ? 0 : RF_SHAREABLE)); if (sc->bge_irq == NULL) { device_printf(sc->bge_dev, "couldn't map interrupt\n"); @@ -4015,20 +4010,19 @@ bge_release_resources(struct bge_softc * if (sc->bge_intrhand != NULL) bus_teardown_intr(dev, sc->bge_irq, sc->bge_intrhand); - if (sc->bge_irq != NULL) + if (sc->bge_irq != NULL) { bus_release_resource(dev, SYS_RES_IRQ, - sc->bge_flags & BGE_FLAG_MSI ? 1 : 0, sc->bge_irq); - - if (sc->bge_flags & BGE_FLAG_MSI) + rman_get_rid(sc->bge_irq), sc->bge_irq); pci_release_msi(dev); + } if (sc->bge_res != NULL) bus_release_resource(dev, SYS_RES_MEMORY, - PCIR_BAR(0), sc->bge_res); + rman_get_rid(sc->bge_res), sc->bge_res); if (sc->bge_res2 != NULL) bus_release_resource(dev, SYS_RES_MEMORY, - PCIR_BAR(2), sc->bge_res2); + rman_get_rid(sc->bge_res2), sc->bge_res2); if (sc->bge_ifp != NULL) if_free(sc->bge_ifp);