summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2014-06-11 11:28:58 +0000
committerFelix Fietkau <nbd@openwrt.org>2014-06-11 11:28:58 +0000
commitd373178835f665896f5c4534ecb89ae47911690b (patch)
treeadae9727f7e74ac8b34419aacbe4db4a3fde9780
parent3ab9651cb0e2464e165bb159603edf6e9eb5277e (diff)
downloadmtk-20170518-d373178835f665896f5c4534ecb89ae47911690b.zip
mtk-20170518-d373178835f665896f5c4534ecb89ae47911690b.tar.gz
mtk-20170518-d373178835f665896f5c4534ecb89ae47911690b.tar.bz2
ath9k: do a chip reset if noise floor calibration fails, should improve stability
Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 41113
-rw-r--r--package/kernel/mac80211/patches/564-ath9k_cleanup_reset_debug.patch60
-rw-r--r--package/kernel/mac80211/patches/565-ath9k_restart_after_nfcal_failure.patch172
2 files changed, 232 insertions, 0 deletions
diff --git a/package/kernel/mac80211/patches/564-ath9k_cleanup_reset_debug.patch b/package/kernel/mac80211/patches/564-ath9k_cleanup_reset_debug.patch
new file mode 100644
index 0000000..c636c5a
--- /dev/null
+++ b/package/kernel/mac80211/patches/564-ath9k_cleanup_reset_debug.patch
@@ -0,0 +1,60 @@
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -846,36 +846,30 @@ static ssize_t read_file_reset(struct fi
+ size_t count, loff_t *ppos)
+ {
+ struct ath_softc *sc = file->private_data;
++ static const char * const reset_cause[__RESET_TYPE_MAX] = {
++ [RESET_TYPE_BB_HANG] = "Baseband Hang",
++ [RESET_TYPE_BB_WATCHDOG] = "Baseband Watchdog",
++ [RESET_TYPE_FATAL_INT] = "Fatal HW Error",
++ [RESET_TYPE_TX_ERROR] = "TX HW error",
++ [RESET_TYPE_TX_GTT] = "Transmit timeout",
++ [RESET_TYPE_TX_HANG] = "TX Path Hang",
++ [RESET_TYPE_PLL_HANG] = "PLL RX Hang",
++ [RESET_TYPE_MAC_HANG] = "MAC Hang",
++ [RESET_TYPE_BEACON_STUCK] = "Stuck Beacon",
++ [RESET_TYPE_MCI] = "MCI Reset",
++ };
+ char buf[512];
+ unsigned int len = 0;
++ int i;
+
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "Baseband Hang",
+- sc->debug.stats.reset[RESET_TYPE_BB_HANG]);
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "Baseband Watchdog",
+- sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG]);
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "Fatal HW Error",
+- sc->debug.stats.reset[RESET_TYPE_FATAL_INT]);
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "TX HW error",
+- sc->debug.stats.reset[RESET_TYPE_TX_ERROR]);
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "TX Path Hang",
+- sc->debug.stats.reset[RESET_TYPE_TX_HANG]);
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "PLL RX Hang",
+- sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "MAC Hang",
+- sc->debug.stats.reset[RESET_TYPE_MAC_HANG]);
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "Stuck Beacon",
+- sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK]);
+- len += scnprintf(buf + len, sizeof(buf) - len,
+- "%17s: %2d\n", "MCI Reset",
+- sc->debug.stats.reset[RESET_TYPE_MCI]);
++ for (i = 0; i < ARRAY_SIZE(reset_cause); i++) {
++ if (!reset_cause[i])
++ continue;
++
++ len += scnprintf(buf + len, sizeof(buf) - len,
++ "%17s: %2d\n", reset_cause[i],
++ sc->debug.stats.reset[i]);
++ }
+
+ if (len > sizeof(buf))
+ len = sizeof(buf);
diff --git a/package/kernel/mac80211/patches/565-ath9k_restart_after_nfcal_failure.patch b/package/kernel/mac80211/patches/565-ath9k_restart_after_nfcal_failure.patch
new file mode 100644
index 0000000..366cc3c
--- /dev/null
+++ b/package/kernel/mac80211/patches/565-ath9k_restart_after_nfcal_failure.patch
@@ -0,0 +1,172 @@
+--- a/drivers/net/wireless/ath/ath9k/calib.c
++++ b/drivers/net/wireless/ath/ath9k/calib.c
+@@ -234,7 +234,7 @@ void ath9k_hw_start_nfcal(struct ath_hw
+ 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)
++int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
+ {
+ struct ath9k_nfcal_hist *h = NULL;
+ unsigned i, j;
+@@ -301,7 +301,7 @@ void ath9k_hw_loadnf(struct ath_hw *ah,
+ ath_dbg(common, ANY,
+ "Timeout while waiting for nf to load: AR_PHY_AGC_CONTROL=0x%x\n",
+ REG_READ(ah, AR_PHY_AGC_CONTROL));
+- return;
++ return -ETIMEDOUT;
+ }
+
+ /*
+@@ -322,6 +322,8 @@ void ath9k_hw_loadnf(struct ath_hw *ah,
+ }
+ }
+ REGWRITE_BUFFER_FLUSH(ah);
++
++ return 0;
+ }
+
+
+--- a/drivers/net/wireless/ath/ath9k/calib.h
++++ b/drivers/net/wireless/ath/ath9k/calib.h
+@@ -109,7 +109,7 @@ struct ath9k_pacal_info{
+
+ bool ath9k_hw_reset_calvalid(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);
++int ath9k_hw_loadnf(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);
+--- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c
++++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c
+@@ -657,14 +657,13 @@ static void ar9002_hw_olc_temp_compensat
+ ar9280_hw_olc_temp_compensation(ah);
+ }
+
+-static bool ar9002_hw_calibrate(struct ath_hw *ah,
+- struct ath9k_channel *chan,
+- u8 rxchainmask,
+- bool longcal)
++static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
++ u8 rxchainmask, bool longcal)
+ {
+ bool iscaldone = true;
+ struct ath9k_cal_list *currCal = ah->cal_list_curr;
+ bool nfcal, nfcal_pending = false;
++ int ret;
+
+ nfcal = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF);
+ if (ah->caldata)
+@@ -698,7 +697,9 @@ static bool ar9002_hw_calibrate(struct a
+ * NF is slow time-variant, so it is OK to use a
+ * historical value.
+ */
+- ath9k_hw_loadnf(ah, ah->curchan);
++ ret = ath9k_hw_loadnf(ah, ah->curchan);
++ if (ret < 0)
++ return ret;
+ }
+
+ if (longcal) {
+--- a/drivers/net/wireless/ath/ath9k/hw-ops.h
++++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
+@@ -41,10 +41,9 @@ static inline void ath9k_hw_set_desc_lin
+ ath9k_hw_ops(ah)->set_desc_link(ds, link);
+ }
+
+-static inline bool ath9k_hw_calibrate(struct ath_hw *ah,
+- struct ath9k_channel *chan,
+- u8 rxchainmask,
+- bool longcal)
++static inline int ath9k_hw_calibrate(struct ath_hw *ah,
++ struct ath9k_channel *chan,
++ u8 rxchainmask, bool longcal)
+ {
+ return ath9k_hw_ops(ah)->calibrate(ah, chan, rxchainmask, longcal);
+ }
+--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+@@ -121,13 +121,12 @@ static bool ar9003_hw_per_calibration(st
+ return iscaldone;
+ }
+
+-static bool ar9003_hw_calibrate(struct ath_hw *ah,
+- struct ath9k_channel *chan,
+- u8 rxchainmask,
+- bool longcal)
++static int ar9003_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan,
++ u8 rxchainmask, bool longcal)
+ {
+ bool iscaldone = true;
+ struct ath9k_cal_list *currCal = ah->cal_list_curr;
++ int ret;
+
+ /*
+ * For given calibration:
+@@ -163,7 +162,9 @@ static bool ar9003_hw_calibrate(struct a
+ * NF is slow time-variant, so it is OK to use a historical
+ * value.
+ */
+- ath9k_hw_loadnf(ah, ah->curchan);
++ ret = ath9k_hw_loadnf(ah, ah->curchan);
++ if (ret < 0)
++ return ret;
+
+ /* start NF calibration, without updating BB NF register */
+ ath9k_hw_start_nfcal(ah, false);
+--- a/drivers/net/wireless/ath/ath9k/hw.h
++++ b/drivers/net/wireless/ath/ath9k/hw.h
+@@ -695,10 +695,8 @@ struct ath_hw_ops {
+ bool power_off);
+ void (*rx_enable)(struct ath_hw *ah);
+ void (*set_desc_link)(void *ds, u32 link);
+- bool (*calibrate)(struct ath_hw *ah,
+- struct ath9k_channel *chan,
+- u8 rxchainmask,
+- bool longcal);
++ int (*calibrate)(struct ath_hw *ah, struct ath9k_channel *chan,
++ u8 rxchainmask, bool longcal);
+ bool (*get_isr)(struct ath_hw *ah, enum ath9k_int *masked,
+ u32 *sync_cause_p);
+ void (*set_txdesc)(struct ath_hw *ah, void *ds,
+--- a/drivers/net/wireless/ath/ath9k/debug.h
++++ b/drivers/net/wireless/ath/ath9k/debug.h
+@@ -49,6 +49,7 @@ enum ath_reset_type {
+ RESET_TYPE_MAC_HANG,
+ RESET_TYPE_BEACON_STUCK,
+ RESET_TYPE_MCI,
++ RESET_TYPE_CALIBRATION,
+ __RESET_TYPE_MAX
+ };
+
+--- a/drivers/net/wireless/ath/ath9k/debug.c
++++ b/drivers/net/wireless/ath/ath9k/debug.c
+@@ -857,6 +857,7 @@ static ssize_t read_file_reset(struct fi
+ [RESET_TYPE_MAC_HANG] = "MAC Hang",
+ [RESET_TYPE_BEACON_STUCK] = "Stuck Beacon",
+ [RESET_TYPE_MCI] = "MCI Reset",
++ [RESET_TYPE_CALIBRATION] = "Calibration error",
+ };
+ char buf[512];
+ unsigned int len = 0;
+--- a/drivers/net/wireless/ath/ath9k/link.c
++++ b/drivers/net/wireless/ath/ath9k/link.c
+@@ -376,9 +376,14 @@ void ath_ani_calibrate(unsigned long dat
+
+ /* Perform calibration if necessary */
+ if (longcal || shortcal) {
+- common->ani.caldone =
+- ath9k_hw_calibrate(ah, ah->curchan,
+- ah->rxchainmask, longcal);
++ int ret = ath9k_hw_calibrate(ah, ah->curchan, ah->rxchainmask,
++ longcal);
++ if (ret < 0) {
++ ath9k_queue_reset(sc, RESET_TYPE_CALIBRATION);
++ return;
++ }
++
++ common->ani.caldone = ret;
+ }
+
+ ath_dbg(common, ANI,