From owner-svn-src-head@FreeBSD.ORG Sun Mar 15 20:53:47 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5AA033AE; Sun, 15 Mar 2015 20:53:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4637E2FF; Sun, 15 Mar 2015 20:53:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2FKrlph074416; Sun, 15 Mar 2015 20:53:47 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2FKrktY074414; Sun, 15 Mar 2015 20:53:46 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201503152053.t2FKrktY074414@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 15 Mar 2015 20:53:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280086 - head/sys/dev/wpi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2015 20:53:47 -0000 Author: adrian Date: Sun Mar 15 20:53:46 2015 New Revision: 280086 URL: https://svnweb.freebsd.org/changeset/base/280086 Log: Use separate mutex for wv_bcbuf and wv_boff structures. PR: kern/197143 Submitted by: Andriy Voskoboinyk Modified: head/sys/dev/wpi/if_wpi.c head/sys/dev/wpi/if_wpivar.h Modified: head/sys/dev/wpi/if_wpi.c ============================================================================== --- head/sys/dev/wpi/if_wpi.c Sun Mar 15 20:52:47 2015 (r280085) +++ head/sys/dev/wpi/if_wpi.c Sun Mar 15 20:53:46 2015 (r280086) @@ -617,8 +617,10 @@ wpi_vap_create(struct ieee80211com *ic, vap = &wvp->wv_vap; ieee80211_vap_setup(ic, vap, name, unit, opmode, flags, bssid, mac); - if (opmode == IEEE80211_M_IBSS) + if (opmode == IEEE80211_M_IBSS) { + WPI_VAP_LOCK_INIT(wvp); wpi_init_beacon(wvp); + } /* Override with driver methods. */ vap->iv_key_alloc = wpi_key_alloc; @@ -649,6 +651,8 @@ wpi_vap_delete(struct ieee80211vap *vap) if (opmode == IEEE80211_M_IBSS) { if (bcn->m != NULL) m_freem(bcn->m); + + WPI_VAP_LOCK_DESTROY(wvp); } free(wvp, M_80211_VAP); @@ -2340,8 +2344,6 @@ wpi_cmd2(struct wpi_softc *sc, struct wp bus_dma_segment_t *seg, segs[WPI_MAX_SCATTER]; int error, i, hdrlen, nsegs, totlen, pad; - WPI_LOCK_ASSERT(sc); - WPI_TXQ_LOCK(sc); KASSERT(buf->size <= sizeof(buf->data), ("buffer overflow")); @@ -3967,7 +3969,7 @@ wpi_config_beacon(struct wpi_vap *wvp) DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_DOING, __func__); - WPI_LOCK_ASSERT(sc); + WPI_VAP_LOCK_ASSERT(wvp); cmd->len = htole16(bcn->m->m_pkthdr.len); cmd->plcp = (ic->ic_curmode == IEEE80211_MODE_11A) ? @@ -4025,12 +4027,14 @@ wpi_setup_beacon(struct wpi_softc *sc, s return ENOMEM; } + WPI_VAP_LOCK(wvp); if (bcn->m != NULL) m_freem(bcn->m); bcn->m = m; error = wpi_config_beacon(wvp); + WPI_VAP_UNLOCK(wvp); return error; } @@ -4047,21 +4051,21 @@ wpi_update_beacon(struct ieee80211vap *v DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__); - WPI_LOCK(sc); + WPI_VAP_LOCK(wvp); if (bcn->m == NULL) { bcn->m = ieee80211_beacon_alloc(ni, bo); if (bcn->m == NULL) { device_printf(sc->sc_dev, "%s: could not allocate beacon frame\n", __func__); - WPI_UNLOCK(sc); DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END_ERR, __func__); + WPI_VAP_UNLOCK(wvp); return; } } - WPI_UNLOCK(sc); + WPI_VAP_UNLOCK(wvp); if (item == IEEE80211_BEACON_TIM) mcast = 1; /* TODO */ @@ -4069,9 +4073,9 @@ wpi_update_beacon(struct ieee80211vap *v setbit(bo->bo_flags, item); ieee80211_beacon_update(ni, bo, bcn->m, mcast); - WPI_LOCK(sc); + WPI_VAP_LOCK(wvp); wpi_config_beacon(wvp); - WPI_UNLOCK(sc); + WPI_VAP_UNLOCK(wvp); DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); } Modified: head/sys/dev/wpi/if_wpivar.h ============================================================================== --- head/sys/dev/wpi/if_wpivar.h Sun Mar 15 20:52:47 2015 (r280085) +++ head/sys/dev/wpi/if_wpivar.h Sun Mar 15 20:53:46 2015 (r280086) @@ -125,12 +125,21 @@ struct wpi_vap { struct wpi_buf wv_bcbuf; struct ieee80211_beacon_offsets wv_boff; + struct mtx wv_mtx; int (*wv_newstate)(struct ieee80211vap *, enum ieee80211_state, int); }; #define WPI_VAP(vap) ((struct wpi_vap *)(vap)) +#define WPI_VAP_LOCK_INIT(_wvp) \ + mtx_init(&(_wvp)->wv_mtx, "lock for wv_bcbuf/wv_boff structures", \ + NULL, MTX_DEF) +#define WPI_VAP_LOCK(_wvp) mtx_lock(&(_wvp)->wv_mtx) +#define WPI_VAP_UNLOCK(_wvp) mtx_unlock(&(_wvp)->wv_mtx) +#define WPI_VAP_LOCK_ASSERT(_wvp) mtx_assert(&(_wvp)->wv_mtx, MA_OWNED) +#define WPI_VAP_LOCK_DESTROY(_wvp) mtx_destroy(&(_wvp)->wv_mtx) + struct wpi_fw_part { const uint8_t *text; uint32_t textsz; @@ -224,7 +233,7 @@ struct wpi_softc { char domain[4]; /* Regulatory domain. */ }; -/* WPI_LOCK > WPI_NT_LOCK > WPI_TXQ_LOCK */ +/* WPI_LOCK > WPI_NT_LOCK / WPI_VAP_LOCK > WPI_TXQ_LOCK */ #define WPI_LOCK_INIT(_sc) \ mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \