ath9k: always call ath_reset from workqueue context
[pandora-kernel.git] / drivers / net / wireless / ath / ath9k / main.c
index 5ac4f3f..9a6db29 100644 (file)
@@ -236,6 +236,7 @@ static int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
        del_timer_sync(&common->ani.timer);
        cancel_work_sync(&sc->paprd_work);
        cancel_work_sync(&sc->hw_check_work);
+       cancel_work_sync(&sc->hw_reset_work);
        cancel_delayed_work_sync(&sc->tx_complete_work);
        cancel_delayed_work_sync(&sc->hw_pll_work);
 
@@ -318,7 +319,6 @@ static void ath_paprd_activate(struct ath_softc *sc)
 {
        struct ath_hw *ah = sc->sc_ah;
        struct ath9k_hw_cal_data *caldata = ah->caldata;
-       struct ath_common *common = ath9k_hw_common(ah);
        int chain;
 
        if (!caldata || !caldata->paprd_done)
@@ -327,7 +327,7 @@ static void ath_paprd_activate(struct ath_softc *sc)
        ath9k_ps_wakeup(sc);
        ar9003_paprd_enable(ah, false);
        for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
-               if (!(common->tx_chainmask & BIT(chain)))
+               if (!(ah->txchainmask & BIT(chain)))
                        continue;
 
                ar9003_paprd_populate_single_table(ah, caldata, chain);
@@ -414,7 +414,7 @@ void ath_paprd_calibrate(struct work_struct *work)
        memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
 
        for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
-               if (!(common->tx_chainmask & BIT(chain)))
+               if (!(ah->txchainmask & BIT(chain)))
                        continue;
 
                chain_ok = 0;
@@ -535,7 +535,7 @@ void ath_ani_calibrate(unsigned long data)
        if (longcal || shortcal) {
                common->ani.caldone =
                        ath9k_hw_calibrate(ah, ah->curchan,
-                                               common->rx_chainmask, longcal);
+                                               ah->rxchainmask, longcal);
        }
 
        ath9k_ps_restore(sc);
@@ -546,6 +546,7 @@ set_timer:
        * The interval must be the shortest necessary to satisfy ANI,
        * short calibration and long calibration.
        */
+       ath9k_debug_samp_bb_mac(sc);
        cal_interval = ATH_LONG_CALINTERVAL;
        if (sc->sc_ah->config.enable_ani)
                cal_interval = min(cal_interval,
@@ -596,74 +597,6 @@ static void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
                ath_tx_node_cleanup(sc, an);
 }
 
-void ath_hw_check(struct work_struct *work)
-{
-       struct ath_softc *sc = container_of(work, struct ath_softc, hw_check_work);
-       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-       unsigned long flags;
-       int busy;
-
-       ath9k_ps_wakeup(sc);
-       if (ath9k_hw_check_alive(sc->sc_ah))
-               goto out;
-
-       spin_lock_irqsave(&common->cc_lock, flags);
-       busy = ath_update_survey_stats(sc);
-       spin_unlock_irqrestore(&common->cc_lock, flags);
-
-       ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
-               "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
-       if (busy >= 99) {
-               if (++sc->hw_busy_count >= 3) {
-                       spin_lock_bh(&sc->sc_pcu_lock);
-                       ath_reset(sc, true);
-                       spin_unlock_bh(&sc->sc_pcu_lock);
-               }
-       } else if (busy >= 0)
-               sc->hw_busy_count = 0;
-
-out:
-       ath9k_ps_restore(sc);
-}
-
-static void ath_hw_pll_rx_hang_check(struct ath_softc *sc, u32 pll_sqsum)
-{
-       static int count;
-       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
-
-       if (pll_sqsum >= 0x40000) {
-               count++;
-               if (count == 3) {
-                       /* Rx is hung for more than 500ms. Reset it */
-                       ath_dbg(common, ATH_DBG_RESET,
-                               "Possible RX hang, resetting");
-                       spin_lock_bh(&sc->sc_pcu_lock);
-                       ath_reset(sc, true);
-                       spin_unlock_bh(&sc->sc_pcu_lock);
-                       count = 0;
-               }
-       } else
-               count = 0;
-}
-
-void ath_hw_pll_work(struct work_struct *work)
-{
-       struct ath_softc *sc = container_of(work, struct ath_softc,
-                                           hw_pll_work.work);
-       u32 pll_sqsum;
-
-       if (AR_SREV_9485(sc->sc_ah)) {
-
-               ath9k_ps_wakeup(sc);
-               pll_sqsum = ar9003_get_pll_sqsum_dvc(sc->sc_ah);
-               ath9k_ps_restore(sc);
-
-               ath_hw_pll_rx_hang_check(sc, pll_sqsum);
-
-               ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, HZ/5);
-       }
-}
-
 
 void ath9k_tasklet(unsigned long data)
 {
@@ -676,9 +609,7 @@ void ath9k_tasklet(unsigned long data)
 
        if ((status & ATH9K_INT_FATAL) ||
            (status & ATH9K_INT_BB_WATCHDOG)) {
-               spin_lock(&sc->sc_pcu_lock);
-               ath_reset(sc, true);
-               spin_unlock(&sc->sc_pcu_lock);
+               ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
                return;
        }
 
@@ -969,7 +900,7 @@ void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
        ath9k_ps_restore(sc);
 }
 
-int ath_reset(struct ath_softc *sc, bool retry_tx)
+static int ath_reset(struct ath_softc *sc, bool retry_tx)
 {
        struct ath_hw *ah = sc->sc_ah;
        struct ath_common *common = ath9k_hw_common(ah);
@@ -978,6 +909,7 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
 
        sc->hw_busy_count = 0;
 
+       ath9k_debug_samp_bb_mac(sc);
        /* Stop ANI */
 
        del_timer_sync(&common->ani.timer);
@@ -1036,6 +968,84 @@ int ath_reset(struct ath_softc *sc, bool retry_tx)
        return r;
 }
 
+void ath_reset_work(struct work_struct *work)
+{
+       struct ath_softc *sc = container_of(work, struct ath_softc, hw_reset_work);
+
+       spin_lock_bh(&sc->sc_pcu_lock);
+       ath_reset(sc, true);
+       spin_unlock_bh(&sc->sc_pcu_lock);
+}
+
+void ath_hw_check(struct work_struct *work)
+{
+       struct ath_softc *sc = container_of(work, struct ath_softc, hw_check_work);
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+       unsigned long flags;
+       int busy;
+
+       ath9k_ps_wakeup(sc);
+       if (ath9k_hw_check_alive(sc->sc_ah))
+               goto out;
+
+       spin_lock_irqsave(&common->cc_lock, flags);
+       busy = ath_update_survey_stats(sc);
+       spin_unlock_irqrestore(&common->cc_lock, flags);
+
+       ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
+               "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
+       if (busy >= 99) {
+               if (++sc->hw_busy_count >= 3) {
+                       spin_lock_bh(&sc->sc_pcu_lock);
+                       ath_reset(sc, true);
+                       spin_unlock_bh(&sc->sc_pcu_lock);
+               }
+
+       } else if (busy >= 0)
+               sc->hw_busy_count = 0;
+
+out:
+       ath9k_ps_restore(sc);
+}
+
+static void ath_hw_pll_rx_hang_check(struct ath_softc *sc, u32 pll_sqsum)
+{
+       static int count;
+       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+
+       if (pll_sqsum >= 0x40000) {
+               count++;
+               if (count == 3) {
+                       /* Rx is hung for more than 500ms. Reset it */
+                       ath_dbg(common, ATH_DBG_RESET,
+                               "Possible RX hang, resetting");
+                       spin_lock_bh(&sc->sc_pcu_lock);
+                       ath_reset(sc, true);
+                       spin_unlock_bh(&sc->sc_pcu_lock);
+                       count = 0;
+               }
+       } else
+               count = 0;
+}
+
+void ath_hw_pll_work(struct work_struct *work)
+{
+       struct ath_softc *sc = container_of(work, struct ath_softc,
+                                           hw_pll_work.work);
+       u32 pll_sqsum;
+
+       if (AR_SREV_9485(sc->sc_ah)) {
+
+               ath9k_ps_wakeup(sc);
+               pll_sqsum = ar9003_get_pll_sqsum_dvc(sc->sc_ah);
+               ath9k_ps_restore(sc);
+
+               ath_hw_pll_rx_hang_check(sc, pll_sqsum);
+
+               ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, HZ/5);
+       }
+}
+
 /**********************/
 /* mac80211 callbacks */
 /**********************/
@@ -1228,6 +1238,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
        cancel_delayed_work_sync(&sc->hw_pll_work);
        cancel_work_sync(&sc->paprd_work);
        cancel_work_sync(&sc->hw_check_work);
+       cancel_work_sync(&sc->hw_reset_work);
 
        if (sc->sc_flags & SC_OP_INVALID) {
                ath_dbg(common, ATH_DBG_ANY, "Device not present\n");