From owner-p4-projects@FreeBSD.ORG Thu Apr 3 20:59:21 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 079811065670; Thu, 3 Apr 2008 20:59:21 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD301106566B for ; Thu, 3 Apr 2008 20:59:20 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A82EB8FC27 for ; Thu, 3 Apr 2008 20:59:20 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m33KxKfW027032 for ; Thu, 3 Apr 2008 20:59:20 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m33KxKr8027030 for perforce@freebsd.org; Thu, 3 Apr 2008 20:59:20 GMT (envelope-from sam@freebsd.org) Date: Thu, 3 Apr 2008 20:59:20 GMT Message-Id: <200804032059.m33KxKr8027030@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 139290 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Apr 2008 20:59:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=139290 Change 139290 by sam@sam_ebb on 2008/04/03 20:58:31 Bite the bullet and hold the com lock across driver callbacks to close various races and make state machine locking more sane: o hold the com lock across the ioctl call to mark the parent device up/down; this mostly causes problems for devices that load firmware in their init routine as the filesystem calls used by firwmare(9) malloc memory with M_WAITOK and we have no way, short of dropping the lock inside the driver, to cope (this is really an issue that needs to be resolved in firmware et al) o hold the com lock while locking the vap list to stop all vap's; this is a noop as this routine is currently unused but closes another case of unlocked vap list traversal While here add an assert to ieee80211_new_state_locked. Affected files ... .. //depot/projects/vap/sys/net80211/ieee80211_proto.c#27 edit Differences ... ==== //depot/projects/vap/sys/net80211/ieee80211_proto.c#27 (text+ko) ==== @@ -1088,10 +1088,7 @@ IEEE80211_MSG_STATE | IEEE80211_MSG_DEBUG, "%s: up parent %s\n", __func__, parent->if_xname); parent->if_flags |= IFF_UP; - /* XXX drop lock */ - IEEE80211_UNLOCK(ic); parent->if_ioctl(parent, SIOCSIFFLAGS, NULL); - IEEE80211_LOCK(ic); } /* * Mark us running. Note that we do this after @@ -1242,14 +1239,15 @@ struct ifnet *parent = ic->ic_ifp; struct ieee80211vap *vap; + IEEE80211_LOCK(ic); /* XXX shouldn't touch driver state */ parent->if_drv_flags &= ~IFF_DRV_RUNNING; - /* XXX locking */ TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { struct ifnet *ifp = vap->iv_ifp; if (IFNET_IS_UP_RUNNING(ifp)) /* NB: avoid recursion */ - ieee80211_stop(vap); + ieee80211_stop_locked(vap); } + IEEE80211_UNLOCK(ic); } /* @@ -1540,6 +1538,8 @@ enum ieee80211_state ostate; int nrunning, nscanning, rc; + IEEE80211_LOCK_ASSERT(ic); + nrunning = nscanning = 0; /* XXX can track this state instead of calculating */ TAILQ_FOREACH(vp, &ic->ic_vaps, iv_next) {