huge madwifi update - use a madwifi-ng-refcount snapshot as base, includes lots of...
[openwrt/svn-archive/archive.git] / package / madwifi / patches / 300-napi_polling.patch
1 diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c madwifi-ng-refcount-r2313-20070505.dev/ath/if_ath.c
2 --- madwifi-ng-refcount-r2313-20070505.old/ath/if_ath.c 2007-05-13 18:17:56.576968032 +0200
3 +++ madwifi-ng-refcount-r2313-20070505.dev/ath/if_ath.c 2007-05-13 18:17:56.594965296 +0200
4 @@ -170,7 +170,7 @@
5 int, u_int32_t);
6 static void ath_setdefantenna(struct ath_softc *, u_int);
7 static struct ath_txq *ath_txq_setup(struct ath_softc *, int, int);
8 -static void ath_rx_tasklet(TQUEUE_ARG);
9 +static int ath_rx_poll(struct net_device *dev, int *budget);
10 static int ath_hardstart(struct sk_buff *, struct net_device *);
11 static int ath_mgtstart(struct ieee80211com *, struct sk_buff *);
12 #ifdef ATH_SUPERG_COMP
13 @@ -420,7 +420,6 @@
14 ATH_TXBUF_LOCK_INIT(sc);
15 ATH_RXBUF_LOCK_INIT(sc);
16
17 - ATH_INIT_TQUEUE(&sc->sc_rxtq, ath_rx_tasklet, dev);
18 ATH_INIT_TQUEUE(&sc->sc_txtq, ath_tx_tasklet, dev);
19 ATH_INIT_TQUEUE(&sc->sc_bmisstq, ath_bmiss_tasklet, dev);
20 ATH_INIT_TQUEUE(&sc->sc_bstucktq, ath_bstuck_tasklet, dev);
21 @@ -674,6 +673,8 @@
22 dev->set_mac_address = ath_set_mac_address;
23 dev->change_mtu = ath_change_mtu;
24 dev->tx_queue_len = ATH_TXBUF - 1; /* 1 for mgmt frame */
25 + dev->poll = ath_rx_poll;
26 + dev->weight = 64;
27 #ifdef USE_HEADERLEN_RESV
28 dev->hard_header_len += sizeof(struct ieee80211_qosframe) +
29 sizeof(struct llc) +
30 @@ -1645,6 +1646,7 @@
31 */
32 ath_hal_getisr(ah, &status); /* NB: clears ISR too */
33 DPRINTF(sc, ATH_DEBUG_INTR, "%s: status 0x%x\n", __func__, status);
34 + sc->sc_isr = status;
35 status &= sc->sc_imask; /* discard unasked for bits */
36 if (status & HAL_INT_FATAL) {
37 sc->sc_stats.ast_hardware++;
38 @@ -1684,7 +1686,12 @@
39 * might take too long to fire */
40 ath_hal_process_noisefloor(ah);
41 sc->sc_channoise = ath_hal_get_channel_noise(ah, &(sc->sc_curchan));
42 - ATH_SCHEDULE_TQUEUE(&sc->sc_rxtq, &needmark);
43 + sc->sc_isr &= ~HAL_INT_RX;
44 + if (netif_rx_schedule_prep(dev)) {
45 + sc->sc_imask &= ~HAL_INT_RX;
46 + ath_hal_intrset(ah, sc->sc_imask);
47 + __netif_rx_schedule(dev);
48 + }
49 }
50 if (status & HAL_INT_TX) {
51 #ifdef ATH_SUPERG_DYNTURBO
52 @@ -1710,6 +1717,11 @@
53 }
54 }
55 #endif
56 + /* disable transmit interrupt */
57 + sc->sc_isr &= ~HAL_INT_TX;
58 + ath_hal_intrset(ah, sc->sc_imask & ~HAL_INT_TX);
59 + sc->sc_imask &= ~HAL_INT_TX;
60 +
61 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, &needmark);
62 sc->sc_tx_start = 0;
63 }
64 @@ -2221,12 +2233,13 @@
65 * Insert the frame on the outbound list and
66 * pass it on to the hardware.
67 */
68 - ATH_TXQ_LOCK(txq);
69 + ATH_TXQ_LOCK_BH(txq);
70 if (ni && ni->ni_vap && txq == &ATH_VAP(ni->ni_vap)->av_mcastq) {
71 /*
72 * The CAB queue is started from the SWBA handler since
73 * frames only go out on DTIM and to avoid possible races.
74 */
75 + sc->sc_imask &= ~HAL_INT_SWBA;
76 ath_hal_intrset(ah, sc->sc_imask & ~HAL_INT_SWBA);
77 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
78 DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: txq depth = %d\n", __func__, txq->axq_depth);
79 @@ -2242,6 +2255,7 @@
80 ito64(bf->bf_daddr), bf->bf_desc);
81 }
82 txq->axq_link = &lastds->ds_link;
83 + sc->sc_imask |= HAL_INT_SWBA;
84 ath_hal_intrset(ah, sc->sc_imask);
85 } else {
86 ATH_TXQ_INSERT_TAIL(txq, bf, bf_list);
87 @@ -2275,7 +2289,7 @@
88 sc->sc_tx_start = jiffies;
89 }
90 }
91 - ATH_TXQ_UNLOCK(txq);
92 + ATH_TXQ_UNLOCK_BH(txq);
93
94 sc->sc_devstats.tx_packets++;
95 sc->sc_devstats.tx_bytes += framelen;
96 @@ -2426,8 +2440,14 @@
97 unsigned int pktlen;
98 int framecnt;
99
100 + /*
101 + * NB: using _BH style locking even though this function may be called
102 + * at interrupt time (within tasklet or bh). This should be harmless
103 + * and this function calls others (i.e., ath_tx_start()) which do
104 + * the same.
105 + */
106 for (;;) {
107 - ATH_TXQ_LOCK(txq);
108 + ATH_TXQ_LOCK_BH(txq);
109
110 bf_ff = TAILQ_LAST(&txq->axq_stageq, axq_headtype);
111 if ((!bf_ff) || ath_ff_flushdonetest(txq, bf_ff)) {
112 @@ -2441,7 +2461,7 @@
113 ATH_NODE(ni)->an_tx_ffbuf[bf_ff->bf_skb->priority] = NULL;
114 TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist);
115
116 - ATH_TXQ_UNLOCK(txq);
117 + ATH_TXQ_UNLOCK_BH(txq);
118
119 /* encap and xmit */
120 bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt);
121 @@ -2462,15 +2482,16 @@
122 }
123 bf_ff->bf_node = NULL;
124
125 - ATH_TXBUF_LOCK_IRQ(sc);
126 + ATH_TXBUF_LOCK_BH(sc);
127 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf_ff, bf_list);
128 - ATH_TXBUF_UNLOCK_IRQ(sc);
129 + ATH_TXBUF_UNLOCK_BH(sc);
130 }
131 + ATH_TXQ_UNLOCK_BH(txq);
132 }
133 #endif
134
135 #define ATH_HARDSTART_GET_TX_BUF_WITH_LOCK \
136 - ATH_TXBUF_LOCK_IRQ(sc); \
137 + ATH_TXBUF_LOCK_BH(sc); \
138 bf = STAILQ_FIRST(&sc->sc_txbuf); \
139 if (bf != NULL) { \
140 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list); \
141 @@ -2485,10 +2506,21 @@
142 sc->sc_devstopped = 1; \
143 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, NULL); \
144 } \
145 - ATH_TXBUF_UNLOCK_IRQ(sc); \
146 +
147 +#define ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF \
148 + ATH_TXBUF_UNLOCK_BH(sc); \
149 + if (bf == NULL) { /* NB: should not happen */ \
150 + DPRINTF(sc,ATH_DEBUG_XMIT,"%s: discard, no xmit buf\n", __func__); \
151 + sc->sc_stats.ast_tx_nobuf++; \
152 + goto hardstart_fail; \
153 + }
154 +
155 +#define ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_ON \
156 + ATH_TXBUF_UNLOCK_BH(sc); \
157 if (bf == NULL) { /* NB: should not happen */ \
158 DPRINTF(sc,ATH_DEBUG_XMIT, \
159 "%s: discard, no xmit buf\n", __func__); \
160 + ATH_TXQ_UNLOCK_BH(txq); \
161 sc->sc_stats.ast_tx_nobuf++; \
162 goto hardstart_fail; \
163 }
164 @@ -2552,6 +2584,7 @@
165 if (M_FLAG_GET(skb, M_UAPSD)) {
166 /* bypass FF handling */
167 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
168 + ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF;
169 if (bf == NULL)
170 goto hardstart_fail;
171 goto ff_bypass;
172 @@ -2573,7 +2606,7 @@
173 /* NB: use this lock to protect an->an_ff_txbuf in athff_can_aggregate()
174 * call too.
175 */
176 - ATH_TXQ_LOCK(txq);
177 + ATH_TXQ_LOCK_BH(txq);
178 if (athff_can_aggregate(sc, eh, an, skb, vap->iv_fragthreshold, &ff_flush)) {
179
180 if (an->an_tx_ffbuf[skb->priority]) { /* i.e., frame on the staging queue */
181 @@ -2583,7 +2616,7 @@
182 TAILQ_REMOVE(&txq->axq_stageq, bf, bf_stagelist);
183 an->an_tx_ffbuf[skb->priority] = NULL;
184
185 - ATH_TXQ_UNLOCK(txq);
186 + ATH_TXQ_UNLOCK_BH(txq);
187
188 /*
189 * chain skbs and add FF magic
190 @@ -2610,6 +2643,7 @@
191 * to give the buffer back.
192 */
193 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
194 + ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_ON;
195 if (bf == NULL) {
196 ATH_TXQ_UNLOCK(txq);
197 goto hardstart_fail;
198 @@ -2624,7 +2658,7 @@
199
200 TAILQ_INSERT_HEAD(&txq->axq_stageq, bf, bf_stagelist);
201
202 - ATH_TXQ_UNLOCK(txq);
203 + ATH_TXQ_UNLOCK_BH(txq);
204
205 return 0;
206 }
207 @@ -2635,7 +2669,7 @@
208 TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist);
209 an->an_tx_ffbuf[skb->priority] = NULL;
210
211 - ATH_TXQ_UNLOCK(txq);
212 + ATH_TXQ_UNLOCK_BH(txq);
213
214 /* encap and xmit */
215 bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt);
216 @@ -2665,9 +2699,9 @@
217 }
218 bf_ff->bf_node = NULL;
219
220 - ATH_TXBUF_LOCK(sc);
221 + ATH_TXBUF_LOCK_BH(sc);
222 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf_ff, bf_list);
223 - ATH_TXBUF_UNLOCK(sc);
224 + ATH_TXBUF_UNLOCK_BH(sc);
225 goto ff_flushdone;
226 }
227 /*
228 @@ -2691,6 +2725,7 @@
229 #else /* ATH_SUPERG_FF */
230
231 ATH_HARDSTART_GET_TX_BUF_WITH_LOCK;
232 + ATH_HARDSTART_REL_TX_BUF_WITH_TXQLOCK_OFF;
233
234 #endif /* ATH_SUPERG_FF */
235
236 @@ -2712,7 +2747,7 @@
237 * Allocate 1 ath_buf for each frame given 1 was
238 * already alloc'd
239 */
240 - ATH_TXBUF_LOCK(sc);
241 + ATH_TXBUF_LOCK_BH(sc);
242 for (bfcnt = 1; bfcnt < framecnt; ++bfcnt) {
243 if ((tbf = STAILQ_FIRST(&sc->sc_txbuf)) != NULL) {
244 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list);
245 @@ -2733,11 +2768,11 @@
246 STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list);
247 }
248 }
249 - ATH_TXBUF_UNLOCK(sc);
250 + ATH_TXBUF_UNLOCK_BH(sc);
251 STAILQ_INIT(&bf_head);
252 goto hardstart_fail;
253 }
254 - ATH_TXBUF_UNLOCK(sc);
255 + ATH_TXBUF_UNLOCK_BH(sc);
256
257 while ((bf = STAILQ_FIRST(&bf_head)) != NULL && skb != NULL) {
258 unsigned int nextfraglen = 0;
259 @@ -2773,7 +2808,7 @@
260
261 hardstart_fail:
262 if (!STAILQ_EMPTY(&bf_head)) {
263 - ATH_TXBUF_LOCK(sc);
264 + ATH_TXBUF_LOCK_BH(sc);
265 STAILQ_FOREACH_SAFE(tbf, &bf_head, bf_list, tempbf) {
266 tbf->bf_skb = NULL;
267 tbf->bf_node = NULL;
268 @@ -2783,7 +2818,7 @@
269
270 STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list);
271 }
272 - ATH_TXBUF_UNLOCK(sc);
273 + ATH_TXBUF_UNLOCK_BH(sc);
274 }
275
276 /* free sk_buffs */
277 @@ -2826,7 +2861,7 @@
278 /*
279 * Grab a TX buffer and associated resources.
280 */
281 - ATH_TXBUF_LOCK_IRQ(sc);
282 + ATH_TXBUF_LOCK_BH(sc);
283 bf = STAILQ_FIRST(&sc->sc_txbuf);
284 if (bf != NULL)
285 STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list);
286 @@ -2837,7 +2872,7 @@
287 sc->sc_devstopped=1;
288 ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, NULL);
289 }
290 - ATH_TXBUF_UNLOCK_IRQ(sc);
291 + ATH_TXBUF_UNLOCK_BH(sc);
292 if (bf == NULL) {
293 printk("ath_mgtstart: discard, no xmit buf\n");
294 sc->sc_stats.ast_tx_nobufmgt++;
295 @@ -2866,9 +2901,9 @@
296 bf->bf_skb = NULL;
297 bf->bf_node = NULL;
298
299 - ATH_TXBUF_LOCK_IRQ(sc);
300 + ATH_TXBUF_LOCK_BH(sc);
301 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);
302 - ATH_TXBUF_UNLOCK_IRQ(sc);
303 + ATH_TXBUF_UNLOCK_BH(sc);
304 }
305 dev_kfree_skb_any(skb);
306 skb = NULL;
307 @@ -3336,10 +3371,10 @@
308 *
309 * XXX Using in_softirq is not right since we might
310 * be called from other soft irq contexts than
311 - * ath_rx_tasklet.
312 + * ath_rx_poll
313 */
314 if (!in_softirq())
315 - tasklet_disable(&sc->sc_rxtq);
316 + netif_poll_disable(dev);
317 netif_stop_queue(dev);
318 }
319
320 @@ -3352,7 +3387,7 @@
321 DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__);
322 netif_start_queue(dev);
323 if (!in_softirq()) /* NB: see above */
324 - tasklet_enable(&sc->sc_rxtq);
325 + netif_poll_enable(dev);
326 }
327
328 /*
329 @@ -4912,9 +4947,9 @@
330 bf->bf_node = NULL;
331 bf->bf_desc->ds_link = 0;
332
333 - ATH_TXBUF_LOCK_IRQ(sc);
334 + ATH_TXBUF_LOCK_BH(sc);
335 STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list);
336 - ATH_TXBUF_UNLOCK_IRQ(sc);
337 + ATH_TXBUF_UNLOCK_BH(sc);
338
339 an->an_uapsd_overflowqdepth--;
340 }
341 @@ -5585,13 +5620,12 @@
342 sc->sc_rxotherant = 0;
343 }
344
345 -static void
346 -ath_rx_tasklet(TQUEUE_ARG data)
347 +static int
348 +ath_rx_poll(struct net_device *dev, int *budget)
349 {
350 #define PA2DESC(_sc, _pa) \
351 ((struct ath_desc *)((caddr_t)(_sc)->sc_rxdma.dd_desc + \
352 ((_pa) - (_sc)->sc_rxdma.dd_desc_paddr)))
353 - struct net_device *dev = (struct net_device *)data;
354 struct ath_buf *bf;
355 struct ath_softc *sc = dev->priv;
356 struct ieee80211com *ic = &sc->sc_ic;
357 @@ -5602,11 +5636,15 @@
358 unsigned int len;
359 int type;
360 u_int phyerr;
361 + int processed = 0, early_stop = 0;
362 + int rx_limit = dev->quota;
363
364 /* Let the 802.11 layer know about the new noise floor */
365 ic->ic_channoise = sc->sc_channoise;
366
367 DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s\n", __func__);
368 +
369 +process_rx_again:
370 do {
371 bf = STAILQ_FIRST(&sc->sc_rxbuf);
372 if (bf == NULL) { /* XXX ??? can this happen */
373 @@ -5630,6 +5668,13 @@
374 /* NB: never process the self-linked entry at the end */
375 break;
376 }
377 +
378 + processed++;
379 + if (rx_limit-- < 0) {
380 + early_stop = 1;
381 + break;
382 + }
383 +
384 skb = bf->bf_skb;
385 if (skb == NULL) { /* XXX ??? can this happen */
386 printk("%s: no skbuff (%s)\n", dev->name, __func__);
387 @@ -5878,6 +5923,25 @@
388 STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list);
389 ATH_RXBUF_UNLOCK_IRQ(sc);
390 } while (ath_rxbuf_init(sc, bf) == 0);
391 + if (!early_stop) {
392 + /* Check if more data is received while we were
393 + * processing the descriptor chain.
394 + */
395 + ATH_DISABLE_INTR();
396 + if (sc->sc_isr & HAL_INT_RX) {
397 + sc->sc_isr &= ~HAL_INT_RX;
398 + ATH_ENABLE_INTR();
399 + ath_uapsd_processtriggers(sc);
400 + goto process_rx_again;
401 + }
402 + netif_rx_complete(dev);
403 +
404 + sc->sc_imask |= HAL_INT_RX;
405 + ath_hal_intrset(ah, sc->sc_imask);
406 + ATH_ENABLE_INTR();
407 + }
408 +
409 + *budget -= processed;
410
411 /* rx signal state monitoring */
412 ath_hal_rxmonitor(ah, &sc->sc_halstats, &sc->sc_curchan);
413 @@ -5885,6 +5949,7 @@
414 sc->sc_rtasksched = 1;
415 schedule_work(&sc->sc_radartask);
416 }
417 + return early_stop;
418 #undef PA2DESC
419 }
420
421 @@ -6160,22 +6225,22 @@
422 }
423 }
424
425 - ATH_TXBUF_LOCK_IRQ(sc);
426 + ATH_TXBUF_LOCK_BH(sc);
427 bf = STAILQ_FIRST(&sc->sc_grppollbuf);
428 if (bf != NULL)
429 STAILQ_REMOVE_HEAD(&sc->sc_grppollbuf, bf_list);
430 else {
431 DPRINTF(sc, ATH_DEBUG_XMIT, "%s: No more TxBufs\n", __func__);
432 - ATH_TXBUF_UNLOCK_IRQ_EARLY(sc);
433 + ATH_TXBUF_UNLOCK_BH(sc);
434 return;
435 }
436 /* XXX use a counter and leave at least one for mgmt frames */
437 if (STAILQ_EMPTY(&sc->sc_grppollbuf)) {
438 DPRINTF(sc, ATH_DEBUG_XMIT, "%s: No more TxBufs left\n", __func__);
439 - ATH_TXBUF_UNLOCK_IRQ_EARLY(sc);
440 + ATH_TXBUF_UNLOCK_BH(sc);
441 return;
442 }
443 - ATH_TXBUF_UNLOCK_IRQ(sc);
444 + ATH_TXBUF_UNLOCK_BH(sc);
445
446 bf->bf_skbaddr = bus_map_single(sc->sc_bdev,
447 skb->data, skb->len, BUS_DMA_TODEVICE);
448 @@ -6641,9 +6706,9 @@
449 dev_kfree_skb(lastbuf->bf_skb);
450 lastbuf->bf_skb = NULL;
451 ieee80211_unref_node(&lastbuf->bf_node);
452 - ATH_TXBUF_LOCK_IRQ(sc);
453 + ATH_TXBUF_LOCK_BH(sc);
454 STAILQ_INSERT_TAIL(&sc->sc_txbuf, lastbuf, bf_list);
455 - ATH_TXBUF_UNLOCK_IRQ(sc);
456 + ATH_TXBUF_UNLOCK_BH(sc);
457
458 /*
459 * move oldest from overflow to delivery
460 @@ -7462,9 +7527,6 @@
461 if (sc->sc_reapcount > ATH_TXBUF_FREE_THRESHOLD) {
462 if (!sc->sc_dfswait)
463 netif_start_queue(sc->sc_dev);
464 - DPRINTF(sc, ATH_DEBUG_TX_PROC,
465 - "%s: tx tasklet restart the queue\n",
466 - __func__);
467 sc->sc_reapcount = 0;
468 sc->sc_devstopped = 0;
469 } else
470 @@ -7499,11 +7561,22 @@
471 struct net_device *dev = (struct net_device *)data;
472 struct ath_softc *sc = dev->priv;
473
474 +process_tx_again:
475 if (txqactive(sc->sc_ah, 0))
476 ath_tx_processq(sc, &sc->sc_txq[0]);
477 if (txqactive(sc->sc_ah, sc->sc_cabq->axq_qnum))
478 ath_tx_processq(sc, sc->sc_cabq);
479
480 + ATH_DISABLE_INTR();
481 + if (sc->sc_isr & HAL_INT_TX) {
482 + sc->sc_isr &= ~HAL_INT_TX;
483 + ATH_ENABLE_INTR();
484 + goto process_tx_again;
485 + }
486 + sc->sc_imask |= HAL_INT_TX;
487 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
488 + ATH_ENABLE_INTR();
489 +
490 netif_wake_queue(dev);
491
492 if (sc->sc_softled)
493 @@ -7520,6 +7593,7 @@
494 struct net_device *dev = (struct net_device *)data;
495 struct ath_softc *sc = dev->priv;
496
497 +process_tx_again:
498 /*
499 * Process each active queue.
500 */
501 @@ -7540,6 +7614,16 @@
502 if (sc->sc_uapsdq && txqactive(sc->sc_ah, sc->sc_uapsdq->axq_qnum))
503 ath_tx_processq(sc, sc->sc_uapsdq);
504
505 + ATH_DISABLE_INTR();
506 + if (sc->sc_isr & HAL_INT_TX) {
507 + sc->sc_isr &= ~HAL_INT_TX;
508 + ATH_ENABLE_INTR();
509 + goto process_tx_again;
510 + }
511 + sc->sc_imask |= HAL_INT_TX;
512 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
513 + ATH_ENABLE_INTR();
514 +
515 netif_wake_queue(dev);
516
517 if (sc->sc_softled)
518 @@ -7557,6 +7641,7 @@
519 unsigned int i;
520
521 /* Process each active queue. */
522 +process_tx_again:
523 for (i = 0; i < HAL_NUM_TX_QUEUES; i++)
524 if (ATH_TXQ_SETUP(sc, i) && txqactive(sc->sc_ah, i))
525 ath_tx_processq(sc, &sc->sc_txq[i]);
526 @@ -7565,6 +7650,16 @@
527 ath_tx_processq(sc, sc->sc_xrtxq);
528 #endif
529
530 + ATH_DISABLE_INTR();
531 + if (sc->sc_isr & HAL_INT_TX) {
532 + sc->sc_isr &= ~HAL_INT_TX;
533 + ATH_ENABLE_INTR();
534 + goto process_tx_again;
535 + }
536 + sc->sc_imask |= HAL_INT_TX;
537 + ath_hal_intrset(sc->sc_ah, sc->sc_imask);
538 + ATH_ENABLE_INTR();
539 +
540 netif_wake_queue(dev);
541
542 if (sc->sc_softled)
543 @@ -9221,9 +9316,9 @@
544 dev->mtu = mtu;
545 if ((dev->flags & IFF_RUNNING) && !sc->sc_invalid) {
546 /* NB: the rx buffers may need to be reallocated */
547 - tasklet_disable(&sc->sc_rxtq);
548 + netif_poll_disable(dev);
549 error = ath_reset(dev);
550 - tasklet_enable(&sc->sc_rxtq);
551 + netif_poll_enable(dev);
552 }
553 ATH_UNLOCK(sc);
554
555 diff -urN madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h madwifi-ng-refcount-r2313-20070505.dev/ath/if_athvar.h
556 --- madwifi-ng-refcount-r2313-20070505.old/ath/if_athvar.h 2007-05-13 18:17:56.363000560 +0200
557 +++ madwifi-ng-refcount-r2313-20070505.dev/ath/if_athvar.h 2007-05-13 18:17:56.595965144 +0200
558 @@ -47,6 +47,10 @@
559 #include "if_athioctl.h"
560 #include "net80211/ieee80211.h" /* XXX for WME_NUM_AC */
561
562 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
563 +#define irqs_disabled() 0
564 +#endif
565 +
566 /*
567 * Deduce if tasklets are available. If not then
568 * fall back to using the immediate work queue.
569 @@ -477,8 +481,12 @@
570 #define ATH_TXQ_LOCK_DESTROY(_tq)
571 #define ATH_TXQ_LOCK(_tq) spin_lock(&(_tq)->axq_lock)
572 #define ATH_TXQ_UNLOCK(_tq) spin_unlock(&(_tq)->axq_lock)
573 -#define ATH_TXQ_LOCK_BH(_tq) spin_lock_bh(&(_tq)->axq_lock)
574 -#define ATH_TXQ_UNLOCK_BH(_tq) spin_unlock_bh(&(_tq)->axq_lock)
575 +#define ATH_TXQ_LOCK_BH(_tq) \
576 + if (!irqs_disabled()) \
577 + spin_lock_bh(&(_tq)->axq_lock)
578 +#define ATH_TXQ_UNLOCK_BH(_tq) \
579 + if (!irqs_disabled()) \
580 + spin_unlock_bh(&(_tq)->axq_lock)
581 #define ATH_TXQ_LOCK_IRQ(_tq) do { \
582 unsigned long __axq_lockflags; \
583 spin_lock_irqsave(&(_tq)->axq_lock, __axq_lockflags);
584 @@ -627,7 +635,6 @@
585 struct ath_buf *sc_rxbufcur; /* current rx buffer */
586 u_int32_t *sc_rxlink; /* link ptr in last RX desc */
587 spinlock_t sc_rxbuflock;
588 - struct ATH_TQ_STRUCT sc_rxtq; /* rx intr tasklet */
589 struct ATH_TQ_STRUCT sc_rxorntq; /* rxorn intr tasklet */
590 u_int8_t sc_defant; /* current default antenna */
591 u_int8_t sc_rxotherant; /* rx's on non-default antenna*/
592 @@ -640,6 +647,7 @@
593 u_int sc_txintrperiod; /* tx interrupt batching */
594 struct ath_txq sc_txq[HAL_NUM_TX_QUEUES];
595 struct ath_txq *sc_ac2q[WME_NUM_AC]; /* WME AC -> h/w qnum */
596 + HAL_INT sc_isr; /* unmasked ISR state */
597 struct ATH_TQ_STRUCT sc_txtq; /* tx intr tasklet */
598 u_int8_t sc_grppoll_str[GRPPOLL_RATE_STR_LEN];
599 struct ath_descdma sc_bdma; /* beacon descriptors */
600 @@ -706,8 +714,12 @@
601 #define ATH_TXBUF_LOCK_DESTROY(_sc)
602 #define ATH_TXBUF_LOCK(_sc) spin_lock(&(_sc)->sc_txbuflock)
603 #define ATH_TXBUF_UNLOCK(_sc) spin_unlock(&(_sc)->sc_txbuflock)
604 -#define ATH_TXBUF_LOCK_BH(_sc) spin_lock_bh(&(_sc)->sc_txbuflock)
605 -#define ATH_TXBUF_UNLOCK_BH(_sc) spin_unlock_bh(&(_sc)->sc_txbuflock)
606 +#define ATH_TXBUF_LOCK_BH(_sc) \
607 + if (!irqs_disabled()) \
608 + spin_lock_bh(&(_sc)->sc_txbuflock)
609 +#define ATH_TXBUF_UNLOCK_BH(_sc) \
610 + if (!irqs_disabled()) \
611 + spin_unlock_bh(&(_sc)->sc_txbuflock)
612 #define ATH_TXBUF_LOCK_IRQ(_sc) do { \
613 unsigned long __txbuflockflags; \
614 spin_lock_irqsave(&(_sc)->sc_txbuflock, __txbuflockflags);
615 @@ -725,8 +737,12 @@
616 #define ATH_RXBUF_LOCK_DESTROY(_sc)
617 #define ATH_RXBUF_LOCK(_sc) spin_lock(&(_sc)->sc_rxbuflock)
618 #define ATH_RXBUF_UNLOCK(_sc) spin_unlock(&(_sc)->sc_rxbuflock)
619 -#define ATH_RXBUF_LOCK_BH(_sc) spin_lock_bh(&(_sc)->sc_rxbuflock)
620 -#define ATH_RXBUF_UNLOCK_BH(_sc) spin_unlock_bh(&(_sc)->sc_rxbuflock)
621 +#define ATH_RXBUF_LOCK_BH(_sc) \
622 + if (!irqs_disabled()) \
623 + spin_lock_bh(&(_sc)->sc_rxbuflock)
624 +#define ATH_RXBUF_UNLOCK_BH(_sc) \
625 + if (!irqs_disabled()) \
626 + spin_unlock_bh(&(_sc)->sc_rxbuflock)
627 #define ATH_RXBUF_LOCK_IRQ(_sc) do { \
628 unsigned long __rxbuflockflags; \
629 spin_lock_irqsave(&(_sc)->sc_rxbuflock, __rxbuflockflags);
630 @@ -736,6 +752,8 @@
631 #define ATH_RXBUF_UNLOCK_IRQ_EARLY(_sc) \
632 spin_unlock_irqrestore(&(_sc)->sc_rxbuflock, __rxbuflockflags);
633
634 +#define ATH_DISABLE_INTR local_irq_disable
635 +#define ATH_ENABLE_INTR local_irq_enable
636
637 /* Protects the device from concurrent accesses */
638 #define ATH_LOCK_INIT(_sc) init_MUTEX(&(_sc)->sc_lock)
639 diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_beacon.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_beacon.c
640 --- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_beacon.c 2007-01-30 05:01:29.000000000 +0100
641 +++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_beacon.c 2007-05-13 18:17:56.596964992 +0200
642 @@ -286,7 +286,7 @@
643 int len_changed = 0;
644 u_int16_t capinfo;
645
646 - IEEE80211_LOCK(ic);
647 + IEEE80211_BEACON_LOCK(ic);
648
649 if ((ic->ic_flags & IEEE80211_F_DOTH) &&
650 (vap->iv_flags & IEEE80211_F_CHANSWITCH) &&
651 @@ -547,7 +547,7 @@
652 vap->iv_flags_ext &= ~IEEE80211_FEXT_APPIE_UPDATE;
653 }
654
655 - IEEE80211_UNLOCK(ic);
656 + IEEE80211_BEACON_UNLOCK(ic);
657
658 return len_changed;
659 }
660 diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_input.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_input.c
661 --- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_input.c 2007-05-13 18:17:56.106039624 +0200
662 +++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_input.c 2007-05-13 18:17:56.597964840 +0200
663 @@ -1148,8 +1148,9 @@
664 if (ni->ni_vlan != 0 && vap->iv_vlgrp != NULL) {
665 /* attach vlan tag */
666 vlan_hwaccel_receive_skb(skb, vap->iv_vlgrp, ni->ni_vlan);
667 - } else
668 - netif_rx(skb);
669 + } else {
670 + netif_receive_skb(skb);
671 + }
672 dev->last_rx = jiffies;
673 }
674 }
675 @@ -3623,9 +3624,9 @@
676 }
677
678 /* Okay, take the first queued packet and put it out... */
679 - IEEE80211_NODE_SAVEQ_LOCK(ni);
680 + IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
681 IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen);
682 - IEEE80211_NODE_SAVEQ_UNLOCK(ni);
683 + IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
684 if (skb == NULL) {
685 IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_POWER, wh->i_addr2,
686 "%s", "recv ps-poll, but queue empty");
687 diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_linux.h madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_linux.h
688 --- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_linux.h 2007-05-04 02:10:06.000000000 +0200
689 +++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_linux.h 2007-05-13 18:17:56.598964688 +0200
690 @@ -31,6 +31,10 @@
691
692 #include <linux/wireless.h>
693
694 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
695 +#define irqs_disabled() 0
696 +#endif
697 +
698 /*
699 * Task deferral
700 *
701 @@ -86,8 +90,12 @@
702 } while (0)
703 #define IEEE80211_UNLOCK_IRQ_EARLY(_ic) \
704 spin_unlock_irqrestore(&(_ic)->ic_comlock, __ilockflags);
705 -#define IEEE80211_LOCK_BH(_ic) spin_lock_bh(&(_ic)->ic_comlock)
706 -#define IEEE80211_UNLOCK_BH(_ic) spin_unlock_bh(&(_ic)->ic_comlock)
707 +#define IEEE80211_LOCK_BH(_ic) \
708 + if (!irqs_disabled()) \
709 + spin_lock_bh(&(_ic)->ic_comlock)
710 +#define IEEE80211_UNLOCK_BH(_ic) \
711 + if (!irqs_disabled()) \
712 + spin_unlock_bh(&(_ic)->ic_comlock)
713 #define IEEE80211_LOCK(_ic) spin_lock(&(_ic)->ic_comlock)
714 #define IEEE80211_UNLOCK(_ic) spin_unlock(&(_ic)->ic_comlock)
715
716 @@ -104,15 +112,22 @@
717 #define IEEE80211_VAPS_LOCK_DESTROY(_ic)
718 #define IEEE80211_VAPS_LOCK(_ic) spin_lock(&(_ic)->ic_vapslock);
719 #define IEEE80211_VAPS_UNLOCK(_ic) spin_unlock(&(_ic)->ic_vapslock);
720 -#define IEEE80211_VAPS_LOCK_BH(_ic) spin_lock_bh(&(_ic)->ic_vapslock);
721 -#define IEEE80211_VAPS_UNLOCK_BH(_ic) spin_unlock_bh(&(_ic)->ic_vapslock);
722 -#define IEEE80211_VAPS_LOCK_IRQ(_ic) do { \
723 - int _vaps_lockflags; \
724 - spin_lock_irqsave(&(_ic)->ic_vapslock, _vaps_lockflags);
725 -#define IEEE80211_VAPS_UNLOCK_IRQ(_ic) \
726 - spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags); \
727 -} while (0)
728 -#define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic) spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags)
729 +#define IEEE80211_VAPS_LOCK_BH(_ic) \
730 + if (!irqs_disabled()) \
731 + spin_lock_bh(&(_ic)->ic_vapslock);
732 +#define IEEE80211_VAPS_UNLOCK_BH(_ic) \
733 + if (!irqs_disabled()) \
734 + spin_unlock_bh(&(_ic)->ic_vapslock);
735 +#define IEEE80211_VAPS_LOCK_IRQ(_ic) do { \
736 + unsigned long __vlockflags=0; \
737 + unsigned int __vlocked=0; \
738 + __vlocked=spin_is_locked(&(_ic)->ic_vapslock); \
739 + if(!__vlocked) spin_lock_irqsave(&(_ic)->ic_vapslock, __vlockflags);
740 +#define IEEE80211_VAPS_UNLOCK_IRQ(_ic) \
741 + if(!__vlocked) spin_unlock_irqrestore(&(_ic)->ic_vapslock, __vlockflags); \
742 +} while (0);
743 +#define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic) \
744 + if (!__vlocked) spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags)
745
746 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)
747 #define IEEE80211_VAPS_LOCK_ASSERT(_ic) \
748 @@ -122,6 +137,11 @@
749 #define IEEE80211_VAPS_LOCK_ASSERT(_ic)
750 #endif
751
752 +/*
753 + * Beacon locking definitions; piggyback on com lock.
754 + */
755 +#define IEEE80211_BEACON_LOCK(_ic) IEEE80211_LOCK_IRQ(_ic)
756 +#define IEEE80211_BEACON_UNLOCK(_ic) IEEE80211_UNLOCK_IRQ(_ic)
757
758 /*
759 * Node locking definitions.
760 @@ -191,8 +211,12 @@
761 typedef spinlock_t ieee80211_scan_lock_t;
762 #define IEEE80211_SCAN_LOCK_INIT(_nt, _name) spin_lock_init(&(_nt)->nt_scanlock)
763 #define IEEE80211_SCAN_LOCK_DESTROY(_nt)
764 -#define IEEE80211_SCAN_LOCK_BH(_nt) spin_lock_bh(&(_nt)->nt_scanlock)
765 -#define IEEE80211_SCAN_UNLOCK_BH(_nt) spin_unlock_bh(&(_nt)->nt_scanlock)
766 +#define IEEE80211_SCAN_LOCK_BH(_nt) \
767 + if (!irqs_disabled()) \
768 + spin_lock_bh(&(_nt)->nt_scanlock)
769 +#define IEEE80211_SCAN_UNLOCK_BH(_nt) \
770 + if (!irqs_disabled()) \
771 + spin_unlock_bh(&(_nt)->nt_scanlock)
772 #define IEEE80211_SCAN_LOCK_IRQ(_nt) do { \
773 unsigned long __scan_lockflags; \
774 spin_lock_irqsave(&(_nt)->nt_scanlock, __scan_lockflags);
775 @@ -217,8 +241,12 @@
776 #define ACL_LOCK_DESTROY(_as)
777 #define ACL_LOCK(_as) spin_lock(&(_as)->as_lock)
778 #define ACL_UNLOCK(_as) spin_unlock(&(_as)->as_lock)
779 -#define ACL_LOCK_BH(_as) spin_lock_bh(&(_as)->as_lock)
780 -#define ACL_UNLOCK_BH(_as) spin_unlock_bh(&(_as)->as_lock)
781 +#define ACL_LOCK_BH(_as) \
782 + if (!irqs_disabled()) \
783 + spin_lock_bh(&(_as)->as_lock)
784 +#define ACL_UNLOCK_BH(_as) \
785 + if (!irqs_disabled()) \
786 + spin_unlock_bh(&(_as)->as_lock)
787
788 #if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)
789 #define ACL_LOCK_ASSERT(_as) \
790 diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_node.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_node.c
791 --- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_node.c 2007-05-13 18:17:56.273014240 +0200
792 +++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_node.c 2007-05-13 18:17:56.599964536 +0200
793 @@ -1567,7 +1567,7 @@
794 struct ieee80211_node *ni;
795 u_int gen;
796
797 - IEEE80211_SCAN_LOCK_IRQ(nt);
798 + IEEE80211_SCAN_LOCK_BH(nt);
799 gen = ++nt->nt_scangen;
800
801 restart:
802 @@ -1587,7 +1587,7 @@
803 }
804 IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt);
805
806 - IEEE80211_SCAN_UNLOCK_IRQ(nt);
807 + IEEE80211_SCAN_UNLOCK_BH(nt);
808 }
809 EXPORT_SYMBOL(ieee80211_iterate_dev_nodes);
810
811 diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_power.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_power.c
812 --- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_power.c 2007-04-25 22:29:55.000000000 +0200
813 +++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_power.c 2007-05-13 18:17:56.599964536 +0200
814 @@ -147,7 +147,7 @@
815 #endif
816 struct sk_buff *skb;
817
818 - IEEE80211_NODE_SAVEQ_LOCK(ni);
819 + IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
820 while ((skb = skb_peek(&ni->ni_savedq)) != NULL &&
821 M_AGE_GET(skb) < IEEE80211_INACT_WAIT) {
822 IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
823 @@ -159,7 +159,7 @@
824 }
825 if (skb != NULL)
826 M_AGE_SUB(skb, IEEE80211_INACT_WAIT);
827 - IEEE80211_NODE_SAVEQ_UNLOCK(ni);
828 + IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
829
830 IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni,
831 "discard %u frames for age", discard);
832 @@ -185,7 +185,7 @@
833 KASSERT(aid < vap->iv_max_aid,
834 ("bogus aid %u, max %u", aid, vap->iv_max_aid));
835
836 - IEEE80211_LOCK(ni->ni_ic);
837 + IEEE80211_BEACON_LOCK(ni->ni_ic);
838 if (set != (isset(vap->iv_tim_bitmap, aid) != 0)) {
839 if (set) {
840 setbit(vap->iv_tim_bitmap, aid);
841 @@ -196,7 +196,7 @@
842 }
843 vap->iv_flags |= IEEE80211_F_TIMUPDATE;
844 }
845 - IEEE80211_UNLOCK(ni->ni_ic);
846 + IEEE80211_BEACON_UNLOCK(ni->ni_ic);
847 }
848
849 /*
850 @@ -297,9 +297,9 @@
851 struct sk_buff *skb;
852 int qlen;
853
854 - IEEE80211_NODE_SAVEQ_LOCK(ni);
855 + IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
856 IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen);
857 - IEEE80211_NODE_SAVEQ_UNLOCK(ni);
858 + IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
859 if (skb == NULL)
860 break;
861 /*
862 @@ -363,9 +363,9 @@
863 for (;;) {
864 struct sk_buff *skb;
865
866 - IEEE80211_NODE_SAVEQ_LOCK(ni);
867 + IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);
868 skb = __skb_dequeue(&ni->ni_savedq);
869 - IEEE80211_NODE_SAVEQ_UNLOCK(ni);
870 + IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);
871 if (skb == NULL)
872 break;
873 ieee80211_parent_queue_xmit(skb);
874 diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_proto.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_proto.c
875 --- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_proto.c 2007-05-13 18:17:56.578967728 +0200
876 +++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_proto.c 2007-05-13 18:17:56.600964384 +0200
877 @@ -635,9 +635,9 @@
878 {
879 struct ieee80211com *ic = vap->iv_ic;
880
881 - IEEE80211_LOCK(ic);
882 + IEEE80211_BEACON_LOCK(ic);
883 ieee80211_wme_initparams_locked(vap);
884 - IEEE80211_UNLOCK(ic);
885 + IEEE80211_BEACON_UNLOCK(ic);
886 }
887
888 void
889 @@ -920,9 +920,9 @@
890 struct ieee80211com *ic = vap->iv_ic;
891
892 if (ic->ic_caps & IEEE80211_C_WME) {
893 - IEEE80211_LOCK(ic);
894 + IEEE80211_BEACON_LOCK(ic);
895 ieee80211_wme_updateparams_locked(vap);
896 - IEEE80211_UNLOCK(ic);
897 + IEEE80211_BEACON_UNLOCK(ic);
898 }
899 }
900
901 diff -urN madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_scan_sta.c madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_scan_sta.c
902 --- madwifi-ng-refcount-r2313-20070505.old/net80211/ieee80211_scan_sta.c 2007-02-01 21:49:37.000000000 +0100
903 +++ madwifi-ng-refcount-r2313-20070505.dev/net80211/ieee80211_scan_sta.c 2007-05-13 18:17:56.601964232 +0200
904 @@ -163,9 +163,11 @@
905 {
906 struct sta_table *st = ss->ss_priv;
907
908 - spin_lock(&st->st_lock);
909 + if (!irqs_disabled())
910 + spin_lock_bh(&st->st_lock);
911 sta_flush_table(st);
912 - spin_unlock(&st->st_lock);
913 + if (!irqs_disabled())
914 + spin_unlock_bh(&st->st_lock);
915 ss->ss_last = 0;
916 return 0;
917 }
918 @@ -215,7 +217,8 @@
919 int hash;
920
921 hash = STA_HASH(macaddr);
922 - spin_lock(&st->st_lock);
923 + if (!irqs_disabled())
924 + spin_lock_bh(&st->st_lock);
925 LIST_FOREACH(se, &st->st_hash[hash], se_hash)
926 if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr) &&
927 sp->ssid[1] == se->base.se_ssid[1] &&
928 @@ -225,7 +228,7 @@
929 MALLOC(se, struct sta_entry *, sizeof(struct sta_entry),
930 M_80211_SCAN, M_NOWAIT | M_ZERO);
931 if (se == NULL) {
932 - spin_unlock(&st->st_lock);
933 + spin_unlock_bh(&st->st_lock);
934 return 0;
935 }
936 se->se_scangen = st->st_scangen-1;
937 @@ -287,7 +290,8 @@
938 se->se_seen = 1;
939 se->se_notseen = 0;
940
941 - spin_unlock(&st->st_lock);
942 + if (!irqs_disabled())
943 + spin_unlock_bh(&st->st_lock);
944
945 /*
946 * If looking for a quick choice and nothing's
947 @@ -1063,7 +1067,8 @@
948 u_int gen;
949 int res = 0;
950
951 - spin_lock(&st->st_scanlock);
952 + if (!irqs_disabled())
953 + spin_lock_bh(&st->st_scanlock);
954 gen = st->st_scangen++;
955 restart:
956 spin_lock(&st->st_lock);
957 @@ -1086,7 +1091,8 @@
958 spin_unlock(&st->st_lock);
959
960 done:
961 - spin_unlock(&st->st_scanlock);
962 + if (!irqs_disabled())
963 + spin_unlock_bh(&st->st_scanlock);
964
965 return res;
966 }
967 @@ -1235,7 +1241,8 @@
968 bestchan = NULL;
969 bestrssi = -1;
970
971 - spin_lock(&st->st_lock);
972 + if (!irqs_disabled())
973 + spin_lock_bh(&st->st_lock);
974 for (i = 0; i < ss->ss_last; i++) {
975 c = ss->ss_chans[i];
976 maxrssi = 0;
977 @@ -1248,7 +1255,8 @@
978 if (bestchan == NULL || maxrssi < bestrssi)
979 bestchan = c;
980 }
981 - spin_unlock(&st->st_lock);
982 + if (!irqs_disabled())
983 + spin_unlock_bh(&st->st_lock);
984
985 return bestchan;
986 }