From b8ee5a7a1ceb1dde18c869c9ccff72032457ff6c Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Mon, 14 Jan 2013 15:58:46 +0000
Subject: [PATCH] ath9k: fix a soft lockup on smp systems

SVN-Revision: 35152
---
 .../mac80211/patches/300-pending_work.patch   | 34 +++++++++++--------
 .../patches/512-ath9k_channelbw_debugfs.patch |  6 ++--
 .../patches/521-ath9k_cur_txpower.patch       |  4 +--
 ...24-ath9k_use_configured_antenna_gain.patch |  2 +-
 .../patches/553-ath9k_debugfs_diag.patch      |  2 +-
 5 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/package/mac80211/patches/300-pending_work.patch b/package/mac80211/patches/300-pending_work.patch
index f7b25402724..06041b36f9d 100644
--- a/package/mac80211/patches/300-pending_work.patch
+++ b/package/mac80211/patches/300-pending_work.patch
@@ -318,15 +318,7 @@
  {
  	struct ath_hw *ah = sc->sc_ah;
  	bool ret = true;
-@@ -196,19 +196,15 @@ static bool ath_prepare_reset(struct ath
- 	ath9k_debug_samp_bb_mac(sc);
- 	ath9k_hw_disable_interrupts(ah);
- 
-+	tasklet_disable(&sc->intr_tq);
-+
- 	if (!ath_stoprecv(sc))
- 		ret = false;
- 
+@@ -202,14 +202,6 @@ static bool ath_prepare_reset(struct ath
  	if (!ath_drain_all_txq(sc, retry_tx))
  		ret = false;
  
@@ -337,11 +329,11 @@
 -	} else {
 -		ath_flushrecv(sc);
 -	}
-+	tasklet_enable(&sc->intr_tq);
- 
+-
  	return ret;
  }
-@@ -262,7 +258,6 @@ static int ath_reset_internal(struct ath
+ 
+@@ -262,11 +254,11 @@ static int ath_reset_internal(struct ath
  	struct ath_common *common = ath9k_hw_common(ah);
  	struct ath9k_hw_cal_data *caldata = NULL;
  	bool fastcc = true;
@@ -349,7 +341,12 @@
  	int r;
  
  	__ath_cancel_work(sc);
-@@ -276,11 +271,10 @@ static int ath_reset_internal(struct ath
+ 
++	tasklet_disable(&sc->intr_tq);
+ 	spin_lock_bh(&sc->sc_pcu_lock);
+ 
+ 	if (!(sc->hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) {
+@@ -276,11 +268,10 @@ static int ath_reset_internal(struct ath
  
  	if (!hchan) {
  		fastcc = false;
@@ -362,7 +359,16 @@
  		fastcc = false;
  
  	ath_dbg(common, CONFIG, "Reset to %u MHz, HT40: %d fastcc: %d\n",
-@@ -804,7 +798,7 @@ static void ath9k_stop(struct ieee80211_
+@@ -302,6 +293,8 @@ static int ath_reset_internal(struct ath
+ 
+ out:
+ 	spin_unlock_bh(&sc->sc_pcu_lock);
++	tasklet_enable(&sc->intr_tq);
++
+ 	return r;
+ }
+ 
+@@ -804,7 +797,7 @@ static void ath9k_stop(struct ieee80211_
  		ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
  	}
  
diff --git a/package/mac80211/patches/512-ath9k_channelbw_debugfs.patch b/package/mac80211/patches/512-ath9k_channelbw_debugfs.patch
index 4d20502d131..8c459180af2 100644
--- a/package/mac80211/patches/512-ath9k_channelbw_debugfs.patch
+++ b/package/mac80211/patches/512-ath9k_channelbw_debugfs.patch
@@ -80,7 +80,7 @@
  	debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc,
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1069,7 +1069,7 @@ static void ath9k_disable_ps(struct ath_
+@@ -1068,7 +1068,7 @@ static void ath9k_disable_ps(struct ath_
  	ath_dbg(common, PS, "PowerSave disabled\n");
  }
  
@@ -89,7 +89,7 @@
  {
  	struct ath_softc *sc = hw->priv;
  	struct ath_hw *ah = sc->sc_ah;
-@@ -1123,9 +1123,11 @@ static int ath9k_config(struct ieee80211
+@@ -1122,9 +1122,11 @@ static int ath9k_config(struct ieee80211
  
  	if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
  		struct ieee80211_channel *curchan = hw->conf.channel;
@@ -101,7 +101,7 @@
  
  		if (ah->curchan)
  			old_pos = ah->curchan - &ah->channels[0];
-@@ -1168,7 +1170,23 @@ static int ath9k_config(struct ieee80211
+@@ -1167,7 +1169,23 @@ static int ath9k_config(struct ieee80211
  			memset(&sc->survey[pos], 0, sizeof(struct survey_info));
  		}
  
diff --git a/package/mac80211/patches/521-ath9k_cur_txpower.patch b/package/mac80211/patches/521-ath9k_cur_txpower.patch
index 294e3dd99d5..ad2d3d91842 100644
--- a/package/mac80211/patches/521-ath9k_cur_txpower.patch
+++ b/package/mac80211/patches/521-ath9k_cur_txpower.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1193,6 +1193,8 @@ int ath9k_config(struct ieee80211_hw *hw
+@@ -1192,6 +1192,8 @@ int ath9k_config(struct ieee80211_hw *hw
  			return -EINVAL;
  		}
  
@@ -9,7 +9,7 @@
  		/*
  		 * The most recent snapshot of channel->noisefloor for the old
  		 * channel is only available after the hardware reset. Copy it to
-@@ -1207,6 +1209,7 @@ int ath9k_config(struct ieee80211_hw *hw
+@@ -1206,6 +1208,7 @@ int ath9k_config(struct ieee80211_hw *hw
  		sc->config.txpowlimit = 2 * conf->power_level;
  		ath9k_cmn_update_txpow(ah, sc->curtxpow,
  				       sc->config.txpowlimit, &sc->curtxpow);
diff --git a/package/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch b/package/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch
index e32f66ea4de..0c3842577dc 100644
--- a/package/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch
+++ b/package/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch
@@ -21,7 +21,7 @@
  	if (ant_gain > max_gain)
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1205,7 +1205,10 @@ int ath9k_config(struct ieee80211_hw *hw
+@@ -1204,7 +1204,10 @@ int ath9k_config(struct ieee80211_hw *hw
  	}
  
  	if (changed & IEEE80211_CONF_CHANGE_POWER) {
diff --git a/package/mac80211/patches/553-ath9k_debugfs_diag.patch b/package/mac80211/patches/553-ath9k_debugfs_diag.patch
index 9ea2ec9ba21..078a7f878ba 100644
--- a/package/mac80211/patches/553-ath9k_debugfs_diag.patch
+++ b/package/mac80211/patches/553-ath9k_debugfs_diag.patch
@@ -125,7 +125,7 @@
  		REG_SET_BIT(ah, AR_BTCOEX_WL_LNADIV, AR_BTCOEX_WL_LNADIV_FORCE_ON);
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -464,6 +464,11 @@ irqreturn_t ath_isr(int irq, void *dev)
+@@ -463,6 +463,11 @@ irqreturn_t ath_isr(int irq, void *dev)
  	ath9k_hw_getisr(ah, &status);	/* NB: clears ISR too */
  	status &= ah->imask;	/* discard unasked-for bits */