From 8c21a84e58bb1e4c1e603bbf09febad5a37f70a7 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 3 May 2002 08:44:53 +0000 Subject: Don't grab the lock until somewhat later in attach to avoid a lock reversal. --- sys/dev/dc/if_dc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index 905f2bc..8deb27e 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -1783,7 +1783,6 @@ static int dc_attach(dev) mtx_init(&sc->dc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE); - DC_LOCK(sc); /* * Handle power management nonsense. @@ -1802,13 +1801,13 @@ static int dc_attach(dev) if (!(command & PCIM_CMD_PORTEN)) { printf("dc%d: failed to enable I/O ports!\n", unit); error = ENXIO; - goto fail; + goto fail_nolock; } #else if (!(command & PCIM_CMD_MEMEN)) { printf("dc%d: failed to enable memory mapping!\n", unit); error = ENXIO; - goto fail; + goto fail_nolock; } #endif @@ -1819,7 +1818,7 @@ static int dc_attach(dev) if (sc->dc_res == NULL) { printf("dc%d: couldn't map ports/memory\n", unit); error = ENXIO; - goto fail; + goto fail_nolock; } sc->dc_btag = rman_get_bustag(sc->dc_res); @@ -1834,7 +1833,7 @@ static int dc_attach(dev) printf("dc%d: couldn't map interrupt\n", unit); bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res); error = ENXIO; - goto fail; + goto fail_nolock; } error = bus_setup_intr(dev, sc->dc_irq, INTR_TYPE_NET | @@ -1845,8 +1844,9 @@ static int dc_attach(dev) bus_release_resource(dev, SYS_RES_IRQ, 0, sc->dc_irq); bus_release_resource(dev, DC_RES, DC_RID, sc->dc_res); printf("dc%d: couldn't set up irq\n", unit); - goto fail; + goto fail_nolock; } + DC_LOCK(sc); /* Need this info to decide on a chip type. */ sc->dc_info = dc_devtype(dev); @@ -2167,6 +2167,7 @@ static int dc_attach(dev) fail: DC_UNLOCK(sc); +fail_nolock: mtx_destroy(&sc->dc_mtx); return(error); } -- cgit v1.1