1 --- a/drivers/net/wireless/ath/ath9k/debug.h
2 +++ b/drivers/net/wireless/ath/ath9k/debug.h
3 @@ -25,8 +25,10 @@ struct ath_buf;
5 #ifdef CONFIG_ATH9K_DEBUGFS
6 #define TX_STAT_INC(q, c) sc->debug.stats.txstats[q].c++
7 +#define RESET_STAT_INC(sc, type) sc->debug.stats.reset[type]++
9 #define TX_STAT_INC(q, c) do { } while (0)
10 +#define RESET_STAT_INC(sc, type) do { } while (0)
13 #ifdef CONFIG_ATH9K_DEBUGFS
14 @@ -171,10 +173,21 @@ struct ath_rx_stats {
18 +enum ath_reset_type {
20 + RESET_TYPE_BB_WATCHDOG,
21 + RESET_TYPE_FATAL_INT,
22 + RESET_TYPE_TX_ERROR,
24 + RESET_TYPE_PLL_HANG,
29 struct ath_interrupt_stats istats;
30 struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES];
31 struct ath_rx_stats rxstats;
32 + u32 reset[__RESET_TYPE_MAX];
35 #define ATH_DBG_MAX_SAMPLES 10
36 --- a/drivers/net/wireless/ath/ath9k/main.c
37 +++ b/drivers/net/wireless/ath/ath9k/main.c
38 @@ -679,6 +679,14 @@ void ath9k_tasklet(unsigned long data)
40 if ((status & ATH9K_INT_FATAL) ||
41 (status & ATH9K_INT_BB_WATCHDOG)) {
42 + enum ath_reset_type type;
44 + if (status & ATH9K_INT_FATAL)
45 + type = RESET_TYPE_FATAL_INT;
47 + type = RESET_TYPE_BB_WATCHDOG;
49 + RESET_STAT_INC(sc, type);
50 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
53 @@ -995,8 +1003,10 @@ void ath_hw_check(struct work_struct *wo
54 ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
55 "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
57 - if (++sc->hw_busy_count >= 3)
58 + if (++sc->hw_busy_count >= 3) {
59 + RESET_STAT_INC(sc, RESET_TYPE_BB_HANG);
60 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
64 sc->hw_busy_count = 0;
65 @@ -1016,6 +1026,7 @@ static void ath_hw_pll_rx_hang_check(str
66 /* Rx is hung for more than 500ms. Reset it */
67 ath_dbg(common, ATH_DBG_RESET,
68 "Possible RX hang, resetting");
69 + RESET_STAT_INC(sc, RESET_TYPE_PLL_HANG);
70 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
73 --- a/drivers/net/wireless/ath/ath9k/xmit.c
74 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
75 @@ -587,8 +587,10 @@ static void ath_tx_complete_aggr(struct
81 + RESET_STAT_INC(sc, RESET_TYPE_TX_ERROR);
82 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
86 static bool ath_lookup_legacy(struct ath_buf *bf)
87 @@ -2270,6 +2272,7 @@ static void ath_tx_complete_poll_work(st
89 ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
90 "tx hung, resetting the chip\n");
91 + RESET_STAT_INC(sc, RESET_TYPE_TX_HANG);
92 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
95 --- a/drivers/net/wireless/ath/ath9k/debug.c
96 +++ b/drivers/net/wireless/ath/ath9k/debug.c
97 @@ -523,9 +523,22 @@ static ssize_t read_file_wiphy(struct fi
98 if (tmp & ATH9K_RX_FILTER_PHYRADAR)
99 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
100 if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
101 - len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n");
103 - len += snprintf(buf + len, sizeof(buf) - len, "\n");
104 + len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL");
106 + len += snprintf(buf + len, sizeof(buf) - len,
107 + "\n\nReset causes:\n"
108 + " baseband hang: %d\n"
109 + " baseband watchdog: %d\n"
110 + " fatal hardware error interrupt: %d\n"
111 + " tx hardware error: %d\n"
112 + " tx path hang: %d\n"
113 + " pll rx hang: %d\n",
114 + sc->debug.stats.reset[RESET_TYPE_BB_HANG],
115 + sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG],
116 + sc->debug.stats.reset[RESET_TYPE_FATAL_INT],
117 + sc->debug.stats.reset[RESET_TYPE_TX_ERROR],
118 + sc->debug.stats.reset[RESET_TYPE_TX_HANG],
119 + sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
121 if (len > sizeof(buf))