Date: Sun, 9 Apr 2006 21:52:09 GMT From: John-Mark Gurney <jmg@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 94874 for review Message-ID: <200604092152.k39Lq915094285@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604092152.k39Lq915094285>