[patch] lor with an(4) pcmcia card on detach

From: Maksim Yevmenkin <maksim.yevmenkin_at_savvis.net>
Date: Fri, 24 Jun 2005 17:11:39 -0700
Dear Hackers,

the following lor was observed on -current when i detach my an(4) pcmcia 
adapter

Jun 24 16:20:10 beetle kernel: taskqueue_drain with the following 
non-sleepable locks held:
Jun 24 16:20:10 beetle kernel: exclusive sleep mutex an0 (network 
driver) r = 0 (0xc59af168) locked _at_ /usr/src/sys/dev/an/if_an.c:2836
Jun 24 16:20:10 beetle kernel: KDB: stack backtrace:
Jun 24 16:20:10 beetle kernel: 
kdb_backtrace(1,c2412a50,c59ae000,c23d0300,e5083c34) at kdb_backtrace+0x29
Jun 24 16:20:10 beetle kernel: 
witness_warn(5,0,c0852219,c2412800,c59ae000) at witness_warn+0x18e
Jun 24 16:20:10 beetle kernel: 
taskqueue_drain(c23d0300,c2412a50,c2412800,c59ae000,c2412800) at 
taskqueue_drain+0x1a
Jun 24 16:20:10 beetle kernel: if_detach(c2412800,c2412800) at 
if_detach+0x1a
Jun 24 16:20:10 beetle kernel: 
ether_ifdetach(c2412800,c59af190,c59ae000,c59af168,0) at ether_ifdetach+0x28
Jun 24 16:20:10 beetle kernel: an_detach(c2a73d00) at an_detach+0x68
Jun 24 16:20:10 beetle kernel: device_detach(c2a73d00) at device_detach+0x70
Jun 24 16:20:10 beetle kernel: pccard_detach_card(c23f8d80) at 
pccard_detach_card+0x41
Jun 24 16:20:10 beetle kernel: exca_removal(c23c6804) at exca_removal+0x46
Jun 24 16:20:10 beetle kernel: cbb_removal(c23c6800) at cbb_removal+0x2c
Jun 24 16:20:10 beetle kernel: 
cbb_event_thread(c23c6800,e5083d38,c23c6800,c0575a00,0) at 
cbb_event_thread+0x9a
Jun 24 16:20:10 beetle kernel: fork_exit(c0575a00,c23c6800,e5083d38) at 
fork_exit+0xa0
Jun 24 16:20:10 beetle kernel: fork_trampoline() at fork_trampoline+0x8
Jun 24 16:20:10 beetle kernel: --- trap 0x1, eip = 0, esp = 0xe5083d6c, 
ebp = 0 ---
Jun 24 16:20:10 beetle kernel: an0: detached

the following is one possible patch

--- if_an.c.orig        Fri Jun 24 16:29:33 2005
+++ if_an.c     Fri Jun 24 16:33:38 2005
_at__at_ -826,18 +826,19 _at__at_
         struct an_softc         *sc = device_get_softc(dev);
         struct ifnet            *ifp = sc->an_ifp;

+       AN_LOCK(sc);
         if (sc->an_gone) {
+               AN_UNLOCK(sc);
                 device_printf(dev,"already unloaded\n");
                 return(0);
         }
-       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);

thanks,
max
Received on Fri Jun 24 2005 - 22:11:56 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:37 UTC