From a7db0ceda4567732941b953b615bf09d2700f169 Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@openwrt.org>
Date: Thu, 12 Apr 2012 21:28:18 +0000
Subject: ath9k: fix sleep mode handling issues, should improve client mode
 reliability

SVN-Revision: 31265
---
 package/mac80211/patches/300-pending_work.patch    | 36 ++++++++++++++++++++--
 .../patches/513-ath9k_channelbw_debugfs.patch      |  6 ++--
 .../mac80211/patches/531-ath9k_cur_txpower.patch   |  4 +--
 .../mac80211/patches/551-ath9k_extra_leds.patch    |  2 +-
 .../patches/552-ath9k_extra_platform_leds.patch    |  2 +-
 5 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/package/mac80211/patches/300-pending_work.patch b/package/mac80211/patches/300-pending_work.patch
index 30ce96e170..64067f2d48 100644
--- a/package/mac80211/patches/300-pending_work.patch
+++ b/package/mac80211/patches/300-pending_work.patch
@@ -1614,7 +1614,37 @@
  		mode = ATH9K_PM_NETWORK_SLEEP;
  	else
  		goto unlock;
-@@ -1955,6 +1957,7 @@ static void ath9k_config_bss(struct ath_
+@@ -1559,6 +1561,7 @@ static int ath9k_config(struct ieee80211
+ 	struct ath_hw *ah = sc->sc_ah;
+ 	struct ath_common *common = ath9k_hw_common(ah);
+ 	struct ieee80211_conf *conf = &hw->conf;
++	bool reset_channel = false;
+ 
+ 	ath9k_ps_wakeup(sc);
+ 	mutex_lock(&sc->mutex);
+@@ -1567,6 +1570,12 @@ static int ath9k_config(struct ieee80211
+ 		sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE);
+ 		if (sc->ps_idle)
+ 			ath_cancel_work(sc);
++		else
++			/*
++			 * The chip needs a reset to properly wake up from
++			 * full sleep
++			 */
++			reset_channel = ah->chip_fullsleep;
+ 	}
+ 
+ 	/*
+@@ -1595,7 +1604,7 @@ static int ath9k_config(struct ieee80211
+ 		}
+ 	}
+ 
+-	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
++	if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
+ 		struct ieee80211_channel *curchan = hw->conf.channel;
+ 		int pos = curchan->hw_value;
+ 		int old_pos = -1;
+@@ -1955,6 +1964,7 @@ static void ath9k_config_bss(struct ath_
  		sc->sc_flags &= ~SC_OP_ANI_RUN;
  		del_timer_sync(&common->ani.timer);
  		memset(&sc->caldata, 0, sizeof(sc->caldata));
@@ -1622,7 +1652,7 @@
  	}
  }
  
-@@ -2300,6 +2303,7 @@ static int ath9k_tx_last_beacon(struct i
+@@ -2300,6 +2310,7 @@ static int ath9k_tx_last_beacon(struct i
  	struct ath_vif *avp;
  	struct ath_buf *bf;
  	struct ath_tx_status ts;
@@ -1630,7 +1660,7 @@
  	int status;
  
  	vif = sc->beacon.bslot[0];
-@@ -2310,7 +2314,7 @@ static int ath9k_tx_last_beacon(struct i
+@@ -2310,7 +2321,7 @@ static int ath9k_tx_last_beacon(struct i
  	if (!avp->is_bslot_active)
  		return 0;
  
diff --git a/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch b/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch
index 713a44339f..70919f09fe 100644
--- a/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch
+++ b/package/mac80211/patches/513-ath9k_channelbw_debugfs.patch
@@ -89,9 +89,9 @@
  {
  	struct ath_softc *sc = hw->priv;
  	struct ath_hw *ah = sc->sc_ah;
-@@ -1581,9 +1581,11 @@ static int ath9k_config(struct ieee80211
+@@ -1588,9 +1588,11 @@ static int ath9k_config(struct ieee80211
  
- 	if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
+ 	if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || reset_channel) {
  		struct ieee80211_channel *curchan = hw->conf.channel;
 +		struct ath9k_channel *hchan;
  		int pos = curchan->hw_value;
@@ -101,7 +101,7 @@
  
  		if (ah->curchan)
  			old_pos = ah->curchan - &ah->channels[0];
-@@ -1631,7 +1633,23 @@ static int ath9k_config(struct ieee80211
+@@ -1638,7 +1640,23 @@ static int ath9k_config(struct ieee80211
  			memset(&sc->survey[pos], 0, sizeof(struct survey_info));
  		}
  
diff --git a/package/mac80211/patches/531-ath9k_cur_txpower.patch b/package/mac80211/patches/531-ath9k_cur_txpower.patch
index af246a788c..809a833085 100644
--- a/package/mac80211/patches/531-ath9k_cur_txpower.patch
+++ b/package/mac80211/patches/531-ath9k_cur_txpower.patch
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/main.c
 +++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -1655,6 +1655,8 @@ int ath9k_config(struct ieee80211_hw *hw
+@@ -1662,6 +1662,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
-@@ -1669,6 +1671,7 @@ int ath9k_config(struct ieee80211_hw *hw
+@@ -1676,6 +1678,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/551-ath9k_extra_leds.patch b/package/mac80211/patches/551-ath9k_extra_leds.patch
index 06237d7e36..e15de8ed67 100644
--- a/package/mac80211/patches/551-ath9k_extra_leds.patch
+++ b/package/mac80211/patches/551-ath9k_extra_leds.patch
@@ -171,7 +171,7 @@
  
 --- a/drivers/net/wireless/ath/ath9k/init.c
 +++ b/drivers/net/wireless/ath/ath9k/init.c
-@@ -759,7 +759,7 @@ int ath9k_init_device(u16 devid, struct 
+@@ -761,7 +761,7 @@ int ath9k_init_device(u16 devid, struct 
  
  #ifdef CONFIG_MAC80211_LEDS
  	/* must be initialized before ieee80211_register_hw */
diff --git a/package/mac80211/patches/552-ath9k_extra_platform_leds.patch b/package/mac80211/patches/552-ath9k_extra_platform_leds.patch
index 3834d43881..ac8ee533d9 100644
--- a/package/mac80211/patches/552-ath9k_extra_platform_leds.patch
+++ b/package/mac80211/patches/552-ath9k_extra_platform_leds.patch
@@ -1,6 +1,6 @@
 --- a/include/linux/ath9k_platform.h
 +++ b/include/linux/ath9k_platform.h
-@@ -32,6 +32,9 @@ struct ath9k_platform_data {
+@@ -33,6 +33,9 @@ struct ath9k_platform_data {
  	bool is_clk_25mhz;
  	int (*get_mac_revision)(void);
  	int (*external_reset)(void);
-- 
cgit v1.2.3