MFC if_an.c v1.69 to RELENG_6

Reorganize an_detach() a bit. Make sure ether_ifdetach() and if_free()
are called outside of AN_LOCK()/AN_UNLOCK. This fixes the following
WITNESS warning (produced when an(4) PCMCIA card is detached).
taskqueue_drain with the following non-sleepable locks held:
exclusive sleep mutex an0 (network driver) r = 0 (0xc59af168) locked @ /usr/src/
sys/dev/an/if_an.c:2836

Do not lock an to check gone flag. Only need to hold the lock to set
the gone flag.

Reviewed by:	imp
Approved by:	re (kemsmith)
This commit is contained in:
emax 2005-08-04 21:12:22 +00:00
parent 5660f0803e
commit c7034773d9

View File

@ -832,12 +832,12 @@ an_detach(device_t dev)
}
AN_LOCK(sc);
an_stop(sc);
sc->an_gone = 1;
ifmedia_removeall(&sc->an_ifmedia);
ifp->if_flags &= ~IFF_RUNNING;
AN_UNLOCK(sc);
ether_ifdetach(ifp);
if_free(ifp);
sc->an_gone = 1;
AN_UNLOCK(sc);
bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
an_release_resources(dev);
mtx_destroy(&sc->an_mtx);