ath9k: merge a pending fix for powersave
[oweals/openwrt.git] / package / mac80211 / patches / 571-ath9k_reset_debug.patch
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;
4  
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]++
8  #else
9  #define TX_STAT_INC(q, c) do { } while (0)
10 +#define RESET_STAT_INC(sc, type) do { } while (0)
11  #endif
12  
13  #ifdef CONFIG_ATH9K_DEBUGFS
14 @@ -171,10 +173,21 @@ struct ath_rx_stats {
15         u8 rs_antenna;
16  };
17  
18 +enum ath_reset_type {
19 +       RESET_TYPE_BB_HANG,
20 +       RESET_TYPE_BB_WATCHDOG,
21 +       RESET_TYPE_FATAL_INT,
22 +       RESET_TYPE_TX_ERROR,
23 +       RESET_TYPE_TX_HANG,
24 +       RESET_TYPE_PLL_HANG,
25 +       __RESET_TYPE_MAX
26 +};
27 +
28  struct ath_stats {
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];
33  };
34  
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,16 @@ void ath9k_tasklet(unsigned long data)
39  
40         if ((status & ATH9K_INT_FATAL) ||
41             (status & ATH9K_INT_BB_WATCHDOG)) {
42 +#ifdef CONFIG_ATH9K_DEBUGFS
43 +               enum ath_reset_type type;
44 +
45 +               if (status & ATH9K_INT_FATAL)
46 +                       type = RESET_TYPE_FATAL_INT;
47 +               else
48 +                       type = RESET_TYPE_BB_WATCHDOG;
49 +
50 +               RESET_STAT_INC(sc, type);
51 +#endif
52                 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
53                 goto out;
54         }
55 @@ -995,8 +1005,10 @@ void ath_hw_check(struct work_struct *wo
56         ath_dbg(common, ATH_DBG_RESET, "Possible baseband hang, "
57                 "busy=%d (try %d)\n", busy, sc->hw_busy_count + 1);
58         if (busy >= 99) {
59 -               if (++sc->hw_busy_count >= 3)
60 +               if (++sc->hw_busy_count >= 3) {
61 +                       RESET_STAT_INC(sc, RESET_TYPE_BB_HANG);
62                         ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
63 +               }
64  
65         } else if (busy >= 0)
66                 sc->hw_busy_count = 0;
67 @@ -1016,6 +1028,7 @@ static void ath_hw_pll_rx_hang_check(str
68                         /* Rx is hung for more than 500ms. Reset it */
69                         ath_dbg(common, ATH_DBG_RESET,
70                                 "Possible RX hang, resetting");
71 +                       RESET_STAT_INC(sc, RESET_TYPE_PLL_HANG);
72                         ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
73                         count = 0;
74                 }
75 --- a/drivers/net/wireless/ath/ath9k/xmit.c
76 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
77 @@ -587,8 +587,10 @@ static void ath_tx_complete_aggr(struct 
78  
79         rcu_read_unlock();
80  
81 -       if (needreset)
82 +       if (needreset) {
83 +               RESET_STAT_INC(sc, RESET_TYPE_TX_ERROR);
84                 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
85 +       }
86  }
87  
88  static bool ath_lookup_legacy(struct ath_buf *bf)
89 @@ -2270,6 +2272,7 @@ static void ath_tx_complete_poll_work(st
90         if (needreset) {
91                 ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_RESET,
92                         "tx hung, resetting the chip\n");
93 +               RESET_STAT_INC(sc, RESET_TYPE_TX_HANG);
94                 ieee80211_queue_work(sc->hw, &sc->hw_reset_work);
95         }
96  
97 --- a/drivers/net/wireless/ath/ath9k/debug.c
98 +++ b/drivers/net/wireless/ath/ath9k/debug.c
99 @@ -523,9 +523,22 @@ static ssize_t read_file_wiphy(struct fi
100         if (tmp & ATH9K_RX_FILTER_PHYRADAR)
101                 len += snprintf(buf + len, sizeof(buf) - len, " PHYRADAR");
102         if (tmp & ATH9K_RX_FILTER_MCAST_BCAST_ALL)
103 -               len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL\n");
104 -       else
105 -               len += snprintf(buf + len, sizeof(buf) - len, "\n");
106 +               len += snprintf(buf + len, sizeof(buf) - len, " MCAST_BCAST_ALL");
107 +
108 +       len += snprintf(buf + len, sizeof(buf) - len,
109 +                      "\n\nReset causes:\n"
110 +                      "  baseband hang: %d\n"
111 +                      "  baseband watchdog: %d\n"
112 +                      "  fatal hardware error interrupt: %d\n"
113 +                      "  tx hardware error: %d\n"
114 +                      "  tx path hang: %d\n"
115 +                      "  pll rx hang: %d\n",
116 +                      sc->debug.stats.reset[RESET_TYPE_BB_HANG],
117 +                      sc->debug.stats.reset[RESET_TYPE_BB_WATCHDOG],
118 +                      sc->debug.stats.reset[RESET_TYPE_FATAL_INT],
119 +                      sc->debug.stats.reset[RESET_TYPE_TX_ERROR],
120 +                      sc->debug.stats.reset[RESET_TYPE_TX_HANG],
121 +                      sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
122  
123         if (len > sizeof(buf))
124                 len = sizeof(buf);