PERFORCE change 94874 for review
John-Mark Gurney
jmg at FreeBSD.org
Sun Apr 9 21:52:10 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=94874
Change 94874 by jmg at 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);
}
More information about the p4-projects
mailing list