kernel: add a recent upstream commit (post-3.3) to the ssb update patch, required...
[openwrt.git] / package / mac80211 / patches / 565-ath9k_fix_lockup.patch
1 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
3 @@ -104,6 +104,29 @@ static int ath_max_4ms_framelen[4][32] =
4  /* Aggregation logic */
5  /*********************/
6  
7 +static void ath_txq_lock(struct ath_softc *sc, struct ath_txq *txq)
8 +{
9 +       spin_lock_bh(&txq->axq_lock);
10 +}
11 +
12 +static void ath_txq_unlock(struct ath_softc *sc, struct ath_txq *txq)
13 +{
14 +       spin_unlock_bh(&txq->axq_lock);
15 +}
16 +
17 +static void ath_txq_unlock_complete(struct ath_softc *sc, struct ath_txq *txq)
18 +{
19 +       struct sk_buff_head q;
20 +       struct sk_buff *skb;
21 +
22 +       __skb_queue_head_init(&q);
23 +       skb_queue_splice_init(&txq->complete_q, &q);
24 +       spin_unlock_bh(&txq->axq_lock);
25 +
26 +       while ((skb = __skb_dequeue(&q)))
27 +               ieee80211_tx_status(sc->hw, skb);
28 +}
29 +
30  static void ath_tx_queue_tid(struct ath_txq *txq, struct ath_atx_tid *tid)
31  {
32         struct ath_atx_ac *ac = tid->ac;
33 @@ -130,7 +153,7 @@ static void ath_tx_resume_tid(struct ath
34  
35         WARN_ON(!tid->paused);
36  
37 -       spin_lock_bh(&txq->axq_lock);
38 +       ath_txq_lock(sc, txq);
39         tid->paused = false;
40  
41         if (skb_queue_empty(&tid->buf_q))
42 @@ -139,7 +162,7 @@ static void ath_tx_resume_tid(struct ath
43         ath_tx_queue_tid(txq, tid);
44         ath_txq_schedule(sc, txq);
45  unlock:
46 -       spin_unlock_bh(&txq->axq_lock);
47 +       ath_txq_unlock_complete(sc, txq);
48  }
49  
50  static struct ath_frame_info *get_frame_info(struct sk_buff *skb)
51 @@ -189,8 +212,11 @@ static void ath_tx_flush_tid(struct ath_
52                 tid->state &= ~AGGR_CLEANUP;
53         }
54  
55 -       if (sendbar)
56 +       if (sendbar) {
57 +               ath_txq_unlock(sc, txq);
58                 ath_send_bar(tid, tid->seq_start);
59 +               ath_txq_lock(sc, txq);
60 +       }
61  }
62  
63  static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid,
64 @@ -564,13 +590,6 @@ static void ath_tx_complete_aggr(struct 
65                 bf = bf_next;
66         }
67  
68 -       if (bar_index >= 0) {
69 -               u16 bar_seq = ATH_BA_INDEX2SEQ(seq_first, bar_index);
70 -               ath_send_bar(tid, ATH_BA_INDEX2SEQ(seq_first, bar_index + 1));
71 -               if (BAW_WITHIN(tid->seq_start, tid->baw_size, bar_seq))
72 -                       tid->bar_index = ATH_BA_INDEX(tid->seq_start, bar_seq);
73 -       }
74 -
75         /* prepend un-acked frames to the beginning of the pending frame queue */
76         if (!skb_queue_empty(&bf_pending)) {
77                 if (an->sleeping)
78 @@ -585,6 +604,17 @@ static void ath_tx_complete_aggr(struct 
79                 }
80         }
81  
82 +       if (bar_index >= 0) {
83 +               u16 bar_seq = ATH_BA_INDEX2SEQ(seq_first, bar_index);
84 +
85 +               if (BAW_WITHIN(tid->seq_start, tid->baw_size, bar_seq))
86 +                       tid->bar_index = ATH_BA_INDEX(tid->seq_start, bar_seq);
87 +
88 +               ath_txq_unlock(sc, txq);
89 +               ath_send_bar(tid, ATH_BA_INDEX2SEQ(seq_first, bar_index + 1));
90 +               ath_txq_lock(sc, txq);
91 +       }
92 +
93         if (tid->state & AGGR_CLEANUP)
94                 ath_tx_flush_tid(sc, tid);
95  
96 @@ -1183,7 +1213,7 @@ void ath_tx_aggr_stop(struct ath_softc *
97                 return;
98         }
99  
100 -       spin_lock_bh(&txq->axq_lock);
101 +       ath_txq_lock(sc, txq);
102         txtid->paused = true;
103  
104         /*
105 @@ -1198,7 +1228,7 @@ void ath_tx_aggr_stop(struct ath_softc *
106                 txtid->state &= ~AGGR_ADDBA_COMPLETE;
107  
108         ath_tx_flush_tid(sc, txtid);
109 -       spin_unlock_bh(&txq->axq_lock);
110 +       ath_txq_unlock_complete(sc, txq);
111  }
112  
113  void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc,
114 @@ -1219,7 +1249,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
115                 ac = tid->ac;
116                 txq = ac->txq;
117  
118 -               spin_lock_bh(&txq->axq_lock);
119 +               ath_txq_lock(sc, txq);
120  
121                 buffered = !skb_queue_empty(&tid->buf_q);
122  
123 @@ -1231,7 +1261,7 @@ void ath_tx_aggr_sleep(struct ieee80211_
124                         list_del(&ac->list);
125                 }
126  
127 -               spin_unlock_bh(&txq->axq_lock);
128 +               ath_txq_unlock(sc, txq);
129  
130                 ieee80211_sta_set_buffered(sta, tidno, buffered);
131         }
132 @@ -1250,7 +1280,7 @@ void ath_tx_aggr_wakeup(struct ath_softc
133                 ac = tid->ac;
134                 txq = ac->txq;
135  
136 -               spin_lock_bh(&txq->axq_lock);
137 +               ath_txq_lock(sc, txq);
138                 ac->clear_ps_filter = true;
139  
140                 if (!skb_queue_empty(&tid->buf_q) && !tid->paused) {
141 @@ -1258,7 +1288,7 @@ void ath_tx_aggr_wakeup(struct ath_softc
142                         ath_txq_schedule(sc, txq);
143                 }
144  
145 -               spin_unlock_bh(&txq->axq_lock);
146 +               ath_txq_unlock_complete(sc, txq);
147         }
148  }
149  
150 @@ -1358,6 +1388,7 @@ struct ath_txq *ath_txq_setup(struct ath
151                 txq->axq_qnum = axq_qnum;
152                 txq->mac80211_qnum = -1;
153                 txq->axq_link = NULL;
154 +               __skb_queue_head_init(&txq->complete_q);
155                 INIT_LIST_HEAD(&txq->axq_q);
156                 INIT_LIST_HEAD(&txq->axq_acq);
157                 spin_lock_init(&txq->axq_lock);
158 @@ -1482,7 +1513,8 @@ static void ath_drain_txq_list(struct at
159   */
160  void ath_draintxq(struct ath_softc *sc, struct ath_txq *txq, bool retry_tx)
161  {
162 -       spin_lock_bh(&txq->axq_lock);
163 +       ath_txq_lock(sc, txq);
164 +
165         if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
166                 int idx = txq->txq_tailidx;
167  
168 @@ -1503,7 +1535,7 @@ void ath_draintxq(struct ath_softc *sc, 
169         if ((sc->sc_flags & SC_OP_TXAGGR) && !retry_tx)
170                 ath_txq_drain_pending_buffers(sc, txq);
171  
172 -       spin_unlock_bh(&txq->axq_lock);
173 +       ath_txq_unlock_complete(sc, txq);
174  }
175  
176  bool ath_drain_all_txq(struct ath_softc *sc, bool retry_tx)
177 @@ -1947,7 +1979,7 @@ int ath_tx_start(struct ieee80211_hw *hw
178  
179         q = skb_get_queue_mapping(skb);
180  
181 -       spin_lock_bh(&txq->axq_lock);
182 +       ath_txq_lock(sc, txq);
183  
184         if (txq == sc->tx.txq_map[q] &&
185             ++txq->pending_frames > ATH_MAX_QDEPTH && !txq->stopped) {
186 @@ -1957,7 +1989,7 @@ int ath_tx_start(struct ieee80211_hw *hw
187  
188         ath_tx_start_dma(sc, skb, txctl, tid);
189  
190 -       spin_unlock_bh(&txq->axq_lock);
191 +       ath_txq_unlock(sc, txq);
192  
193         return 0;
194  }
195 @@ -1969,7 +2001,6 @@ int ath_tx_start(struct ieee80211_hw *hw
196  static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb,
197                             int tx_flags, struct ath_txq *txq)
198  {
199 -       struct ieee80211_hw *hw = sc->hw;
200         struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
201         struct ath_common *common = ath9k_hw_common(sc->sc_ah);
202         struct ieee80211_hdr * hdr = (struct ieee80211_hdr *)skb->data;
203 @@ -2013,7 +2044,7 @@ static void ath_tx_complete(struct ath_s
204                 }
205         }
206  
207 -       ieee80211_tx_status(hw, skb);
208 +       __skb_queue_tail(&txq->complete_q, skb);
209  }
210  
211  static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf,
212 @@ -2149,7 +2180,7 @@ static void ath_tx_processq(struct ath_s
213                 txq->axq_qnum, ath9k_hw_gettxbuf(sc->sc_ah, txq->axq_qnum),
214                 txq->axq_link);
215  
216 -       spin_lock_bh(&txq->axq_lock);
217 +       ath_txq_lock(sc, txq);
218         for (;;) {
219                 if (work_pending(&sc->hw_reset_work))
220                         break;
221 @@ -2208,7 +2239,7 @@ static void ath_tx_processq(struct ath_s
222  
223                 ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);
224         }
225 -       spin_unlock_bh(&txq->axq_lock);
226 +       ath_txq_unlock_complete(sc, txq);
227  }
228  
229  static void ath_tx_complete_poll_work(struct work_struct *work)
230 @@ -2225,17 +2256,17 @@ static void ath_tx_complete_poll_work(st
231         for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++)
232                 if (ATH_TXQ_SETUP(sc, i)) {
233                         txq = &sc->tx.txq[i];
234 -                       spin_lock_bh(&txq->axq_lock);
235 +                       ath_txq_lock(sc, txq);
236                         if (txq->axq_depth) {
237                                 if (txq->axq_tx_inprogress) {
238                                         needreset = true;
239 -                                       spin_unlock_bh(&txq->axq_lock);
240 +                                       ath_txq_unlock(sc, txq);
241                                         break;
242                                 } else {
243                                         txq->axq_tx_inprogress = true;
244                                 }
245                         }
246 -                       spin_unlock_bh(&txq->axq_lock);
247 +                       ath_txq_unlock_complete(sc, txq);
248                 }
249  
250         if (needreset) {
251 @@ -2293,10 +2324,10 @@ void ath_tx_edma_tasklet(struct ath_soft
252  
253                 txq = &sc->tx.txq[ts.qid];
254  
255 -               spin_lock_bh(&txq->axq_lock);
256 +               ath_txq_lock(sc, txq);
257  
258                 if (list_empty(&txq->txq_fifo[txq->txq_tailidx])) {
259 -                       spin_unlock_bh(&txq->axq_lock);
260 +                       ath_txq_unlock(sc, txq);
261                         return;
262                 }
263  
264 @@ -2322,7 +2353,7 @@ void ath_tx_edma_tasklet(struct ath_soft
265                 }
266  
267                 ath_tx_process_buffer(sc, txq, &ts, bf, &bf_head);
268 -               spin_unlock_bh(&txq->axq_lock);
269 +               ath_txq_unlock_complete(sc, txq);
270         }
271  }
272  
273 @@ -2460,7 +2491,7 @@ void ath_tx_node_cleanup(struct ath_soft
274                 ac = tid->ac;
275                 txq = ac->txq;
276  
277 -               spin_lock_bh(&txq->axq_lock);
278 +               ath_txq_lock(sc, txq);
279  
280                 if (tid->sched) {
281                         list_del(&tid->list);
282 @@ -2476,6 +2507,6 @@ void ath_tx_node_cleanup(struct ath_soft
283                 tid->state &= ~AGGR_ADDBA_COMPLETE;
284                 tid->state &= ~AGGR_CLEANUP;
285  
286 -               spin_unlock_bh(&txq->axq_lock);
287 +               ath_txq_unlock(sc, txq);
288         }
289  }
290 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
291 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
292 @@ -196,6 +196,7 @@ struct ath_txq {
293         u8 txq_headidx;
294         u8 txq_tailidx;
295         int pending_frames;
296 +       struct sk_buff_head complete_q;
297  };
298  
299  struct ath_atx_ac {