Commit 141b38b6 authored by Sujith's avatar Sujith Committed by John W. Linville

ath9k: Lock mac80211 callbacks with a mutex

Signed-off-by: default avatarSujith <Sujith.Manoharan@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 367681f4
...@@ -1938,6 +1938,8 @@ static int ath9k_start(struct ieee80211_hw *hw) ...@@ -1938,6 +1938,8 @@ static int ath9k_start(struct ieee80211_hw *hw)
DPRINTF(sc, ATH_DBG_CONFIG, "Starting driver with " DPRINTF(sc, ATH_DBG_CONFIG, "Starting driver with "
"initial channel: %d MHz\n", curchan->center_freq); "initial channel: %d MHz\n", curchan->center_freq);
mutex_lock(&sc->mutex);
/* setup initial channel */ /* setup initial channel */
pos = curchan->hw_value; pos = curchan->hw_value;
...@@ -1963,7 +1965,7 @@ static int ath9k_start(struct ieee80211_hw *hw) ...@@ -1963,7 +1965,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
"(freq %u MHz)\n", r, "(freq %u MHz)\n", r,
curchan->center_freq); curchan->center_freq);
spin_unlock_bh(&sc->sc_resetlock); spin_unlock_bh(&sc->sc_resetlock);
return r; goto mutex_unlock;
} }
spin_unlock_bh(&sc->sc_resetlock); spin_unlock_bh(&sc->sc_resetlock);
...@@ -1983,7 +1985,8 @@ static int ath9k_start(struct ieee80211_hw *hw) ...@@ -1983,7 +1985,8 @@ static int ath9k_start(struct ieee80211_hw *hw)
if (ath_startrecv(sc) != 0) { if (ath_startrecv(sc) != 0) {
DPRINTF(sc, ATH_DBG_FATAL, DPRINTF(sc, ATH_DBG_FATAL,
"Unable to start recv logic\n"); "Unable to start recv logic\n");
return -EIO; r = -EIO;
goto mutex_unlock;
} }
/* Setup our intr mask. */ /* Setup our intr mask. */
...@@ -2010,6 +2013,10 @@ static int ath9k_start(struct ieee80211_hw *hw) ...@@ -2010,6 +2013,10 @@ static int ath9k_start(struct ieee80211_hw *hw)
#if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
r = ath_start_rfkill_poll(sc); r = ath_start_rfkill_poll(sc);
#endif #endif
mutex_unlock:
mutex_unlock(&sc->mutex);
return r; return r;
} }
...@@ -2074,7 +2081,7 @@ static void ath9k_stop(struct ieee80211_hw *hw) ...@@ -2074,7 +2081,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
return; return;
} }
DPRINTF(sc, ATH_DBG_CONFIG, "Cleaning up\n"); mutex_lock(&sc->mutex);
ieee80211_stop_queues(sc->hw); ieee80211_stop_queues(sc->hw);
...@@ -2099,6 +2106,8 @@ static void ath9k_stop(struct ieee80211_hw *hw) ...@@ -2099,6 +2106,8 @@ static void ath9k_stop(struct ieee80211_hw *hw)
sc->sc_flags |= SC_OP_INVALID; sc->sc_flags |= SC_OP_INVALID;
mutex_unlock(&sc->mutex);
DPRINTF(sc, ATH_DBG_CONFIG, "Driver halt\n"); DPRINTF(sc, ATH_DBG_CONFIG, "Driver halt\n");
} }
...@@ -2114,6 +2123,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw, ...@@ -2114,6 +2123,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
if (sc->sc_nvaps) if (sc->sc_nvaps)
return -ENOBUFS; return -ENOBUFS;
mutex_lock(&sc->mutex);
switch (conf->type) { switch (conf->type) {
case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_STATION:
ic_opmode = NL80211_IFTYPE_STATION; ic_opmode = NL80211_IFTYPE_STATION;
...@@ -2173,6 +2184,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw, ...@@ -2173,6 +2184,8 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL)); jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL));
} }
mutex_unlock(&sc->mutex);
return 0; return 0;
} }
...@@ -2184,6 +2197,8 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw, ...@@ -2184,6 +2197,8 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
DPRINTF(sc, ATH_DBG_CONFIG, "Detach Interface\n"); DPRINTF(sc, ATH_DBG_CONFIG, "Detach Interface\n");
mutex_lock(&sc->mutex);
/* Stop ANI */ /* Stop ANI */
del_timer_sync(&sc->sc_ani.timer); del_timer_sync(&sc->sc_ani.timer);
...@@ -2198,6 +2213,8 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw, ...@@ -2198,6 +2213,8 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
sc->sc_vaps[0] = NULL; sc->sc_vaps[0] = NULL;
sc->sc_nvaps--; sc->sc_nvaps--;
mutex_unlock(&sc->mutex);
} }
static int ath9k_config(struct ieee80211_hw *hw, u32 changed) static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
...@@ -2206,6 +2223,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ...@@ -2206,6 +2223,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
struct ieee80211_conf *conf = &hw->conf; struct ieee80211_conf *conf = &hw->conf;
mutex_lock(&sc->mutex); mutex_lock(&sc->mutex);
if (changed & IEEE80211_CONF_CHANGE_PS) { if (changed & IEEE80211_CONF_CHANGE_PS) {
if (conf->flags & IEEE80211_CONF_PS) { if (conf->flags & IEEE80211_CONF_PS) {
if ((sc->sc_imask & ATH9K_INT_TIM_TIMER) == 0) { if ((sc->sc_imask & ATH9K_INT_TIM_TIMER) == 0) {
...@@ -2250,6 +2268,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ...@@ -2250,6 +2268,7 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
sc->sc_config.txpowlimit = 2 * conf->power_level; sc->sc_config.txpowlimit = 2 * conf->power_level;
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
return 0; return 0;
} }
...@@ -2392,8 +2411,7 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw, ...@@ -2392,8 +2411,7 @@ static void ath9k_sta_notify(struct ieee80211_hw *hw,
} }
} }
static int ath9k_conf_tx(struct ieee80211_hw *hw, static int ath9k_conf_tx(struct ieee80211_hw *hw, u16 queue,
u16 queue,
const struct ieee80211_tx_queue_params *params) const struct ieee80211_tx_queue_params *params)
{ {
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
...@@ -2403,6 +2421,8 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw, ...@@ -2403,6 +2421,8 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw,
if (queue >= WME_NUM_AC) if (queue >= WME_NUM_AC)
return 0; return 0;
mutex_lock(&sc->mutex);
qi.tqi_aifs = params->aifs; qi.tqi_aifs = params->aifs;
qi.tqi_cwmin = params->cw_min; qi.tqi_cwmin = params->cw_min;
qi.tqi_cwmax = params->cw_max; qi.tqi_cwmax = params->cw_max;
...@@ -2419,6 +2439,8 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw, ...@@ -2419,6 +2439,8 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw,
if (ret) if (ret)
DPRINTF(sc, ATH_DBG_FATAL, "TXQ Update failed\n"); DPRINTF(sc, ATH_DBG_FATAL, "TXQ Update failed\n");
mutex_unlock(&sc->mutex);
return ret; return ret;
} }
...@@ -2431,6 +2453,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw, ...@@ -2431,6 +2453,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
int ret = 0; int ret = 0;
mutex_lock(&sc->mutex);
ath9k_ps_wakeup(sc); ath9k_ps_wakeup(sc);
DPRINTF(sc, ATH_DBG_KEYCACHE, "Set HW Key\n"); DPRINTF(sc, ATH_DBG_KEYCACHE, "Set HW Key\n");
...@@ -2456,6 +2479,8 @@ static int ath9k_set_key(struct ieee80211_hw *hw, ...@@ -2456,6 +2479,8 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
} }
ath9k_ps_restore(sc); ath9k_ps_restore(sc);
mutex_unlock(&sc->mutex);
return ret; return ret;
} }
...@@ -2466,6 +2491,8 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw, ...@@ -2466,6 +2491,8 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
{ {
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
mutex_lock(&sc->mutex);
if (changed & BSS_CHANGED_ERP_PREAMBLE) { if (changed & BSS_CHANGED_ERP_PREAMBLE) {
DPRINTF(sc, ATH_DBG_CONFIG, "BSS Changed PREAMBLE %d\n", DPRINTF(sc, ATH_DBG_CONFIG, "BSS Changed PREAMBLE %d\n",
bss_conf->use_short_preamble); bss_conf->use_short_preamble);
...@@ -2490,15 +2517,18 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw, ...@@ -2490,15 +2517,18 @@ static void ath9k_bss_info_changed(struct ieee80211_hw *hw,
bss_conf->assoc); bss_conf->assoc);
ath9k_bss_assoc_info(sc, vif, bss_conf); ath9k_bss_assoc_info(sc, vif, bss_conf);
} }
mutex_unlock(&sc->mutex);
} }
static u64 ath9k_get_tsf(struct ieee80211_hw *hw) static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
{ {
u64 tsf; u64 tsf;
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
struct ath_hal *ah = sc->sc_ah;
tsf = ath9k_hw_gettsf64(ah); mutex_lock(&sc->mutex);
tsf = ath9k_hw_gettsf64(sc->sc_ah);
mutex_unlock(&sc->mutex);
return tsf; return tsf;
} }
...@@ -2506,17 +2536,19 @@ static u64 ath9k_get_tsf(struct ieee80211_hw *hw) ...@@ -2506,17 +2536,19 @@ static u64 ath9k_get_tsf(struct ieee80211_hw *hw)
static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf) static void ath9k_set_tsf(struct ieee80211_hw *hw, u64 tsf)
{ {
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
struct ath_hal *ah = sc->sc_ah;
ath9k_hw_settsf64(ah, tsf); mutex_lock(&sc->mutex);
ath9k_hw_settsf64(sc->sc_ah, tsf);
mutex_unlock(&sc->mutex);
} }
static void ath9k_reset_tsf(struct ieee80211_hw *hw) static void ath9k_reset_tsf(struct ieee80211_hw *hw)
{ {
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
struct ath_hal *ah = sc->sc_ah;
ath9k_hw_reset_tsf(ah); mutex_lock(&sc->mutex);
ath9k_hw_reset_tsf(sc->sc_ah);
mutex_unlock(&sc->mutex);
} }
static int ath9k_ampdu_action(struct ieee80211_hw *hw, static int ath9k_ampdu_action(struct ieee80211_hw *hw,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment