{ether,ieee80211}_ifdetach() can't be called with serializer being held, since
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 31 Dec 2005 14:08:01 +0000 (14:08 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 31 Dec 2005 14:08:01 +0000 (14:08 +0000)
commitcdf8943267dded98e264d518696299371b913d6d
treea97caab7ef4b6e12674dad8b0a7972815539f51b
parent34850bd53b422f3bda4bc1cf820ff13ca9e69096
{ether,ieee80211}_ifdetach() can't be called with serializer being held, since
they will go through code which tries to hold serializer again, e.g.
ether_ifdetach() -> if_detach() -> in_control()

So in various NICs' xxx_detach():
- Move bus_teardown_intr() under "(device_is_attached())", whenever it is
  applicable.  Since it is not possible that intrhandle is NULL here, nuke
  original "(intrhandle != NULL)".  This can:
    1) Avoid holding serializer, if xxx_attach() fails
    2) Release serializer ASAP
    3) Ease following tasks
- Hold serializer only for xxx_stop()(or similar functions which stops NIC) and
  bus_teardown_intr()
- Call {ether,ieee80211}_ifdetach() after serializer is released

Other stuffs:
- Serialize xxx_detach() for awi(4), ep(4), sn(4) and xe(4)
- Release serializer before returning from {ed_pccard,ray}_detach()
- Make ipw(4)'s ipw_detach() suitable for error handling, adjust ipw_attach()
  accordingly
- Fix a bug in ex_pccard_detach(): instead of if_detach(), ether_ifdetach()
  should be used here
- For ndis(4), "ifp->serializer" ==> "ifp->if_serializer"
Reported-by: esmith <esmith@postmark.net>
Discussed-with: dillon and joerg
Partially-Reviewed-by: dillon and joerg
Reported-by: Steve Mynott <steve.mynott@gmail.com> and me
48 files changed:
sys/dev/netif/an/if_an.c
sys/dev/netif/awi/if_awi_pccard.c
sys/dev/netif/bfe/if_bfe.c
sys/dev/netif/bge/if_bge.c
sys/dev/netif/cm/if_cm_isa.c
sys/dev/netif/cs/if_cs.c
sys/dev/netif/dc/if_dc.c
sys/dev/netif/ed/if_ed_isa.c
sys/dev/netif/ed/if_ed_pccard.c
sys/dev/netif/ed/if_ed_pci.c
sys/dev/netif/em/if_em.c
sys/dev/netif/ep/if_ep_pccard.c
sys/dev/netif/ex/if_ex_pccard.c
sys/dev/netif/fe/if_fe_pccard.c
sys/dev/netif/fwe/if_fwe.c
sys/dev/netif/fxp/if_fxp.c
sys/dev/netif/gx/if_gx.c
sys/dev/netif/ipw/if_ipw.c
sys/dev/netif/iwi/if_iwi.c
sys/dev/netif/lge/if_lge.c
sys/dev/netif/lnc/if_lnc_isa.c
sys/dev/netif/lnc/if_lnc_pci.c
sys/dev/netif/my/if_my.c
sys/dev/netif/ndis/if_ndis.c
sys/dev/netif/nge/if_nge.c
sys/dev/netif/nv/if_nv.c
sys/dev/netif/owi/if_owi.c
sys/dev/netif/pcn/if_pcn.c
sys/dev/netif/ray/if_ray.c
sys/dev/netif/re/if_re.c
sys/dev/netif/rl/if_rl.c
sys/dev/netif/sbsh/if_sbsh.c
sys/dev/netif/sf/if_sf.c
sys/dev/netif/sis/if_sis.c
sys/dev/netif/sk/if_sk.c
sys/dev/netif/sn/if_sn.c
sys/dev/netif/sn/if_sn_pccard.c
sys/dev/netif/ste/if_ste.c
sys/dev/netif/ti/if_ti.c
sys/dev/netif/tl/if_tl.c
sys/dev/netif/tx/if_tx.c
sys/dev/netif/txp/if_txp.c
sys/dev/netif/vr/if_vr.c
sys/dev/netif/wb/if_wb.c
sys/dev/netif/wi/if_wi.c
sys/dev/netif/wl/if_wl.c
sys/dev/netif/xe/if_xe.c
sys/dev/netif/xl/if_xl.c