From owner-p4-projects@FreeBSD.ORG Sun Apr 9 21:52:09 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D3C5316A403; Sun, 9 Apr 2006 21:52:09 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AE07C16A400 for ; Sun, 9 Apr 2006 21:52:09 +0000 (UTC) (envelope-from jmg@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5FFA243D45 for ; Sun, 9 Apr 2006 21:52:09 +0000 (GMT) (envelope-from jmg@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k39Lq9k9094295 for ; Sun, 9 Apr 2006 21:52:09 GMT (envelope-from jmg@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k39Lq915094285 for perforce@freebsd.org; Sun, 9 Apr 2006 21:52:09 GMT (envelope-from jmg@freebsd.org) Date: Sun, 9 Apr 2006 21:52:09 GMT Message-Id: <200604092152.k39Lq915094285@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmg@freebsd.org using -f From: John-Mark Gurney To: Perforce Change Reviews Cc: Subject: PERFORCE change 94874 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Apr 2006 21:52:10 -0000 http://perforce.freebsd.org/chv.cgi?CH=94874 Change 94874 by jmg@jmg_arlene on 2006/04/09 21:51:31 add intr refcnt so that we know when to deallocate the intr resource... Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hv_pcivar.h#8 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hv_pci.c#34 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hv_pcivar.h#8 (text+ko) ==== @@ -37,6 +37,7 @@ struct bus_dma_tag hs_dmatag; struct resource *hs_intr[4]; + int hs_intrrefcnt[4]; struct rman hs_pci_intr_rman; ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hv_pci.c#34 (text+ko) ==== @@ -390,21 +390,26 @@ KASSERT(pciintr >= 0 && pciintr <= 3, ("interrupt out of range")); rid = pciintr + 1; - if (sc->hs_intr[pciintr] != NULL) - return (EBUSY); + if (sc->hs_intr[pciintr] == NULL) { + if ((sc->hs_intr[pciintr] = bus_alloc_resource_any(dev, + SYS_RES_IRQ, &rid, RF_SHAREABLE | RF_ACTIVE)) == NULL) { + device_printf(dev, "couldn't alloc interrupt\n"); + return (ENXIO); + } + sc->hs_intrrefcnt[pciintr] = 1; + } else + sc->hs_intrrefcnt[pciintr]++; - if ((sc->hs_intr[pciintr] = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &rid, RF_SHAREABLE | RF_ACTIVE)) == NULL) { - device_printf(dev, "couldn't alloc interrupt\n"); - return (ENXIO); - } - error = bus_setup_intr(dev, sc->hs_intr[pciintr], flags, intr, arg, cookiep); if (error) { - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->hs_intr[pciintr]), sc->hs_intr[pciintr]); - sc->hs_intr[pciintr] = NULL; + sc->hs_intrrefcnt[pciintr]--; + if (sc->hs_intrrefcnt[pciintr] == 0) { + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(sc->hs_intr[pciintr]), + sc->hs_intr[pciintr]); + sc->hs_intr[pciintr] = NULL; + } device_printf(dev, "bus_setup_intr: %d\n", error); return (error); } @@ -427,9 +432,12 @@ if (error) return (error); - bus_release_resource(dev, SYS_RES_IRQ, - rman_get_rid(sc->hs_intr[pciintr]), sc->hs_intr[pciintr]); - sc->hs_intr[pciintr] = NULL; + sc->hs_intrrefcnt[pciintr]--; + if (sc->hs_intrrefcnt[pciintr] == 0) { + bus_release_resource(dev, SYS_RES_IRQ, + rman_get_rid(sc->hs_intr[pciintr]), sc->hs_intr[pciintr]); + sc->hs_intr[pciintr] = NULL; + } return (0); }