diff options
-rw-r--r-- | package/mac80211/Makefile | 4 | ||||
-rw-r--r-- | package/mac80211/patches/130-printk_debug_revert.patch | 69 | ||||
-rw-r--r-- | package/mac80211/patches/520-mac80211_offchannel_conf.patch | 35 | ||||
-rw-r--r-- | package/mac80211/patches/520-pending_work.patch (renamed from package/mac80211/patches/522-ath9k_cleanup_cal_data.patch) | 830 | ||||
-rw-r--r-- | package/mac80211/patches/521-ath9k_no_offchannel_cal.patch | 201 | ||||
-rw-r--r-- | package/mac80211/patches/523-ath9k_nfcal_timeout_handling.patch | 140 |
6 files changed, 662 insertions, 617 deletions
diff --git a/package/mac80211/Makefile b/package/mac80211/Makefile index 8db6eb6..84e5345 100644 --- a/package/mac80211/Makefile +++ b/package/mac80211/Makefile @@ -10,12 +10,12 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mac80211 -PKG_VERSION:=2010-07-26 +PKG_VERSION:=2010-07-29 PKG_RELEASE:=1 PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources # http://www.orbit-lab.org/kernel/compat-wireless-2.6/2010/11 \ # http://wireless.kernel.org/download/compat-wireless-2.6 -PKG_MD5SUM:=4388547c8cf60a895d9ee64420df2f25 +PKG_MD5SUM:=fcfb757939c4718efbf9c87ca59c6932 PKG_SOURCE:=compat-wireless-$(PKG_VERSION).tar.bz2 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/compat-wireless-$(PKG_VERSION) diff --git a/package/mac80211/patches/130-printk_debug_revert.patch b/package/mac80211/patches/130-printk_debug_revert.patch new file mode 100644 index 0000000..232902e --- /dev/null +++ b/package/mac80211/patches/130-printk_debug_revert.patch @@ -0,0 +1,69 @@ +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -2443,9 +2443,8 @@ void cfg80211_cqm_rssi_notify(struct net + wiphy_printk(KERN_NOTICE, wiphy, format, ##args) + #define wiphy_info(wiphy, format, args...) \ + wiphy_printk(KERN_INFO, wiphy, format, ##args) +- +-int wiphy_debug(const struct wiphy *wiphy, const char *format, ...) +- __attribute__ ((format (printf, 2, 3))); ++#define wiphy_debug(wiphy, format, args...) \ ++ wiphy_printk(KERN_DEBUG, wiphy, format, ##args) + + #if defined(DEBUG) + #define wiphy_dbg(wiphy, format, args...) \ +--- a/net/wireless/core.c ++++ b/net/wireless/core.c +@@ -921,52 +921,3 @@ static void __exit cfg80211_exit(void) + destroy_workqueue(cfg80211_wq); + } + module_exit(cfg80211_exit); +- +-static int ___wiphy_printk(const char *level, const struct wiphy *wiphy, +- struct va_format *vaf) +-{ +- if (!wiphy) +- return printk("%s(NULL wiphy *): %pV", level, vaf); +- +- return printk("%s%s: %pV", level, wiphy_name(wiphy), vaf); +-} +- +-int __wiphy_printk(const char *level, const struct wiphy *wiphy, +- const char *fmt, ...) +-{ +- struct va_format vaf; +- va_list args; +- int r; +- +- va_start(args, fmt); +- +- vaf.fmt = fmt; +- vaf.va = &args; +- +- r = ___wiphy_printk(level, wiphy, &vaf); +- va_end(args); +- +- return r; +-} +-EXPORT_SYMBOL(__wiphy_printk); +- +-#define define_wiphy_printk_level(func, kern_level) \ +-int func(const struct wiphy *wiphy, const char *fmt, ...) \ +-{ \ +- struct va_format vaf; \ +- va_list args; \ +- int r; \ +- \ +- va_start(args, fmt); \ +- \ +- vaf.fmt = fmt; \ +- vaf.va = &args; \ +- \ +- r = ___wiphy_printk(kern_level, wiphy, &vaf); \ +- va_end(args); \ +- \ +- return r; \ +-} \ +-EXPORT_SYMBOL(func); +- +-define_wiphy_printk_level(wiphy_debug, KERN_DEBUG); diff --git a/package/mac80211/patches/520-mac80211_offchannel_conf.patch b/package/mac80211/patches/520-mac80211_offchannel_conf.patch deleted file mode 100644 index deb0d06..0000000 --- a/package/mac80211/patches/520-mac80211_offchannel_conf.patch +++ /dev/null @@ -1,35 +0,0 @@ ---- a/include/net/mac80211.h -+++ b/include/net/mac80211.h -@@ -625,11 +625,14 @@ struct ieee80211_rx_status { - * may turn the device off as much as possible. Typically, this flag will - * be set when an interface is set UP but not associated or scanning, but - * it can also be unset in that case when monitor interfaces are active. -+ * @IEEE80211_CONF_OFFCHANNEL: The device is currently not on its main -+ * operating channel. - */ - enum ieee80211_conf_flags { - IEEE80211_CONF_MONITOR = (1<<0), - IEEE80211_CONF_PS = (1<<1), - IEEE80211_CONF_IDLE = (1<<2), -+ IEEE80211_CONF_OFFCHANNEL = (1<<3), - }; - - ---- a/net/mac80211/main.c -+++ b/net/mac80211/main.c -@@ -111,12 +111,15 @@ int ieee80211_hw_config(struct ieee80211 - if (scan_chan) { - chan = scan_chan; - channel_type = NL80211_CHAN_NO_HT; -+ local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL; - } else if (local->tmp_channel) { - chan = scan_chan = local->tmp_channel; - channel_type = local->tmp_channel_type; -+ local->hw.conf.flags |= IEEE80211_CONF_OFFCHANNEL; - } else { - chan = local->oper_channel; - channel_type = local->_oper_channel_type; -+ local->hw.conf.flags &= ~IEEE80211_CONF_OFFCHANNEL; - } - - if (chan != local->hw.conf.channel || diff --git a/package/mac80211/patches/522-ath9k_cleanup_cal_data.patch b/package/mac80211/patches/520-pending_work.patch index a4b6e45..bcbbaf6 100644 --- a/package/mac80211/patches/522-ath9k_cleanup_cal_data.patch +++ b/package/mac80211/patches/520-pending_work.patch @@ -1,66 +1,216 @@ ---- a/drivers/net/wireless/ath/ath9k/hw.h -+++ b/drivers/net/wireless/ath/ath9k/hw.h -@@ -346,19 +346,24 @@ enum ath9k_int { - CHANNEL_HT40PLUS | \ - CHANNEL_HT40MINUS) +--- a/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -103,11 +103,13 @@ int ieee80211_hw_config(struct ieee80211 + int ret = 0; + int power; + enum nl80211_channel_type channel_type; ++ u32 offchannel_flag; + + might_sleep(); + + scan_chan = local->scan_channel; + ++ offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; + if (scan_chan) { + chan = scan_chan; + channel_type = NL80211_CHAN_NO_HT; +@@ -121,8 +123,9 @@ int ieee80211_hw_config(struct ieee80211 + channel_type = local->_oper_channel_type; + local->hw.conf.flags &= ~IEEE80211_CONF_OFFCHANNEL; + } ++ offchannel_flag ^= local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; --struct ath9k_channel { -- struct ieee80211_channel *chan; -+struct ath9k_hw_cal_data { - u16 channel; - u32 channelFlags; -- u32 chanmode; - int32_t CalValid; -- bool oneTimeCalsDone; - int8_t iCoff; - int8_t qCoff; - int16_t rawNoiseFloor; - bool paprd_done; - u16 small_signal_gain[AR9300_MAX_CHAINS]; - u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; -+ struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; -+}; +- if (chan != local->hw.conf.channel || ++ if (offchannel_flag || chan != local->hw.conf.channel || + channel_type != local->hw.conf.channel_type) { + local->hw.conf.channel = chan; + local->hw.conf.channel_type = channel_type; +--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c ++++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c +@@ -63,6 +63,7 @@ static bool ar9002_hw_per_calibration(st + u8 rxchainmask, + struct ath9k_cal_list *currCal) + { ++ struct ath9k_hw_cal_data *caldata = ah->caldata; + bool iscaldone = false; + + if (currCal->calState == CAL_RUNNING) { +@@ -81,14 +82,14 @@ static bool ar9002_hw_per_calibration(st + } + + currCal->calData->calPostProc(ah, numChains); +- ichan->CalValid |= currCal->calData->calType; ++ caldata->CalValid |= currCal->calData->calType; + currCal->calState = CAL_DONE; + iscaldone = true; + } else { + ar9002_hw_setup_calibration(ah, currCal); + } + } +- } else if (!(ichan->CalValid & currCal->calData->calType)) { ++ } else if (!(caldata->CalValid & currCal->calData->calType)) { + ath9k_hw_reset_calibration(ah, currCal); + } + +@@ -686,8 +687,13 @@ static bool ar9002_hw_calibrate(struct a + { + bool iscaldone = true; + struct ath9k_cal_list *currCal = ah->cal_list_curr; ++ bool nfcal, nfcal_pending = false; + +- if (currCal && ++ nfcal = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF); ++ if (ah->caldata) ++ nfcal_pending = ah->caldata->nfcal_pending; + -+struct ath9k_channel { -+ struct ieee80211_channel *chan; -+ u16 channel; -+ u32 channelFlags; -+ u32 chanmode; - }; ++ if (currCal && !nfcal && + (currCal->calState == CAL_RUNNING || + currCal->calState == CAL_WAITING)) { + iscaldone = ar9002_hw_per_calibration(ah, chan, +@@ -703,7 +709,7 @@ static bool ar9002_hw_calibrate(struct a + } - #define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \ -@@ -669,7 +674,7 @@ struct ath_hw { - enum nl80211_iftype opmode; - enum ath9k_power_mode power_mode; + /* Do NF cal only at longer intervals */ +- if (longcal) { ++ if (longcal || nfcal_pending) { + /* Do periodic PAOffset Cal */ + ar9002_hw_pa_cal(ah, false); + ar9002_hw_olc_temp_compensation(ah); +@@ -712,16 +718,18 @@ static bool ar9002_hw_calibrate(struct a + * Get the value from the previous NF cal and update + * history buffer. + */ +- ath9k_hw_getnf(ah, chan); +- +- /* +- * Load the NF from history buffer of the current channel. +- * NF is slow time-variant, so it is OK to use a historical +- * value. +- */ +- ath9k_hw_loadnf(ah, ah->curchan); ++ if (ath9k_hw_getnf(ah, chan)) { ++ /* ++ * Load the NF from history buffer of the current ++ * channel. ++ * NF is slow time-variant, so it is OK to use a ++ * historical value. ++ */ ++ ath9k_hw_loadnf(ah, ah->curchan); ++ } + +- ath9k_hw_start_nfcal(ah); ++ if (longcal) ++ ath9k_hw_start_nfcal(ah, false); + } -- struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; -+ struct ath9k_hw_cal_data *caldata; - struct ath9k_pacal_info pacal_info; - struct ar5416Stats stats; - struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES]; -@@ -863,7 +868,7 @@ const char *ath9k_hw_probe(u16 vendorid, - void ath9k_hw_deinit(struct ath_hw *ah); - int ath9k_hw_init(struct ath_hw *ah); - int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, -- bool bChannelChange); -+ struct ath9k_hw_cal_data *caldata, bool bChannelChange); - int ath9k_hw_fill_cap_info(struct ath_hw *ah); - u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan); + return iscaldone; +@@ -869,8 +877,10 @@ static bool ar9002_hw_init_cal(struct at + ar9002_hw_pa_cal(ah, true); -@@ -958,9 +963,10 @@ void ar9003_hw_bb_watchdog_read(struct a - void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); - void ar9003_paprd_enable(struct ath_hw *ah, bool val); - void ar9003_paprd_populate_single_table(struct ath_hw *ah, -- struct ath9k_channel *chan, int chain); --int ar9003_paprd_create_curve(struct ath_hw *ah, struct ath9k_channel *chan, -- int chain); -+ struct ath9k_hw_cal_data *caldata, -+ int chain); -+int ar9003_paprd_create_curve(struct ath_hw *ah, -+ struct ath9k_hw_cal_data *caldata, int chain); - int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain); - int ar9003_paprd_init_table(struct ath_hw *ah); - bool ar9003_paprd_is_done(struct ath_hw *ah); + /* Do NF Calibration after DC offset and other calibrations */ +- REG_WRITE(ah, AR_PHY_AGC_CONTROL, +- REG_READ(ah, AR_PHY_AGC_CONTROL) | AR_PHY_AGC_CONTROL_NF); ++ ath9k_hw_start_nfcal(ah, true); ++ ++ if (ah->caldata) ++ ah->caldata->nfcal_pending = true; + + ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; + +@@ -901,7 +911,8 @@ static bool ar9002_hw_init_cal(struct at + ath9k_hw_reset_calibration(ah, ah->cal_list_curr); + } + +- chan->CalValid = 0; ++ if (ah->caldata) ++ ah->caldata->CalValid = 0; + + return true; + } +--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c +@@ -68,6 +68,7 @@ static bool ar9003_hw_per_calibration(st + u8 rxchainmask, + struct ath9k_cal_list *currCal) + { ++ struct ath9k_hw_cal_data *caldata = ah->caldata; + /* Cal is assumed not done until explicitly set below */ + bool iscaldone = false; + +@@ -95,7 +96,7 @@ static bool ar9003_hw_per_calibration(st + currCal->calData->calPostProc(ah, numChains); + + /* Calibration has finished. */ +- ichan->CalValid |= currCal->calData->calType; ++ caldata->CalValid |= currCal->calData->calType; + currCal->calState = CAL_DONE; + iscaldone = true; + } else { +@@ -106,7 +107,7 @@ static bool ar9003_hw_per_calibration(st + ar9003_hw_setup_calibration(ah, currCal); + } + } +- } else if (!(ichan->CalValid & currCal->calData->calType)) { ++ } else if (!(caldata->CalValid & currCal->calData->calType)) { + /* If current cal is marked invalid in channel, kick it off */ + ath9k_hw_reset_calibration(ah, currCal); + } +@@ -149,6 +150,12 @@ static bool ar9003_hw_calibrate(struct a + /* Do NF cal only at longer intervals */ + if (longcal) { + /* ++ * Get the value from the previous NF cal and update ++ * history buffer. ++ */ ++ ath9k_hw_getnf(ah, chan); ++ ++ /* + * Load the NF from history buffer of the current channel. + * NF is slow time-variant, so it is OK to use a historical + * value. +@@ -156,7 +163,7 @@ static bool ar9003_hw_calibrate(struct a + ath9k_hw_loadnf(ah, ah->curchan); + + /* start NF calibration, without updating BB NF register */ +- ath9k_hw_start_nfcal(ah); ++ ath9k_hw_start_nfcal(ah, false); + } + + return iscaldone; +@@ -762,6 +769,8 @@ static bool ar9003_hw_init_cal(struct at + /* Revert chainmasks to their original values before NF cal */ + ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask); + ++ ath9k_hw_start_nfcal(ah, true); ++ + /* Initialize list pointers */ + ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; + +@@ -785,7 +794,8 @@ static bool ar9003_hw_init_cal(struct at + if (ah->cal_list_curr) + ath9k_hw_reset_calibration(ah, ah->cal_list_curr); + +- chan->CalValid = 0; ++ if (ah->caldata) ++ ah->caldata->CalValid = 0; + + return true; + } +--- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c ++++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c +@@ -542,7 +542,11 @@ static void ar9003_hw_prog_ini(struct at + u32 reg = INI_RA(iniArr, i, 0); + u32 val = INI_RA(iniArr, i, column); + +- REG_WRITE(ah, reg, val); ++ if (reg >= 0x16000 && reg < 0x17000) ++ ath9k_hw_analog_shift_regwrite(ah, reg, val); ++ else ++ REG_WRITE(ah, reg, val); ++ + DO_DELAY(regWrites); + } + } --- a/drivers/net/wireless/ath/ath9k/calib.c +++ b/drivers/net/wireless/ath/ath9k/calib.c @@ -22,23 +22,6 @@ @@ -116,7 +266,7 @@ return true; if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah)) -@@ -151,7 +147,7 @@ bool ath9k_hw_reset_calvalid(struct ath_ +@@ -151,37 +147,55 @@ bool ath9k_hw_reset_calvalid(struct ath_ "Resetting Cal %d state for channel %u\n", currCal->calData->calType, conf->channel->center_freq); @@ -125,7 +275,28 @@ currCal->calState = CAL_WAITING; return false; -@@ -169,19 +165,28 @@ void ath9k_hw_start_nfcal(struct ath_hw + } + EXPORT_SYMBOL(ath9k_hw_reset_calvalid); + +-void ath9k_hw_start_nfcal(struct ath_hw *ah) ++void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update) + { ++ if (ah->caldata) ++ ah->caldata->nfcal_pending = true; ++ + REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, + AR_PHY_AGC_CONTROL_ENABLE_NF); +- REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, ++ ++ if (update) ++ REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, ++ AR_PHY_AGC_CONTROL_NO_UPDATE_NF); ++ else ++ REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, + AR_PHY_AGC_CONTROL_NO_UPDATE_NF); ++ + REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF); + } void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan) { @@ -157,14 +328,23 @@ REG_WRITE(ah, ah->nf_regs[i], val); } } -@@ -285,14 +290,18 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah +@@ -277,22 +291,25 @@ static void ath9k_hw_nf_sanitize(struct + } + } + +-int16_t ath9k_hw_getnf(struct ath_hw *ah, +- struct ath9k_channel *chan) ++bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan) + { + struct ath_common *common = ath9k_hw_common(ah); + int16_t nf, nfThresh; int16_t nfarray[NUM_NF_READINGS] = { 0 }; struct ath9k_nfcal_hist *h; struct ieee80211_channel *c = chan->chan; + struct ath9k_hw_cal_data *caldata = ah->caldata; + + if (!caldata) -+ return ath9k_hw_get_default_nf(ah, chan); ++ return false; chan->channelFlags &= (~CHANNEL_CW_INT); if (REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) { @@ -174,23 +354,24 @@ - chan->rawNoiseFloor = nf; - return chan->rawNoiseFloor; + caldata->rawNoiseFloor = nf; -+ return caldata->rawNoiseFloor; ++ return false; } else { ath9k_hw_do_getnf(ah, nfarray); ath9k_hw_nf_sanitize(ah, nfarray); -@@ -307,47 +316,41 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah +@@ -307,47 +324,40 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah } } - h = ah->nfCalHist; +- + h = caldata->nfCalHist; - ++ caldata->nfcal_pending = false; ath9k_hw_update_nfcal_hist_buffer(h, nfarray); - chan->rawNoiseFloor = h[0].privNF; -+ caldata->rawNoiseFloor = h[0].privNF; - +- - return chan->rawNoiseFloor; -+ return ah->caldata->rawNoiseFloor; ++ caldata->rawNoiseFloor = h[0].privNF; ++ return true; } -void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah) @@ -244,9 +425,127 @@ + return ah->caldata->rawNoiseFloor; } EXPORT_SYMBOL(ath9k_hw_getchan_noise); +--- a/drivers/net/wireless/ath/ath9k/calib.h ++++ b/drivers/net/wireless/ath/ath9k/calib.h +@@ -108,11 +108,11 @@ struct ath9k_pacal_info{ + }; + + bool ath9k_hw_reset_calvalid(struct ath_hw *ah); +-void ath9k_hw_start_nfcal(struct ath_hw *ah); ++void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update); + void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan); +-int16_t ath9k_hw_getnf(struct ath_hw *ah, +- struct ath9k_channel *chan); +-void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah); ++bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan); ++void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah, ++ struct ath9k_channel *chan); + s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan); + void ath9k_hw_reset_calibration(struct ath_hw *ah, + struct ath9k_cal_list *currCal); +--- a/drivers/net/wireless/ath/ath9k/hw.c ++++ b/drivers/net/wireless/ath/ath9k/hw.c +@@ -622,7 +622,6 @@ static int __ath9k_hw_init(struct ath_hw + else + ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S); + +- ath9k_init_nfcal_hist_buffer(ah); + ah->bb_watchdog_timeout_ms = 25; + + common->state = ATH_HW_INITIALIZED; +@@ -1195,9 +1194,6 @@ static bool ath9k_hw_channel_change(stru + + ath9k_hw_spur_mitigate_freq(ah, chan); + +- if (!chan->oneTimeCalsDone) +- chan->oneTimeCalsDone = true; +- + return true; + } + +@@ -1230,7 +1226,7 @@ bool ath9k_hw_check_alive(struct ath_hw + EXPORT_SYMBOL(ath9k_hw_check_alive); + + int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, +- bool bChannelChange) ++ struct ath9k_hw_cal_data *caldata, bool bChannelChange) + { + struct ath_common *common = ath9k_hw_common(ah); + u32 saveLedState; +@@ -1255,9 +1251,19 @@ int ath9k_hw_reset(struct ath_hw *ah, st + if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) + return -EIO; + +- if (curchan && !ah->chip_fullsleep) ++ if (curchan && !ah->chip_fullsleep && ah->caldata) + ath9k_hw_getnf(ah, curchan); + ++ ah->caldata = caldata; ++ if (caldata && ++ (chan->channel != caldata->channel || ++ (chan->channelFlags & ~CHANNEL_CW_INT) != ++ (caldata->channelFlags & ~CHANNEL_CW_INT))) { ++ /* Operating channel changed, reset channel calibration data */ ++ memset(caldata, 0, sizeof(*caldata)); ++ ath9k_init_nfcal_hist_buffer(ah, chan); ++ } ++ + if (bChannelChange && + (ah->chip_fullsleep != true) && + (ah->curchan != NULL) && +@@ -1268,7 +1274,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st + + if (ath9k_hw_channel_change(ah, chan)) { + ath9k_hw_loadnf(ah, ah->curchan); +- ath9k_hw_start_nfcal(ah); ++ ath9k_hw_start_nfcal(ah, true); + return 0; + } + } +@@ -1473,11 +1479,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st + if (ah->btcoex_hw.enabled) + ath9k_hw_btcoex_enable(ah); + +- if (AR_SREV_9300_20_OR_LATER(ah)) { +- ath9k_hw_loadnf(ah, curchan); +- ath9k_hw_start_nfcal(ah); ++ if (AR_SREV_9300_20_OR_LATER(ah)) + ar9003_hw_bb_watchdog_config(ah); +- } + + return 0; + } --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c -@@ -184,11 +184,13 @@ static void ath_start_ani(struct ath_com +@@ -155,6 +155,27 @@ void ath9k_ps_restore(struct ath_softc * + spin_unlock_irqrestore(&sc->sc_pm_lock, flags); + } + ++static void ath_start_ani(struct ath_common *common) ++{ ++ struct ath_hw *ah = common->ah; ++ unsigned long timestamp = jiffies_to_msecs(jiffies); ++ struct ath_softc *sc = (struct ath_softc *) common->priv; ++ ++ if (!(sc->sc_flags & SC_OP_ANI_RUN)) ++ return; ++ ++ if (sc->sc_flags & SC_OP_OFFCHANNEL) ++ return; ++ ++ common->ani.longcal_timer = timestamp; ++ common->ani.shortcal_timer = timestamp; ++ common->ani.checkani_timer = timestamp; ++ ++ mod_timer(&common->ani.timer, ++ jiffies + ++ msecs_to_jiffies((u32)ah->config.ani_poll_interval)); ++} ++ + /* + * Set/change channels. If the channel is really being changed, it's done + * by reseting the chip. To accomplish this we must first cleanup any pending +@@ -163,16 +184,23 @@ void ath9k_ps_restore(struct ath_softc * int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw, struct ath9k_channel *hchan) { @@ -260,8 +559,22 @@ int r; if (sc->sc_flags & SC_OP_INVALID) -@@ -221,6 +223,9 @@ int ath_set_channel(struct ath_softc *sc - if (!stopped || !(sc->sc_flags & SC_OP_OFFCHANNEL)) + return -EIO; + ++ del_timer_sync(&common->ani.timer); ++ cancel_work_sync(&sc->paprd_work); ++ cancel_work_sync(&sc->hw_check_work); ++ cancel_delayed_work_sync(&sc->tx_complete_work); ++ + ath9k_ps_wakeup(sc); + + /* +@@ -192,9 +220,12 @@ int ath_set_channel(struct ath_softc *sc + * to flush data frames already in queue because of + * changing channel. */ + +- if (!stopped || (sc->sc_flags & SC_OP_FULL_RESET)) ++ if (!stopped || !(sc->sc_flags & SC_OP_OFFCHANNEL)) fastcc = false; + if (!(sc->sc_flags & SC_OP_OFFCHANNEL)) @@ -270,7 +583,7 @@ ath_print(common, ATH_DBG_CONFIG, "(%u MHz) -> (%u MHz), conf_is_ht40: %d\n", sc->sc_ah->curchan->channel, -@@ -228,7 +233,7 @@ int ath_set_channel(struct ath_softc *sc +@@ -202,7 +233,7 @@ int ath_set_channel(struct ath_softc *sc spin_lock_bh(&sc->sc_resetlock); @@ -279,7 +592,29 @@ if (r) { ath_print(common, ATH_DBG_FATAL, "Unable to reset channel (%u MHz), " -@@ -264,9 +269,10 @@ int ath_set_channel(struct ath_softc *sc +@@ -213,8 +244,6 @@ int ath_set_channel(struct ath_softc *sc + } + spin_unlock_bh(&sc->sc_resetlock); + +- sc->sc_flags &= ~SC_OP_FULL_RESET; +- + if (ath_startrecv(sc) != 0) { + ath_print(common, ATH_DBG_FATAL, + "Unable to restart recv logic\n"); +@@ -226,6 +255,12 @@ int ath_set_channel(struct ath_softc *sc + ath_update_txpow(sc); + ath9k_hw_set_interrupts(ah, ah->imask); + ++ if (!(sc->sc_flags & (SC_OP_OFFCHANNEL | SC_OP_SCANNING))) { ++ ath_start_ani(common); ++ ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); ++ ath_beacon_config(sc, NULL); ++ } ++ + ps_restore: + ath9k_ps_restore(sc); + return r; +@@ -234,17 +269,19 @@ int ath_set_channel(struct ath_softc *sc static void ath_paprd_activate(struct ath_softc *sc) { struct ath_hw *ah = sc->sc_ah; @@ -291,7 +626,8 @@ return; ath9k_ps_wakeup(sc); -@@ -274,7 +280,7 @@ static void ath_paprd_activate(struct at ++ ar9003_paprd_enable(ah, false); + for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) { if (!(ah->caps.tx_chainmask & BIT(chain))) continue; @@ -300,7 +636,7 @@ } ar9003_paprd_enable(ah, true); -@@ -292,6 +298,7 @@ void ath_paprd_calibrate(struct work_str +@@ -262,6 +299,7 @@ void ath_paprd_calibrate(struct work_str int band = hw->conf.channel->band; struct ieee80211_supported_band *sband = &sc->sbands[band]; struct ath_tx_control txctl; @@ -308,7 +644,7 @@ int qnum, ftype; int chain_ok = 0; int chain; -@@ -299,6 +306,9 @@ void ath_paprd_calibrate(struct work_str +@@ -269,6 +307,9 @@ void ath_paprd_calibrate(struct work_str int time_left; int i; @@ -318,7 +654,7 @@ skb = alloc_skb(len, GFP_KERNEL); if (!skb) return; -@@ -353,7 +363,7 @@ void ath_paprd_calibrate(struct work_str +@@ -323,7 +364,7 @@ void ath_paprd_calibrate(struct work_str if (!ar9003_paprd_is_done(ah)) break; @@ -327,7 +663,7 @@ break; chain_ok = 1; -@@ -361,7 +371,7 @@ void ath_paprd_calibrate(struct work_str +@@ -331,7 +372,7 @@ void ath_paprd_calibrate(struct work_str kfree_skb(skb); if (chain_ok) { @@ -336,18 +672,52 @@ ath_paprd_activate(sc); } -@@ -470,8 +480,8 @@ set_timer: +@@ -440,33 +481,14 @@ set_timer: cal_interval = min(cal_interval, (u32)short_cal_interval); mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval)); -- if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) { +- if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && +- !(sc->sc_flags & SC_OP_SCANNING)) { - if (!sc->sc_ah->curchan->paprd_done) + if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && ah->caldata) { + if (!ah->caldata->paprd_done) ieee80211_queue_work(sc->hw, &sc->paprd_work); else ath_paprd_activate(sc); -@@ -829,7 +839,7 @@ void ath_radio_enable(struct ath_softc * + } + } + +-static void ath_start_ani(struct ath_common *common) +-{ +- struct ath_hw *ah = common->ah; +- unsigned long timestamp = jiffies_to_msecs(jiffies); +- struct ath_softc *sc = (struct ath_softc *) common->priv; +- +- if (!(sc->sc_flags & SC_OP_ANI_RUN)) +- return; +- +- common->ani.longcal_timer = timestamp; +- common->ani.shortcal_timer = timestamp; +- common->ani.checkani_timer = timestamp; +- +- mod_timer(&common->ani.timer, +- jiffies + +- msecs_to_jiffies((u32)ah->config.ani_poll_interval)); +-} +- + /* + * Update tx/rx chainmask. For legacy association, + * hard code chainmask to 1x1, for 11n association, use +@@ -478,7 +500,7 @@ void ath_update_chainmask(struct ath_sof + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + +- if ((sc->sc_flags & SC_OP_SCANNING) || is_ht || ++ if ((sc->sc_flags & SC_OP_OFFCHANNEL) || is_ht || + (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE)) { + common->tx_chainmask = ah->caps.tx_chainmask; + common->rx_chainmask = ah->caps.rx_chainmask; +@@ -818,7 +840,7 @@ void ath_radio_enable(struct ath_softc * ah->curchan = ath_get_curchannel(sc, sc->hw); spin_lock_bh(&sc->sc_resetlock); @@ -356,7 +726,7 @@ if (r) { ath_print(common, ATH_DBG_FATAL, "Unable to reset channel (%u MHz), " -@@ -889,7 +899,7 @@ void ath_radio_disable(struct ath_softc +@@ -878,7 +900,7 @@ void ath_radio_disable(struct ath_softc ah->curchan = ath_get_curchannel(sc, hw); spin_lock_bh(&sc->sc_resetlock); @@ -365,7 +735,7 @@ if (r) { ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, "Unable to reset channel (%u MHz), " -@@ -922,7 +932,7 @@ int ath_reset(struct ath_softc *sc, bool +@@ -911,7 +933,7 @@ int ath_reset(struct ath_softc *sc, bool ath_flushrecv(sc); spin_lock_bh(&sc->sc_resetlock); @@ -374,7 +744,7 @@ if (r) ath_print(common, ATH_DBG_FATAL, "Unable to reset hardware; reset status %d\n", r); -@@ -1097,7 +1107,7 @@ static int ath9k_start(struct ieee80211_ +@@ -1086,7 +1108,7 @@ static int ath9k_start(struct ieee80211_ * and then setup of the interrupt mask. */ spin_lock_bh(&sc->sc_resetlock); @@ -383,6 +753,52 @@ if (r) { ath_print(common, ATH_DBG_FATAL, "Unable to reset hardware; reset status %d " +@@ -1580,6 +1602,10 @@ static int ath9k_config(struct ieee80211 + + aphy->chan_idx = pos; + aphy->chan_is_ht = conf_is_ht(conf); ++ if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) ++ sc->sc_flags |= SC_OP_OFFCHANNEL; ++ else ++ sc->sc_flags &= ~SC_OP_OFFCHANNEL; + + if (aphy->state == ATH_WIPHY_SCAN || + aphy->state == ATH_WIPHY_ACTIVE) +@@ -1991,7 +2017,6 @@ static void ath9k_sw_scan_start(struct i + { + struct ath_wiphy *aphy = hw->priv; + struct ath_softc *sc = aphy->sc; +- struct ath_common *common = ath9k_hw_common(sc->sc_ah); + + mutex_lock(&sc->mutex); + if (ath9k_wiphy_scanning(sc)) { +@@ -2009,10 +2034,6 @@ static void ath9k_sw_scan_start(struct i + aphy->state = ATH_WIPHY_SCAN; + ath9k_wiphy_pause_all_forced(sc, aphy); + sc->sc_flags |= SC_OP_SCANNING; +- del_timer_sync(&common->ani.timer); +- cancel_work_sync(&sc->paprd_work); +- cancel_work_sync(&sc->hw_check_work); +- cancel_delayed_work_sync(&sc->tx_complete_work); + mutex_unlock(&sc->mutex); + } + +@@ -2024,15 +2045,10 @@ static void ath9k_sw_scan_complete(struc + { + struct ath_wiphy *aphy = hw->priv; + struct ath_softc *sc = aphy->sc; +- struct ath_common *common = ath9k_hw_common(sc->sc_ah); + + mutex_lock(&sc->mutex); + aphy->state = ATH_WIPHY_ACTIVE; + sc->sc_flags &= ~SC_OP_SCANNING; +- sc->sc_flags |= SC_OP_FULL_RESET; +- ath_start_ani(common); +- ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); +- ath_beacon_config(sc, NULL); + mutex_unlock(&sc->mutex); + } + --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c @@ -577,10 +577,11 @@ static bool create_pa_curve(u32 *data_L, @@ -423,131 +839,36 @@ buf = kmalloc(2 * 48 * sizeof(u32), GFP_ATOMIC); if (!buf) ---- a/drivers/net/wireless/ath/ath9k/hw.c -+++ b/drivers/net/wireless/ath/ath9k/hw.c -@@ -621,7 +621,6 @@ static int __ath9k_hw_init(struct ath_hw - else - ah->tx_trig_level = (AR_FTRIG_512B >> AR_FTRIG_S); - -- ath9k_init_nfcal_hist_buffer(ah); - ah->bb_watchdog_timeout_ms = 25; - - common->state = ATH_HW_INITIALIZED; -@@ -1194,9 +1193,6 @@ static bool ath9k_hw_channel_change(stru - - ath9k_hw_spur_mitigate_freq(ah, chan); - -- if (!chan->oneTimeCalsDone) -- chan->oneTimeCalsDone = true; -- - return true; - } - -@@ -1229,7 +1225,7 @@ bool ath9k_hw_check_alive(struct ath_hw - EXPORT_SYMBOL(ath9k_hw_check_alive); - - int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, -- bool bChannelChange) -+ struct ath9k_hw_cal_data *caldata, bool bChannelChange) - { - struct ath_common *common = ath9k_hw_common(ah); - u32 saveLedState; -@@ -1254,9 +1250,19 @@ int ath9k_hw_reset(struct ath_hw *ah, st - if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) - return -EIO; - -- if (curchan && !ah->chip_fullsleep) -+ if (curchan && !ah->chip_fullsleep && ah->caldata) - ath9k_hw_getnf(ah, curchan); +--- a/drivers/net/wireless/ath/ath9k/ath9k.h ++++ b/drivers/net/wireless/ath/ath9k/ath9k.h +@@ -511,7 +511,7 @@ void ath_deinit_leds(struct ath_softc *s + #define SC_OP_BEACONS BIT(1) + #define SC_OP_RXAGGR BIT(2) + #define SC_OP_TXAGGR BIT(3) +-#define SC_OP_FULL_RESET BIT(4) ++#define SC_OP_OFFCHANNEL BIT(4) + #define SC_OP_PREAMBLE_SHORT BIT(5) + #define SC_OP_PROTECT_ENABLE BIT(6) + #define SC_OP_RXFLUSH BIT(7) +@@ -612,6 +612,7 @@ struct ath_softc { + struct ath_wiphy { + struct ath_softc *sc; /* shared for all virtual wiphys */ + struct ieee80211_hw *hw; ++ struct ath9k_hw_cal_data caldata; + enum ath_wiphy_state { + ATH_WIPHY_INACTIVE, + ATH_WIPHY_ACTIVE, +--- a/drivers/net/wireless/ath/ath9k/htc.h ++++ b/drivers/net/wireless/ath/ath9k/htc.h +@@ -353,6 +353,8 @@ struct ath9k_htc_priv { + u16 seq_no; + u32 bmiss_cnt; -+ ah->caldata = caldata; -+ if (caldata && -+ (chan->channel != caldata->channel || -+ (chan->channelFlags & ~CHANNEL_CW_INT) != -+ (caldata->channelFlags & ~CHANNEL_CW_INT))) { -+ /* Operating channel changed, reset channel calibration data */ -+ memset(caldata, 0, sizeof(*caldata)); -+ ath9k_init_nfcal_hist_buffer(ah, chan); -+ } ++ struct ath9k_hw_cal_data caldata[38]; + - if (bChannelChange && - (ah->chip_fullsleep != true) && - (ah->curchan != NULL) && ---- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c -+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c -@@ -63,6 +63,7 @@ static bool ar9002_hw_per_calibration(st - u8 rxchainmask, - struct ath9k_cal_list *currCal) - { -+ struct ath9k_hw_cal_data *caldata = ah->caldata; - bool iscaldone = false; - - if (currCal->calState == CAL_RUNNING) { -@@ -81,14 +82,14 @@ static bool ar9002_hw_per_calibration(st - } - - currCal->calData->calPostProc(ah, numChains); -- ichan->CalValid |= currCal->calData->calType; -+ caldata->CalValid |= currCal->calData->calType; - currCal->calState = CAL_DONE; - iscaldone = true; - } else { - ar9002_hw_setup_calibration(ah, currCal); - } - } -- } else if (!(ichan->CalValid & currCal->calData->calType)) { -+ } else if (!(caldata->CalValid & currCal->calData->calType)) { - ath9k_hw_reset_calibration(ah, currCal); - } - -@@ -901,7 +902,8 @@ static bool ar9002_hw_init_cal(struct at - ath9k_hw_reset_calibration(ah, ah->cal_list_curr); - } - -- chan->CalValid = 0; -+ if (ah->caldata) -+ ah->caldata->CalValid = 0; - - return true; - } ---- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c -+++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c -@@ -68,6 +68,7 @@ static bool ar9003_hw_per_calibration(st - u8 rxchainmask, - struct ath9k_cal_list *currCal) - { -+ struct ath9k_hw_cal_data *caldata = ah->caldata; - /* Cal is assumed not done until explicitly set below */ - bool iscaldone = false; - -@@ -95,7 +96,7 @@ static bool ar9003_hw_per_calibration(st - currCal->calData->calPostProc(ah, numChains); - - /* Calibration has finished. */ -- ichan->CalValid |= currCal->calData->calType; -+ caldata->CalValid |= currCal->calData->calType; - currCal->calState = CAL_DONE; - iscaldone = true; - } else { -@@ -106,7 +107,7 @@ static bool ar9003_hw_per_calibration(st - ar9003_hw_setup_calibration(ah, currCal); - } - } -- } else if (!(ichan->CalValid & currCal->calData->calType)) { -+ } else if (!(caldata->CalValid & currCal->calData->calType)) { - /* If current cal is marked invalid in channel, kick it off */ - ath9k_hw_reset_calibration(ah, currCal); - } -@@ -785,7 +786,8 @@ static bool ar9003_hw_init_cal(struct at - if (ah->cal_list_curr) - ath9k_hw_reset_calibration(ah, ah->cal_list_curr); - -- chan->CalValid = 0; -+ if (ah->caldata) -+ ah->caldata->CalValid = 0; + spinlock_t beacon_lock; - return true; - } + bool tx_queues_stop; --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c @@ -125,6 +125,7 @@ static int ath9k_htc_set_channel(struct @@ -595,6 +916,70 @@ if (ret) { ath_print(common, ATH_DBG_FATAL, "Unable to reset hardware; reset status %d " +--- a/drivers/net/wireless/ath/ath9k/hw.h ++++ b/drivers/net/wireless/ath/ath9k/hw.h +@@ -346,19 +346,25 @@ enum ath9k_int { + CHANNEL_HT40PLUS | \ + CHANNEL_HT40MINUS) + +-struct ath9k_channel { +- struct ieee80211_channel *chan; ++struct ath9k_hw_cal_data { + u16 channel; + u32 channelFlags; +- u32 chanmode; + int32_t CalValid; +- bool oneTimeCalsDone; + int8_t iCoff; + int8_t qCoff; + int16_t rawNoiseFloor; + bool paprd_done; ++ bool nfcal_pending; + u16 small_signal_gain[AR9300_MAX_CHAINS]; + u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; ++ struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; ++}; ++ ++struct ath9k_channel { ++ struct ieee80211_channel *chan; ++ u16 channel; ++ u32 channelFlags; ++ u32 chanmode; + }; + + #define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \ +@@ -669,7 +675,7 @@ struct ath_hw { + enum nl80211_iftype opmode; + enum ath9k_power_mode power_mode; + +- struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; ++ struct ath9k_hw_cal_data *caldata; + struct ath9k_pacal_info pacal_info; + struct ar5416Stats stats; + struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES]; +@@ -863,7 +869,7 @@ const char *ath9k_hw_probe(u16 vendorid, + void ath9k_hw_deinit(struct ath_hw *ah); + int ath9k_hw_init(struct ath_hw *ah); + int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, +- bool bChannelChange); ++ struct ath9k_hw_cal_data *caldata, bool bChannelChange); + int ath9k_hw_fill_cap_info(struct ath_hw *ah); + u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan); + +@@ -958,9 +964,10 @@ void ar9003_hw_bb_watchdog_read(struct a + void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); + void ar9003_paprd_enable(struct ath_hw *ah, bool val); + void ar9003_paprd_populate_single_table(struct ath_hw *ah, +- struct ath9k_channel *chan, int chain); +-int ar9003_paprd_create_curve(struct ath_hw *ah, struct ath9k_channel *chan, +- int chain); ++ struct ath9k_hw_cal_data *caldata, ++ int chain); ++int ar9003_paprd_create_curve(struct ath_hw *ah, ++ struct ath9k_hw_cal_data *caldata, int chain); + int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain); + int ar9003_paprd_init_table(struct ath_hw *ah); + bool ar9003_paprd_is_done(struct ath_hw *ah); --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -1181,7 +1181,7 @@ void ath_drain_all_txq(struct ath_softc @@ -606,36 +991,3 @@ if (r) ath_print(common, ATH_DBG_FATAL, "Unable to reset hardware; reset status %d\n", ---- a/drivers/net/wireless/ath/ath9k/ath9k.h -+++ b/drivers/net/wireless/ath/ath9k/ath9k.h -@@ -611,6 +611,7 @@ struct ath_softc { - struct ath_wiphy { - struct ath_softc *sc; /* shared for all virtual wiphys */ - struct ieee80211_hw *hw; -+ struct ath9k_hw_cal_data caldata; - enum ath_wiphy_state { - ATH_WIPHY_INACTIVE, - ATH_WIPHY_ACTIVE, ---- a/drivers/net/wireless/ath/ath9k/calib.h -+++ b/drivers/net/wireless/ath/ath9k/calib.h -@@ -112,7 +112,8 @@ void ath9k_hw_start_nfcal(struct ath_hw - void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan); - int16_t ath9k_hw_getnf(struct ath_hw *ah, - struct ath9k_channel *chan); --void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah); -+void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah, -+ struct ath9k_channel *chan); - s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan); - void ath9k_hw_reset_calibration(struct ath_hw *ah, - struct ath9k_cal_list *currCal); ---- a/drivers/net/wireless/ath/ath9k/htc.h -+++ b/drivers/net/wireless/ath/ath9k/htc.h -@@ -353,6 +353,8 @@ struct ath9k_htc_priv { - u16 seq_no; - u32 bmiss_cnt; - -+ struct ath9k_hw_cal_data caldata[38]; -+ - spinlock_t beacon_lock; - - bool tx_queues_stop; diff --git a/package/mac80211/patches/521-ath9k_no_offchannel_cal.patch b/package/mac80211/patches/521-ath9k_no_offchannel_cal.patch deleted file mode 100644 index 5f5d608..0000000 --- a/package/mac80211/patches/521-ath9k_no_offchannel_cal.patch +++ /dev/null @@ -1,201 +0,0 @@ ---- a/drivers/net/wireless/ath/ath9k/ath9k.h -+++ b/drivers/net/wireless/ath/ath9k/ath9k.h -@@ -511,13 +511,12 @@ void ath_deinit_leds(struct ath_softc *s - #define SC_OP_BEACONS BIT(1) - #define SC_OP_RXAGGR BIT(2) - #define SC_OP_TXAGGR BIT(3) --#define SC_OP_FULL_RESET BIT(4) - #define SC_OP_PREAMBLE_SHORT BIT(5) - #define SC_OP_PROTECT_ENABLE BIT(6) - #define SC_OP_RXFLUSH BIT(7) - #define SC_OP_LED_ASSOCIATED BIT(8) - #define SC_OP_LED_ON BIT(9) --#define SC_OP_SCANNING BIT(10) -+#define SC_OP_OFFCHANNEL BIT(10) - #define SC_OP_TSF_RESET BIT(11) - #define SC_OP_BT_PRIORITY_DETECTED BIT(12) - #define SC_OP_BT_SCAN BIT(13) ---- a/drivers/net/wireless/ath/ath9k/main.c -+++ b/drivers/net/wireless/ath/ath9k/main.c -@@ -155,6 +155,27 @@ void ath9k_ps_restore(struct ath_softc * - spin_unlock_irqrestore(&sc->sc_pm_lock, flags); - } - -+static void ath_start_ani(struct ath_common *common) -+{ -+ struct ath_hw *ah = common->ah; -+ unsigned long timestamp = jiffies_to_msecs(jiffies); -+ struct ath_softc *sc = (struct ath_softc *) common->priv; -+ -+ if (!(sc->sc_flags & SC_OP_ANI_RUN)) -+ return; -+ -+ if (sc->sc_flags & SC_OP_OFFCHANNEL) -+ return; -+ -+ common->ani.longcal_timer = timestamp; -+ common->ani.shortcal_timer = timestamp; -+ common->ani.checkani_timer = timestamp; -+ -+ mod_timer(&common->ani.timer, -+ jiffies + -+ msecs_to_jiffies((u32)ah->config.ani_poll_interval)); -+} -+ - /* - * Set/change channels. If the channel is really being changed, it's done - * by reseting the chip. To accomplish this we must first cleanup any pending -@@ -173,6 +194,11 @@ int ath_set_channel(struct ath_softc *sc - if (sc->sc_flags & SC_OP_INVALID) - return -EIO; - -+ del_timer_sync(&common->ani.timer); -+ cancel_work_sync(&sc->paprd_work); -+ cancel_work_sync(&sc->hw_check_work); -+ cancel_delayed_work_sync(&sc->tx_complete_work); -+ - ath9k_ps_wakeup(sc); - - /* -@@ -192,7 +218,7 @@ int ath_set_channel(struct ath_softc *sc - * to flush data frames already in queue because of - * changing channel. */ - -- if (!stopped || (sc->sc_flags & SC_OP_FULL_RESET)) -+ if (!stopped || !(sc->sc_flags & SC_OP_OFFCHANNEL)) - fastcc = false; - - ath_print(common, ATH_DBG_CONFIG, -@@ -213,8 +239,6 @@ int ath_set_channel(struct ath_softc *sc - } - spin_unlock_bh(&sc->sc_resetlock); - -- sc->sc_flags &= ~SC_OP_FULL_RESET; -- - if (ath_startrecv(sc) != 0) { - ath_print(common, ATH_DBG_FATAL, - "Unable to restart recv logic\n"); -@@ -226,6 +250,12 @@ int ath_set_channel(struct ath_softc *sc - ath_update_txpow(sc); - ath9k_hw_set_interrupts(ah, ah->imask); - -+ if (!(sc->sc_flags & SC_OP_OFFCHANNEL)) { -+ ath_start_ani(common); -+ ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); -+ ath_beacon_config(sc, NULL); -+ } -+ - ps_restore: - ath9k_ps_restore(sc); - return r; -@@ -440,8 +470,7 @@ set_timer: - cal_interval = min(cal_interval, (u32)short_cal_interval); - - mod_timer(&common->ani.timer, jiffies + msecs_to_jiffies(cal_interval)); -- if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) && -- !(sc->sc_flags & SC_OP_SCANNING)) { -+ if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_PAPRD) { - if (!sc->sc_ah->curchan->paprd_done) - ieee80211_queue_work(sc->hw, &sc->paprd_work); - else -@@ -449,24 +478,6 @@ set_timer: - } - } - --static void ath_start_ani(struct ath_common *common) --{ -- struct ath_hw *ah = common->ah; -- unsigned long timestamp = jiffies_to_msecs(jiffies); -- struct ath_softc *sc = (struct ath_softc *) common->priv; -- -- if (!(sc->sc_flags & SC_OP_ANI_RUN)) -- return; -- -- common->ani.longcal_timer = timestamp; -- common->ani.shortcal_timer = timestamp; -- common->ani.checkani_timer = timestamp; -- -- mod_timer(&common->ani.timer, -- jiffies + -- msecs_to_jiffies((u32)ah->config.ani_poll_interval)); --} -- - /* - * Update tx/rx chainmask. For legacy association, - * hard code chainmask to 1x1, for 11n association, use -@@ -478,7 +489,7 @@ void ath_update_chainmask(struct ath_sof - struct ath_hw *ah = sc->sc_ah; - struct ath_common *common = ath9k_hw_common(ah); - -- if ((sc->sc_flags & SC_OP_SCANNING) || is_ht || -+ if ((sc->sc_flags & SC_OP_OFFCHANNEL) || is_ht || - (ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE)) { - common->tx_chainmask = ah->caps.tx_chainmask; - common->rx_chainmask = ah->caps.rx_chainmask; -@@ -1580,6 +1591,10 @@ static int ath9k_config(struct ieee80211 - - aphy->chan_idx = pos; - aphy->chan_is_ht = conf_is_ht(conf); -+ if (hw->conf.flags & IEEE80211_CONF_OFFCHANNEL) -+ sc->sc_flags |= SC_OP_OFFCHANNEL; -+ else -+ sc->sc_flags &= ~SC_OP_OFFCHANNEL; - - if (aphy->state == ATH_WIPHY_SCAN || - aphy->state == ATH_WIPHY_ACTIVE) -@@ -1991,7 +2006,6 @@ static void ath9k_sw_scan_start(struct i - { - struct ath_wiphy *aphy = hw->priv; - struct ath_softc *sc = aphy->sc; -- struct ath_common *common = ath9k_hw_common(sc->sc_ah); - - mutex_lock(&sc->mutex); - if (ath9k_wiphy_scanning(sc)) { -@@ -2007,11 +2021,6 @@ static void ath9k_sw_scan_start(struct i - - aphy->state = ATH_WIPHY_SCAN; - ath9k_wiphy_pause_all_forced(sc, aphy); -- sc->sc_flags |= SC_OP_SCANNING; -- del_timer_sync(&common->ani.timer); -- cancel_work_sync(&sc->paprd_work); -- cancel_work_sync(&sc->hw_check_work); -- cancel_delayed_work_sync(&sc->tx_complete_work); - mutex_unlock(&sc->mutex); - } - -@@ -2019,15 +2028,9 @@ static void ath9k_sw_scan_complete(struc - { - struct ath_wiphy *aphy = hw->priv; - struct ath_softc *sc = aphy->sc; -- struct ath_common *common = ath9k_hw_common(sc->sc_ah); - - mutex_lock(&sc->mutex); - aphy->state = ATH_WIPHY_ACTIVE; -- sc->sc_flags &= ~SC_OP_SCANNING; -- sc->sc_flags |= SC_OP_FULL_RESET; -- ath_start_ani(common); -- ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0); -- ath_beacon_config(sc, NULL); - mutex_unlock(&sc->mutex); - } - ---- a/drivers/net/wireless/ath/ath9k/recv.c -+++ b/drivers/net/wireless/ath/ath9k/recv.c -@@ -292,7 +292,7 @@ static void ath_edma_start_recv(struct a - - ath_opmode_init(sc); - -- ath9k_hw_startpcureceive(sc->sc_ah, (sc->sc_flags & SC_OP_SCANNING)); -+ ath9k_hw_startpcureceive(sc->sc_ah, (sc->sc_flags & SC_OP_OFFCHANNEL)); - } - - static void ath_edma_stop_recv(struct ath_softc *sc) -@@ -498,7 +498,7 @@ int ath_startrecv(struct ath_softc *sc) - start_recv: - spin_unlock_bh(&sc->rx.rxbuflock); - ath_opmode_init(sc); -- ath9k_hw_startpcureceive(ah, (sc->sc_flags & SC_OP_SCANNING)); -+ ath9k_hw_startpcureceive(ah, (sc->sc_flags & SC_OP_OFFCHANNEL)); - - return 0; - } diff --git a/package/mac80211/patches/523-ath9k_nfcal_timeout_handling.patch b/package/mac80211/patches/523-ath9k_nfcal_timeout_handling.patch deleted file mode 100644 index 9036360..0000000 --- a/package/mac80211/patches/523-ath9k_nfcal_timeout_handling.patch +++ /dev/null @@ -1,140 +0,0 @@ ---- a/drivers/net/wireless/ath/ath9k/hw.h -+++ b/drivers/net/wireless/ath/ath9k/hw.h -@@ -354,6 +354,7 @@ struct ath9k_hw_cal_data { - int8_t qCoff; - int16_t rawNoiseFloor; - bool paprd_done; -+ bool nfcal_pending; - u16 small_signal_gain[AR9300_MAX_CHAINS]; - u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; - struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; ---- a/drivers/net/wireless/ath/ath9k/calib.c -+++ b/drivers/net/wireless/ath/ath9k/calib.c -@@ -156,6 +156,9 @@ EXPORT_SYMBOL(ath9k_hw_reset_calvalid); - - void ath9k_hw_start_nfcal(struct ath_hw *ah) - { -+ if (ah->caldata) -+ ah->caldata->nfcal_pending = true; -+ - REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, - AR_PHY_AGC_CONTROL_ENABLE_NF); - REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, -@@ -282,8 +285,7 @@ static void ath9k_hw_nf_sanitize(struct - } - } - --int16_t ath9k_hw_getnf(struct ath_hw *ah, -- struct ath9k_channel *chan) -+bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan) - { - struct ath_common *common = ath9k_hw_common(ah); - int16_t nf, nfThresh; -@@ -293,7 +295,7 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah - struct ath9k_hw_cal_data *caldata = ah->caldata; - - if (!caldata) -- return ath9k_hw_get_default_nf(ah, chan); -+ return false; - - chan->channelFlags &= (~CHANNEL_CW_INT); - if (REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) { -@@ -301,7 +303,7 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah - "NF did not complete in calibration window\n"); - nf = 0; - caldata->rawNoiseFloor = nf; -- return caldata->rawNoiseFloor; -+ return false; - } else { - ath9k_hw_do_getnf(ah, nfarray); - ath9k_hw_nf_sanitize(ah, nfarray); -@@ -317,11 +319,10 @@ int16_t ath9k_hw_getnf(struct ath_hw *ah - } - - h = caldata->nfCalHist; -- -+ caldata->nfcal_pending = false; - ath9k_hw_update_nfcal_hist_buffer(h, nfarray); - caldata->rawNoiseFloor = h[0].privNF; -- -- return ah->caldata->rawNoiseFloor; -+ return true; - } - - void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah, ---- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c -+++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c -@@ -687,8 +687,13 @@ static bool ar9002_hw_calibrate(struct a - { - bool iscaldone = true; - struct ath9k_cal_list *currCal = ah->cal_list_curr; -+ bool nfcal, nfcal_pending = false; - -- if (currCal && -+ nfcal = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF); -+ if (ah->caldata) -+ nfcal_pending = ah->caldata->nfcal_pending; -+ -+ if (currCal && !nfcal && - (currCal->calState == CAL_RUNNING || - currCal->calState == CAL_WAITING)) { - iscaldone = ar9002_hw_per_calibration(ah, chan, -@@ -704,7 +709,7 @@ static bool ar9002_hw_calibrate(struct a - } - - /* Do NF cal only at longer intervals */ -- if (longcal) { -+ if (longcal || nfcal_pending) { - /* Do periodic PAOffset Cal */ - ar9002_hw_pa_cal(ah, false); - ar9002_hw_olc_temp_compensation(ah); -@@ -713,16 +718,18 @@ static bool ar9002_hw_calibrate(struct a - * Get the value from the previous NF cal and update - * history buffer. - */ -- ath9k_hw_getnf(ah, chan); -- -- /* -- * Load the NF from history buffer of the current channel. -- * NF is slow time-variant, so it is OK to use a historical -- * value. -- */ -- ath9k_hw_loadnf(ah, ah->curchan); -+ if (ath9k_hw_getnf(ah, chan)) { -+ /* -+ * Load the NF from history buffer of the current -+ * channel. -+ * NF is slow time-variant, so it is OK to use a -+ * historical value. -+ */ -+ ath9k_hw_loadnf(ah, ah->curchan); -+ } - -- ath9k_hw_start_nfcal(ah); -+ if (longcal) -+ ath9k_hw_start_nfcal(ah); - } - - return iscaldone; -@@ -873,6 +880,9 @@ static bool ar9002_hw_init_cal(struct at - REG_WRITE(ah, AR_PHY_AGC_CONTROL, - REG_READ(ah, AR_PHY_AGC_CONTROL) | AR_PHY_AGC_CONTROL_NF); - -+ if (ah->caldata) -+ ah->caldata->nfcal_pending = true; -+ - ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; - - /* Enable IQ, ADC Gain and ADC DC offset CALs */ ---- a/drivers/net/wireless/ath/ath9k/calib.h -+++ b/drivers/net/wireless/ath/ath9k/calib.h -@@ -110,8 +110,7 @@ struct ath9k_pacal_info{ - bool ath9k_hw_reset_calvalid(struct ath_hw *ah); - void ath9k_hw_start_nfcal(struct ath_hw *ah); - void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan); --int16_t ath9k_hw_getnf(struct ath_hw *ah, -- struct ath9k_channel *chan); -+bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan); - void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah, - struct ath9k_channel *chan); - s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan); |