Ticket #1329: madwifi-locks.3.diff

File madwifi-locks.3.diff, 36.7 kB (added by mentor, 5 years ago)

Locally tested (and working!) version

  • net80211/ieee80211_beacon.c

    old new  
    286286        int len_changed = 0; 
    287287        u_int16_t capinfo; 
    288288 
    289         IEEE80211_LOCK(ic); 
     289        IEEE80211_LOCK_IRQ(ic); 
    290290 
    291291        if ((ic->ic_flags & IEEE80211_F_DOTH) && 
    292292            (vap->iv_flags & IEEE80211_F_CHANSWITCH) && 
     
    307307                if (c == NULL) { 
    308308                        IEEE80211_DPRINTF(vap, IEEE80211_MSG_DOTH, 
    309309                                "%s: find channel failure\n", __func__); 
    310                         IEEE80211_UNLOCK(ic); 
     310                        IEEE80211_UNLOCK_IRQ_EARLY(ic); 
    311311                        return 0; 
    312312                } 
    313313                ic->ic_bsschan = c; 
     
    547547                vap->iv_flags_ext &= ~IEEE80211_FEXT_APPIE_UPDATE; 
    548548        } 
    549549 
    550         IEEE80211_UNLOCK(ic); 
     550        IEEE80211_UNLOCK_IRQ(ic); 
    551551 
    552552        return len_changed; 
    553553} 
  • net80211/ieee80211_scan_sta.c

    old new  
    110110        int (*st_action)(struct ieee80211vap *, const struct ieee80211_scan_entry *); 
    111111}; 
    112112 
     113#define SCAN_STA_LOCK_INIT(_st, _name)                                  \ 
     114        spin_lock_init(&(_st)->st_lock) 
     115#define SCAN_STA_LOCK_DESTROY(_st) 
     116#define SCAN_STA_LOCK_IRQ(_st) do {                                     \ 
     117        unsigned long __stlockflags;                                    \ 
     118        spin_lock_irqsave(&(_st)->st_lock, __stlockflags); 
     119#define SCAN_STA_UNLOCK_IRQ(_st)                                        \ 
     120        spin_unlock_irqrestore(&(_st)->st_lock, __stlockflags);         \ 
     121} while (0) 
     122#define SCAN_STA_UNLOCK_IRQ_EARLY(_st)                                  \ 
     123        spin_unlock_irqrestore(&(_st)->st_lock, __stlockflags); 
     124 
     125#define SCAN_STA_GEN_LOCK_INIT(_st, _name)                              \ 
     126        spin_lock_init(&(_st)->st_lock) 
     127#define SCAN_STA_GEN_LOCK_DESTROY(_st) 
     128#define SCAN_STA_GEN_LOCK(_st)          spin_lock(&(_st)->st_scanlock); 
     129#define SCAN_STA_GEN_UNLOCK(_st)        spin_unlock(&(_st)->st_scanlock); 
     130 
    113131static void sta_flush_table(struct sta_table *); 
    114132static int match_bss(struct ieee80211vap *, const struct ieee80211_scan_state *, 
    115133        const struct sta_entry *); 
     
    129147                M_80211_SCAN, M_NOWAIT | M_ZERO); 
    130148        if (st == NULL) 
    131149                return 0; 
    132         spin_lock_init(&st->st_lock); 
    133         spin_lock_init(&st->st_scanlock); 
     150        SCAN_STA_LOCK_INIT(st, "scan_sta"); 
     151        SCAN_STA_GEN_LOCK_INIT(st, "scan_sta_gen"); 
    134152        TAILQ_INIT(&st->st_entry); 
    135153        IEEE80211_INIT_TQUEUE(&st->st_actiontq, action_tasklet, ss); 
    136154        ss->ss_priv = st; 
     
    163181{ 
    164182        struct sta_table *st = ss->ss_priv; 
    165183 
    166         spin_lock(&st->st_lock); 
     184        SCAN_STA_LOCK_IRQ(st); 
    167185        sta_flush_table(st); 
    168         spin_unlock(&st->st_lock); 
     186        SCAN_STA_UNLOCK_IRQ(st); 
    169187        ss->ss_last = 0; 
    170188        return 0; 
    171189} 
     
    215233        int hash; 
    216234 
    217235        hash = STA_HASH(macaddr); 
    218         spin_lock(&st->st_lock);   
     236        SCAN_STA_LOCK_IRQ(st); 
    219237        LIST_FOREACH(se, &st->st_hash[hash], se_hash) 
    220238                if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr) && 
    221239                    sp->ssid[1] == se->base.se_ssid[1] &&  
     
    225243        MALLOC(se, struct sta_entry *, sizeof(struct sta_entry), 
    226244                M_80211_SCAN, M_NOWAIT | M_ZERO); 
    227245        if (se == NULL) { 
    228                 spin_unlock(&st->st_lock); 
     246                SCAN_STA_UNLOCK_IRQ_EARLY(st); 
    229247                return 0; 
    230248        } 
    231249        se->se_scangen = st->st_scangen-1; 
     
    287305        se->se_seen = 1; 
    288306        se->se_notseen = 0; 
    289307 
    290         spin_unlock(&st->st_lock); 
     308        SCAN_STA_UNLOCK_IRQ(st); 
    291309 
    292310        /* 
    293311         * If looking for a quick choice and nothing's 
     
    792810sta_update_notseen(struct sta_table *st) 
    793811{ 
    794812        struct sta_entry *se; 
    795         unsigned long stlockflags; 
    796813 
    797         spin_lock_irqsave(&st->st_lock, stlockflags); 
     814        SCAN_STA_LOCK_IRQ(st); 
    798815        TAILQ_FOREACH(se, &st->st_entry, se_list) { 
    799816                /* 
    800817                 * If seen then reset and don't bump the count; 
     
    808825                else 
    809826                        se->se_notseen++; 
    810827        } 
    811         spin_unlock_irqrestore(&st->st_lock, stlockflags); 
     828        SCAN_STA_UNLOCK_IRQ(st); 
    812829} 
    813830 
    814831static void 
    815832sta_dec_fails(struct sta_table *st) 
    816833{ 
    817834        struct sta_entry *se; 
    818         unsigned long stlockflags; 
    819835 
    820         spin_lock_irqsave(&st->st_lock, stlockflags); 
     836        SCAN_STA_LOCK_IRQ(st); 
    821837        TAILQ_FOREACH(se, &st->st_entry, se_list) 
    822838                if (se->se_fails) 
    823839                        se->se_fails--; 
    824         spin_unlock_irqrestore(&st->st_lock, stlockflags); 
     840        SCAN_STA_UNLOCK_IRQ(st); 
    825841} 
    826842 
    827843static struct sta_entry * 
     
    829845{ 
    830846        struct sta_table *st = ss->ss_priv; 
    831847        struct sta_entry *se, *selbs = NULL; 
    832         unsigned long stlockflags; 
    833848 
    834849        IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN | IEEE80211_MSG_ROAM, " %s\n", 
    835850                "macaddr          bssid         chan  rssi  rate flag  wep  essid"); 
    836         spin_lock_irqsave(&st->st_lock, stlockflags); 
     851        SCAN_STA_LOCK_IRQ(st); 
    837852        TAILQ_FOREACH(se, &st->st_entry, se_list) { 
    838853                if (match_bss(vap, ss, se) == 0) { 
    839854                        if (selbs == NULL) 
     
    842857                                selbs = se; 
    843858                } 
    844859        } 
    845         spin_unlock_irqrestore(&st->st_lock, stlockflags); 
     860        SCAN_STA_UNLOCK_IRQ(st); 
    846861 
    847862        return selbs; 
    848863} 
     
    930945        struct sta_entry *se; 
    931946        int hash = STA_HASH(macaddr); 
    932947 
    933         spin_lock(&st->st_lock); 
     948        SCAN_STA_LOCK_IRQ(st); 
    934949        LIST_FOREACH(se, &st->st_hash[hash], se_hash) 
    935950                if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr)) 
    936951                        break; 
    937         spin_unlock(&st->st_lock); 
     952        SCAN_STA_UNLOCK_IRQ(st); 
    938953 
    939954        return se;              /* NB: unlocked */ 
    940955} 
     
    10241039        struct sta_table *st = ss->ss_priv; 
    10251040        struct sta_entry *se, *next; 
    10261041 
    1027         spin_lock(&st->st_lock); 
     1042        SCAN_STA_LOCK_IRQ(st); 
    10281043        TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) { 
    10291044                if (se->se_notseen > STA_PURGE_SCANS) { 
    10301045                        TAILQ_REMOVE(&st->st_entry, se, se_list); 
     
    10321047                        FREE(se, M_80211_SCAN); 
    10331048                } 
    10341049        } 
    1035         spin_unlock(&st->st_lock); 
     1050        SCAN_STA_UNLOCK_IRQ(st); 
    10361051        /* 
    10371052         * If rate control is enabled check periodically to see if 
    10381053         * we should roam from our current connection to one that 
     
    10631078        u_int gen; 
    10641079        int res = 0; 
    10651080 
    1066         spin_lock(&st->st_scanlock); 
     1081        SCAN_STA_GEN_LOCK(st); 
    10671082        gen = st->st_scangen++; 
    10681083restart: 
    1069         spin_lock(&st->st_lock); 
     1084        SCAN_STA_LOCK_IRQ(st); 
    10701085        TAILQ_FOREACH(se, &st->st_entry, se_list) { 
    10711086                if (se->se_scangen != gen) { 
    10721087                        se->se_scangen = gen; 
    10731088                        /* update public state */ 
    10741089                        se->base.se_age = jiffies - se->se_lastupdate; 
    1075                         spin_unlock(&st->st_lock); 
     1090                        SCAN_STA_UNLOCK_IRQ_EARLY(st); 
     1091                         
    10761092                        res = (*f)(arg, &se->base); 
    10771093 
    1078                         if(res != 0) { 
     1094                        if(res != 0) 
    10791095                          /* We probably ran out of buffer space. */ 
    10801096                          goto done; 
    1081                         } 
     1097 
    10821098                        goto restart; 
    10831099                } 
    10841100        } 
    10851101 
    1086         spin_unlock(&st->st_lock); 
     1102        SCAN_STA_UNLOCK_IRQ(st); 
    10871103 
    10881104 done: 
    1089         spin_unlock(&st->st_scanlock); 
     1105        SCAN_STA_GEN_UNLOCK(st); 
    10901106 
    10911107        return res; 
    10921108} 
     
    12351251        bestchan = NULL; 
    12361252        bestrssi = -1; 
    12371253 
    1238         spin_lock(&st->st_lock); 
     1254        SCAN_STA_LOCK_IRQ(st); 
    12391255        for (i = 0; i < ss->ss_last; i++) { 
    12401256                c = ss->ss_chans[i]; 
    12411257                maxrssi = 0; 
     
    12481264                if (bestchan == NULL || maxrssi < bestrssi) 
    12491265                        bestchan = c; 
    12501266        } 
    1251         spin_unlock(&st->st_lock); 
     1267        SCAN_STA_UNLOCK_IRQ(st); 
    12521268 
    12531269        return bestchan; 
    12541270} 
     
    13491365        struct sta_table *st = ss->ss_priv; 
    13501366        struct sta_entry *se, *next; 
    13511367 
    1352         spin_lock(&st->st_lock); 
     1368        SCAN_STA_LOCK_IRQ(st); 
    13531369        TAILQ_FOREACH_SAFE(se, &st->st_entry, se_list, next) { 
    13541370                if (se->se_notseen > STA_PURGE_SCANS) { 
    13551371                        TAILQ_REMOVE(&st->st_entry, se, se_list); 
     
    13571373                        FREE(se, M_80211_SCAN); 
    13581374                } 
    13591375        } 
    1360         spin_unlock(&st->st_lock); 
     1376        SCAN_STA_UNLOCK_IRQ(st); 
    13611377} 
    13621378 
    13631379/* 
  • net80211/ieee80211_input.c

    old new  
    36543654        } 
    36553655 
    36563656        /* Okay, take the first queued packet and put it out... */ 
    3657         IEEE80211_NODE_SAVEQ_LOCK(ni); 
     3657        IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 
    36583658        IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen); 
    3659         IEEE80211_NODE_SAVEQ_UNLOCK(ni); 
     3659        IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 
    36603660        if (skb == NULL) { 
    36613661                IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_POWER, wh->i_addr2, 
    36623662                        "%s", "recv ps-poll, but queue empty"); 
  • net80211/ieee80211_power.c

    old new  
    113113        struct sk_buff *skb; 
    114114        int qlen; 
    115115 
    116         IEEE80211_NODE_SAVEQ_LOCK(ni); 
     116        IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 
    117117        qlen = IEEE80211_NODE_SAVEQ_QLEN(ni); 
    118118        while ((skb = __skb_dequeue(&ni->ni_savedq)) != NULL) { 
    119119                cb = (struct ieee80211_cb *) skb->cb; 
    120120                ieee80211_unref_node(&cb->ni); 
    121121                dev_kfree_skb_any(skb); 
    122122        } 
    123         IEEE80211_NODE_SAVEQ_UNLOCK(ni); 
     123        IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 
    124124 
    125125        return qlen; 
    126126} 
     
    147147#endif 
    148148                struct sk_buff *skb; 
    149149 
    150                 IEEE80211_NODE_SAVEQ_LOCK(ni); 
     150                IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 
    151151                while ((skb = skb_peek(&ni->ni_savedq)) != NULL && 
    152152                     M_AGE_GET(skb) < IEEE80211_INACT_WAIT) { 
    153153                        IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, 
     
    159159                } 
    160160                if (skb != NULL) 
    161161                        M_AGE_SUB(skb, IEEE80211_INACT_WAIT); 
    162                 IEEE80211_NODE_SAVEQ_UNLOCK(ni); 
     162                IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 
    163163 
    164164                IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, 
    165165                        "discard %u frames for age", discard); 
     
    185185        KASSERT(aid < vap->iv_max_aid, 
    186186                ("bogus aid %u, max %u", aid, vap->iv_max_aid)); 
    187187 
    188         IEEE80211_LOCK(ni->ni_ic); 
     188        IEEE80211_LOCK_IRQ(ni->ni_ic); 
    189189        if (set != (isset(vap->iv_tim_bitmap, aid) != 0)) { 
    190190                if (set) { 
    191191                        setbit(vap->iv_tim_bitmap, aid); 
     
    196196                } 
    197197                vap->iv_flags |= IEEE80211_F_TIMUPDATE; 
    198198        } 
    199         IEEE80211_UNLOCK(ni->ni_ic); 
     199        IEEE80211_UNLOCK_IRQ(ni->ni_ic); 
    200200} 
    201201 
    202202/* 
     
    212212        struct sk_buff *tail; 
    213213        int qlen, age; 
    214214 
    215         IEEE80211_NODE_SAVEQ_LOCK_IRQ(ni);     
     215        IEEE80211_NODE_SAVEQ_LOCK_BH(ni);      
    216216        if (IEEE80211_NODE_SAVEQ_QLEN(ni) >= IEEE80211_PS_MAX_QUEUE) { 
    217217                IEEE80211_NODE_STAT(ni, psq_drops); 
    218                 IEEE80211_NODE_SAVEQ_UNLOCK_IRQ_EARLY(ni); 
     218                IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 
    219219                IEEE80211_NOTE(vap, IEEE80211_MSG_ANY, ni, 
    220220                        "pwr save q overflow, drops %d (size %d)", 
    221221                        ni->ni_stats.ns_psq_drops, IEEE80211_PS_MAX_QUEUE); 
     
    244244                __skb_queue_head(&ni->ni_savedq, skb); 
    245245        M_AGE_SET(skb, age); 
    246246        qlen = IEEE80211_NODE_SAVEQ_QLEN(ni); 
    247         IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(ni);   
     247        IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni);    
    248248 
    249249        IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, 
    250250                "save frame, %u now queued", qlen); 
     
    288288                                vap->iv_set_tim(ni, 0);         /* just in case */ 
    289289                        return; 
    290290                } 
     291 
    291292                IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, 
    292293                                "flush ps queue, %u packets queued", 
    293294                                IEEE80211_NODE_SAVEQ_QLEN(ni)); 
     295 
    294296                for (;;) { 
    295297                        struct sk_buff *skb; 
    296298                        int qlen; 
    297299 
    298                         IEEE80211_NODE_SAVEQ_LOCK(ni); 
     300                        IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 
    299301                        IEEE80211_NODE_SAVEQ_DEQUEUE(ni, skb, qlen); 
    300                         IEEE80211_NODE_SAVEQ_UNLOCK(ni); 
     302                        IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 
    301303                        if (skb == NULL) 
    302304                                break; 
    303305                        /*  
     
    362364                        for (;;) { 
    363365                                struct sk_buff *skb; 
    364366 
    365                                 IEEE80211_NODE_SAVEQ_LOCK(ni); 
     367                                IEEE80211_NODE_SAVEQ_LOCK_BH(ni); 
    366368                                skb = __skb_dequeue(&ni->ni_savedq); 
    367                                 IEEE80211_NODE_SAVEQ_UNLOCK(ni); 
     369                                IEEE80211_NODE_SAVEQ_UNLOCK_BH(ni); 
    368370                                if (skb == NULL) 
    369371                                        break; 
    370372                                ieee80211_parent_queue_xmit(skb); 
  • net80211/ieee80211_proto.c

    old new  
    633633{ 
    634634        struct ieee80211com *ic = vap->iv_ic; 
    635635 
    636         IEEE80211_LOCK(ic); 
     636        IEEE80211_LOCK_IRQ(ic); 
    637637        ieee80211_wme_initparams_locked(vap); 
    638         IEEE80211_UNLOCK(ic); 
     638        IEEE80211_UNLOCK_IRQ(ic); 
    639639} 
    640640 
    641641void 
     
    918918        struct ieee80211com *ic = vap->iv_ic; 
    919919 
    920920        if (ic->ic_caps & IEEE80211_C_WME) { 
    921                 IEEE80211_LOCK(ic); 
     921                IEEE80211_LOCK_IRQ(ic); 
    922922                ieee80211_wme_updateparams_locked(vap); 
    923                 IEEE80211_UNLOCK(ic); 
     923                IEEE80211_UNLOCK_IRQ(ic); 
    924924        } 
    925925} 
    926926 
  • net80211/ieee80211_linux.h

    old new  
    8686} while (0) 
    8787#define IEEE80211_UNLOCK_IRQ_EARLY(_ic)                                 \ 
    8888        spin_unlock_irqrestore(&(_ic)->ic_comlock, __ilockflags); 
    89 #define IEEE80211_LOCK_BH(_ic)  spin_lock_bh(&(_ic)->ic_comlock) 
    90 #define IEEE80211_UNLOCK_BH(_ic) spin_unlock_bh(&(_ic)->ic_comlock) 
    91 #define IEEE80211_LOCK(_ic)     spin_lock(&(_ic)->ic_comlock) 
    92 #define IEEE80211_UNLOCK(_ic)   spin_unlock(&(_ic)->ic_comlock) 
    9389 
    9490#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
    9591#define IEEE80211_LOCK_ASSERT(_ic) \ 
     
    10298#define IEEE80211_VAPS_LOCK_INIT(_ic, _name)            \ 
    10399        spin_lock_init(&(_ic)->ic_vapslock) 
    104100#define IEEE80211_VAPS_LOCK_DESTROY(_ic) 
    105 #define IEEE80211_VAPS_LOCK(_ic)        spin_lock(&(_ic)->ic_vapslock); 
    106 #define IEEE80211_VAPS_UNLOCK(_ic)      spin_unlock(&(_ic)->ic_vapslock); 
    107101#define IEEE80211_VAPS_LOCK_BH(_ic)     spin_lock_bh(&(_ic)->ic_vapslock); 
    108102#define IEEE80211_VAPS_UNLOCK_BH(_ic)   spin_unlock_bh(&(_ic)->ic_vapslock); 
    109 #define IEEE80211_VAPS_LOCK_IRQ(_ic)    do {    \ 
    110         int _vaps_lockflags;                    \ 
    111         spin_lock_irqsave(&(_ic)->ic_vapslock, _vaps_lockflags); 
    112 #define IEEE80211_VAPS_UNLOCK_IRQ(_ic)  \ 
    113         spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags); \ 
    114 } while (0) 
    115 #define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic)    spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags) 
    116103 
    117104#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
    118105#define IEEE80211_VAPS_LOCK_ASSERT(_ic) \ 
     
    131118typedef spinlock_t ieee80211_node_lock_t; 
    132119#define IEEE80211_NODE_LOCK_INIT(_ni, _name)    spin_lock_init(&(_ni)->ni_nodelock) 
    133120#define IEEE80211_NODE_LOCK_DESTROY(_ni) 
    134 #if 0   /* We should always be contesting in the same contexts */ 
    135 #define IEEE80211_NODE_LOCK(_ni)        spin_lock(&(_ni)->ni_nodelock) 
    136 #define IEEE80211_NODE_UNLOCK(_ni)      spin_unlock(&(_ni)->ni_nodelock) 
    137 #define IEEE80211_NODE_LOCK_BH(_ni)     spin_lock_bh(&(_ni)->ni_nodelock) 
    138 #define IEEE80211_NODE_UNLOCK_BH(_ni)   spin_unlock_bh(&(_ni)->ni_nodelock) 
    139 #endif 
    140121#define IEEE80211_NODE_LOCK_IRQ(_ni)    do {    \ 
    141122        unsigned long __node_lockflags;         \ 
    142123        spin_lock_irqsave(&(_ni)->ni_nodelock, __node_lockflags); 
     
    191172typedef spinlock_t ieee80211_scan_lock_t; 
    192173#define IEEE80211_SCAN_LOCK_INIT(_nt, _name) spin_lock_init(&(_nt)->nt_scanlock) 
    193174#define IEEE80211_SCAN_LOCK_DESTROY(_nt) 
    194 #define IEEE80211_SCAN_LOCK_BH(_nt)     spin_lock_bh(&(_nt)->nt_scanlock) 
    195 #define IEEE80211_SCAN_UNLOCK_BH(_nt)   spin_unlock_bh(&(_nt)->nt_scanlock) 
    196175#define IEEE80211_SCAN_LOCK_IRQ(_nt)    do {    \ 
    197176        unsigned long __scan_lockflags;         \ 
    198177        spin_lock_irqsave(&(_nt)->nt_scanlock, __scan_lockflags); 
     
    217196#define ACL_LOCK_DESTROY(_as) 
    218197#define ACL_LOCK(_as)                   spin_lock(&(_as)->as_lock) 
    219198#define ACL_UNLOCK(_as)                 spin_unlock(&(_as)->as_lock) 
    220 #define ACL_LOCK_BH(_as)                spin_lock_bh(&(_as)->as_lock) 
    221 #define ACL_UNLOCK_BH(_as)              spin_unlock_bh(&(_as)->as_lock) 
    222199 
    223200#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
    224201#define ACL_LOCK_ASSERT(_as) \ 
     
    240217        skb_queue_head_init(&(_ni)->ni_savedq);                 \ 
    241218} while (0) 
    242219#define IEEE80211_NODE_SAVEQ_DESTROY(_ni) 
    243 #define IEEE80211_NODE_SAVEQ_QLEN(_ni)  skb_queue_len(&(_ni)->ni_savedq) 
    244 #define IEEE80211_NODE_SAVEQ_LOCK(_ni)                          \ 
    245         spin_lock(&(_ni)->ni_savedq.lock) 
    246 #define IEEE80211_NODE_SAVEQ_UNLOCK(_ni)                        \ 
    247         spin_unlock(&(_ni)->ni_savedq.lock) 
    248 #define IEEE80211_NODE_SAVEQ_LOCK_IRQ(_ni) do {                 \ 
    249         unsigned long __sqlockflags;                            \ 
    250         spin_lock_irqsave(&(_ni)->ni_savedq.lock, __sqlockflags); 
    251 #define IEEE80211_NODE_SAVEQ_UNLOCK_IRQ(_ni)                            \ 
    252         spin_unlock_irqrestore(&(_ni)->ni_savedq.lock, __sqlockflags);  \ 
    253 } while (0) 
    254 #define IEEE80211_NODE_SAVEQ_UNLOCK_IRQ_EARLY(_ni)              \ 
    255         spin_unlock_irqrestore(&(_ni)->ni_savedq.lock, __sqlockflags); 
     220#define IEEE80211_NODE_SAVEQ_QLEN(_ni)          skb_queue_len(&(_ni)->ni_savedq) 
     221#define IEEE80211_NODE_SAVEQ_LOCK_BH(_ni)       spin_lock_bh(&(_ni)->ni_savedq.lock); 
     222#define IEEE80211_NODE_SAVEQ_UNLOCK_BH(_ni)     spin_unlock_bh(&(_ni)->ni_savedq.lock); 
    256223 
    257224/* caller MUST lock IEEE80211_NODE_SAVEQ */ 
    258225#define IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _skb, _qlen) do {     \ 
  • ath/if_ath_pci.c

    old new  
    221221 
    222222        /* looking for device type from broken device id */ 
    223223        vdevice = id->device; 
    224         for(i=0;i<sizeof(ath_devidmap)/sizeof(ath_devidmap[0]);i++) { 
     224        for(i = 0; i < (sizeof(ath_devidmap) / sizeof(ath_devidmap[0])); i++) { 
    225225                if(id->device == ath_devidmap[i][0]) { 
    226226                        vdevice = ath_devidmap[i][1]; 
    227227                        break; 
  • ath/if_athvar.h

    old new  
    345345#define ATH_NODE(_n)                    ((struct ath_node *)(_n)) 
    346346#define ATH_NODE_CONST(ni)              ((const struct ath_node *)(ni)) 
    347347#define ATH_NODE_UAPSD_LOCK_INIT(_an)   spin_lock_init(&(_an)->an_uapsd_lock) 
    348 #define ATH_NODE_UAPSD_LOCK(_an)        spin_lock(&(_an)->an_uapsd_lock) 
    349 #define ATH_NODE_UAPSD_UNLOCK(_an)      spin_unlock(&(_an)->an_uapsd_lock) 
    350348#define ATH_NODE_UAPSD_LOCK_IRQ(_an)    do {    \ 
    351349        unsigned long __an_uapsd_lockflags;     \ 
    352350        spin_lock_irqsave(&(_an)->an_uapsd_lock, __an_uapsd_lockflags); 
     
    476474#define ATH_TXQ_INTR_PERIOD             5  /* axq_intrcnt period for intr gen */ 
    477475#define ATH_TXQ_LOCK_INIT(_tq)          spin_lock_init(&(_tq)->axq_lock) 
    478476#define ATH_TXQ_LOCK_DESTROY(_tq)        
    479 #define ATH_TXQ_LOCK(_tq)               spin_lock(&(_tq)->axq_lock) 
    480 #define ATH_TXQ_UNLOCK(_tq)             spin_unlock(&(_tq)->axq_lock) 
    481 #define ATH_TXQ_LOCK_BH(_tq)            spin_lock_bh(&(_tq)->axq_lock) 
    482 #define ATH_TXQ_UNLOCK_BH(_tq)          spin_unlock_bh(&(_tq)->axq_lock) 
    483477#define ATH_TXQ_LOCK_IRQ(_tq)           do {    \ 
    484478        unsigned long __axq_lockflags;          \ 
    485479        spin_lock_irqsave(&(_tq)->axq_lock, __axq_lockflags); 
     
    489483#define ATH_TXQ_UNLOCK_IRQ_EARLY(_tq)                   \ 
    490484        spin_unlock_irqrestore(&(_tq)->axq_lock, __axq_lockflags); 
    491485 
    492 #define ATH_TXQ_UAPSDQ_LOCK_IRQ(_tq)    spin_lock_irqsave(&(_tq)->axq_lock, uapsdq_lockflags) 
    493 #define ATH_TXQ_UAPSDQ_UNLOCK_IRQ(_tq)  spin_unlock_irqrestore(&(_tq)->axq_lock, uapsdq_lockflags) 
    494  
    495  
    496  
    497  
    498486#define ATH_TXQ_LOCK_ASSERT(_tq) \ 
    499487        KASSERT(spin_is_locked(&(_tq)->axq_lock), ("txq not locked!")) 
     488 
    500489#define ATH_TXQ_INSERT_TAIL(_tq, _elm, _field) do { \ 
    501490        STAILQ_INSERT_TAIL( &(_tq)->axq_q, (_elm), _field); \ 
    502491        (_tq)->axq_depth++; \ 
     
    688677}; 
    689678 
    690679typedef void (*ath_callback) (struct ath_softc *); 
    691 #define ATH_TXQ_SETUP(sc, i)    ((sc)->sc_txqsetup & (1<<i)) 
     680#define ATH_TXQ_SETUP(sc, i)    ((sc)->sc_txqsetup & (1 << i)) 
    692681 
    693682#define ATH_TXBUF_LOCK_INIT(_sc)        spin_lock_init(&(_sc)->sc_txbuflock) 
    694683#define ATH_TXBUF_LOCK_DESTROY(_sc) 
    695 #define ATH_TXBUF_LOCK(_sc)             spin_lock(&(_sc)->sc_txbuflock) 
    696 #define ATH_TXBUF_UNLOCK(_sc)           spin_unlock(&(_sc)->sc_txbuflock) 
    697 #define ATH_TXBUF_LOCK_BH(_sc)          spin_lock_bh(&(_sc)->sc_txbuflock) 
    698 #define ATH_TXBUF_UNLOCK_BH(_sc)        spin_unlock_bh(&(_sc)->sc_txbuflock) 
    699684#define ATH_TXBUF_LOCK_IRQ(_sc)         do {    \ 
    700685        unsigned long __txbuflockflags;         \ 
    701686        spin_lock_irqsave(&(_sc)->sc_txbuflock, __txbuflockflags); 
     
    711696 
    712697#define ATH_RXBUF_LOCK_INIT(_sc)        spin_lock_init(&(_sc)->sc_rxbuflock) 
    713698#define ATH_RXBUF_LOCK_DESTROY(_sc) 
    714 #define ATH_RXBUF_LOCK(_sc)             spin_lock(&(_sc)->sc_rxbuflock) 
    715 #define ATH_RXBUF_UNLOCK(_sc)           spin_unlock(&(_sc)->sc_rxbuflock) 
    716 #define ATH_RXBUF_LOCK_BH(_sc)          spin_lock_bh(&(_sc)->sc_rxbuflock) 
    717 #define ATH_RXBUF_UNLOCK_BH(_sc)        spin_unlock_bh(&(_sc)->sc_rxbuflock) 
    718699#define ATH_RXBUF_LOCK_IRQ(_sc)         do {    \ 
    719700        unsigned long __rxbuflockflags;         \ 
    720701        spin_lock_irqsave(&(_sc)->sc_rxbuflock, __rxbuflockflags); 
     
    724705#define ATH_RXBUF_UNLOCK_IRQ_EARLY(_sc)         \ 
    725706        spin_unlock_irqrestore(&(_sc)->sc_rxbuflock, __rxbuflockflags); 
    726707 
    727  
    728708/* Protects the device from concurrent accesses */ 
    729709#define ATH_LOCK_INIT(_sc)              init_MUTEX(&(_sc)->sc_lock) 
    730710#define ATH_LOCK_DESTROY(_sc) 
  • ath/if_ath.c

    old new  
    12891289                if (vap->iv_xrvap) 
    12901290                        vap->iv_xrvap->iv_xrvap = NULL; 
    12911291                kfree(vap->iv_dev); 
    1292                 ath_tx_cleanupq(sc,sc->sc_xrtxq); 
     1292                ath_tx_cleanupq(sc, sc->sc_xrtxq); 
    12931293                sc->sc_xrtxq = NULL; 
    12941294                if (sc->sc_hasdiversity) { 
    12951295                        /* Restore diversity setting to old diversity setting */ 
     
    13621362         *          based on ic->ic_uapsdmaxtriggers. 
    13631363         */ 
    13641364 
    1365         ATH_RXBUF_LOCK(sc); 
     1365        ATH_RXBUF_LOCK_IRQ(sc); 
    13661366        if (sc->sc_rxbufcur == NULL) 
    13671367                sc->sc_rxbufcur = STAILQ_FIRST(&sc->sc_rxbuf); 
    13681368        for (bf = sc->sc_rxbufcur; bf; bf = STAILQ_NEXT(bf, bf_list)) { 
     
    15421542                an = ATH_NODE(ni); 
    15431543 
    15441544                /* start the SP */ 
    1545                 ATH_NODE_UAPSD_LOCK(an); 
     1545                ATH_NODE_UAPSD_LOCK_IRQ(an); 
    15461546                ni->ni_stats.ns_uapsd_triggers++; 
    15471547                ni->ni_flags |= IEEE80211_NODE_UAPSD_SP; 
    15481548                ni->ni_uapsd_trigseq[ac] = frame_seq; 
    1549                 ATH_NODE_UAPSD_UNLOCK(an); 
     1549                ATH_NODE_UAPSD_UNLOCK_IRQ(an); 
    15501550 
    1551                 ATH_TXQ_LOCK(uapsd_xmit_q); 
     1551                ATH_TXQ_LOCK_IRQ(uapsd_xmit_q); 
    15521552                if (STAILQ_EMPTY(&an->an_uapsd_q)) { 
    15531553                        DPRINTF(sc, ATH_DEBUG_UAPSD, 
    15541554                                "%s: Queue empty, generating QoS NULL to send\n", 
     
    16051605                } 
    16061606                an->an_uapsd_qdepth = 0; 
    16071607 
    1608                 ATH_TXQ_UNLOCK(uapsd_xmit_q); 
     1608                ATH_TXQ_UNLOCK_IRQ(uapsd_xmit_q); 
    16091609        } 
    16101610        sc->sc_rxbufcur = bf; 
    1611         ATH_RXBUF_UNLOCK(sc); 
     1611        ATH_RXBUF_UNLOCK_IRQ(sc); 
    16121612#undef PA2DESC 
    16131613} 
    16141614 
     
    21732173         * Insert the frame on the outbound list and 
    21742174         * pass it on to the hardware. 
    21752175         */ 
    2176         ATH_TXQ_LOCK(txq); 
     2176        ATH_TXQ_LOCK_IRQ(txq); 
    21772177        if (ni && ni->ni_vap && txq == &ATH_VAP(ni->ni_vap)->av_mcastq) { 
    21782178                /* 
    21792179                 * The CAB queue is started from the SWBA handler since 
     
    22182218                ath_hal_txstart(ah, txq->axq_qnum); 
    22192219                sc->sc_dev->trans_start = jiffies; 
    22202220        } 
    2221         ATH_TXQ_UNLOCK(txq); 
     2221        ATH_TXQ_UNLOCK_IRQ(txq); 
    22222222 
    22232223        sc->sc_devstats.tx_packets++; 
    22242224        sc->sc_devstats.tx_bytes += framelen; 
     
    23562356        return 0; 
    23572357} 
    23582358 
    2359 /* Caller must not hold ATH_TXQ_LOCK and ATH_TXBUF_LOCK 
     2359/* Caller must not hold ATH_TXQ_LOCK_IRQ and ATH_TXBUF_LOCK 
    23602360 * 
    23612361 * Context: softIRQ 
    23622362 */ 
     
    23702370        int framecnt; 
    23712371 
    23722372        for (;;) { 
    2373                 ATH_TXQ_LOCK(txq); 
     2373                ATH_TXQ_LOCK_IRQ(txq); 
    23742374 
    23752375                bf_ff = TAILQ_LAST(&txq->axq_stageq, axq_headtype); 
    23762376                if ((!bf_ff) || ath_ff_flushdonetest(txq, bf_ff)) { 
    2377                         ATH_TXQ_UNLOCK(txq); 
     2377                        ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 
    23782378                        break; 
    23792379                } 
    23802380 
     
    23842384                ATH_NODE(ni)->an_tx_ffbuf[bf_ff->bf_skb->priority] = NULL; 
    23852385                TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist); 
    23862386 
    2387                 ATH_TXQ_UNLOCK(txq); 
     2387                ATH_TXQ_UNLOCK_IRQ(txq); 
    23882388 
    23892389                /* encap and xmit */ 
    23902390                bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt); 
     
    24122412} 
    24132413#endif 
    24142414 
    2415 #define ATH_HARDSTART_GET_TX_BUF_WITH_LOCK                            \ 
     2415#define ATH_HARDSTART_GET_TX_BUF_WITH_LOCK      do {                  \ 
    24162416        ATH_TXBUF_LOCK_IRQ(sc);                                         \ 
    24172417        bf = STAILQ_FIRST(&sc->sc_txbuf);                               \ 
    24182418        if (bf != NULL) {                                               \ 
     
    24332433                DPRINTF(sc,ATH_DEBUG_XMIT,                              \ 
    24342434                        "%s: discard, no xmit buf\n", __func__);        \ 
    24352435                sc->sc_stats.ast_tx_nobuf++;                            \ 
    2436         } 
     2436        }                                                               \ 
     2437        } while (0) 
    24372438 
    24382439/* 
    24392440 * Transmit a data packet.  On failure caller is 
     
    25152516        /* NB: use this lock to protect an->an_ff_txbuf in athff_can_aggregate() 
    25162517         *     call too. 
    25172518         */ 
    2518         ATH_TXQ_LOCK(txq); 
     2519        ATH_TXQ_LOCK_IRQ(txq); 
    25192520        if (athff_can_aggregate(sc, eh, an, skb, vap->iv_fragthreshold, &ff_flush)) { 
    2520  
    25212521                if (an->an_tx_ffbuf[skb->priority]) { /* i.e., frame on the staging queue */ 
    25222522                        bf = an->an_tx_ffbuf[skb->priority]; 
    25232523 
     
    25252525                        TAILQ_REMOVE(&txq->axq_stageq, bf, bf_stagelist); 
    25262526                        an->an_tx_ffbuf[skb->priority] = NULL; 
    25272527 
    2528                         ATH_TXQ_UNLOCK(txq); 
    2529  
    25302528                        /* 
    25312529                         * chain skbs and add FF magic 
    25322530                         * 
     
    25382536                        skb = bf->bf_skb; 
    25392537                        ATH_FF_MAGIC_PUT(skb); 
    25402538 
    2541 #if 0 
    2542                         /* decrement extra node reference made when an_tx_ffbuf[] was set */ 
    2543                         ieee80211_unref_node(&ni); /* XXX where was it set ? */ 
    2544 #endif 
    2545  
    25462539                        DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
    25472540                                "%s: aggregating fast-frame\n", __func__); 
    25482541                } else { 
    2549                         /* NB: careful grabbing the TX_BUF lock since still holding the txq lock. 
    2550                          *     this could be avoided by always obtaining the txbuf earlier, 
     2542                        /* NB: Careful grabbing the TX_BUF lock since still holding the TXQ lock. 
     2543                         *     This could be avoided by always obtaining the TXBuf earlier, 
    25512544                         *     but the "if" portion of this "if/else" clause would then need 
    25522545                         *     to give the buffer back. 
    25532546                         */ 
    25542547                        ATH_HARDSTART_GET_TX_BUF_WITH_LOCK; 
    25552548                        if (bf == NULL) { 
    2556                                 ATH_TXQ_UNLOCK(txq); 
     2549                                ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 
    25572550                                goto hardstart_fail; 
    25582551                        } 
    25592552                        DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
     
    25662559 
    25672560                        TAILQ_INSERT_HEAD(&txq->axq_stageq, bf, bf_stagelist); 
    25682561 
    2569                         ATH_TXQ_UNLOCK(txq); 
     2562                        ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 
    25702563 
    25712564                        return 0; 
    25722565                } 
    25732566        } else { 
    25742567                if (ff_flush) { 
    25752568                        struct ath_buf *bf_ff = an->an_tx_ffbuf[skb->priority]; 
     2569                        int success = 0; 
    25762570 
    25772571                        TAILQ_REMOVE(&txq->axq_stageq, bf_ff, bf_stagelist); 
    25782572                        an->an_tx_ffbuf[skb->priority] = NULL; 
    25792573 
    2580                         ATH_TXQ_UNLOCK(txq); 
    2581  
    25822574                        /* encap and xmit */ 
    25832575                        bf_ff->bf_skb = ieee80211_encap(ni, bf_ff->bf_skb, &framecnt); 
    25842576 
     
    25872579                                        "%s: discard, ff flush encap failure\n", 
    25882580                                        __func__); 
    25892581                                sc->sc_stats.ast_tx_encap++; 
    2590                                 goto ff_flushbad; 
     2582                        } else { 
     2583                                pktlen = bf_ff->bf_skb->len;    /* NB: don't reference skb below */ 
     2584                                if (!ath_tx_start(dev, ni, bf_ff, bf_ff->bf_skb, 0)) 
     2585                                        success = 1; 
    25912586                        } 
    2592                         pktlen = bf_ff->bf_skb->len;    /* NB: don't reference skb below */ 
    2593                         /* NB: ath_tx_start() will use ATH_TXBUF_LOCK_BH(). The _BH 
    2594                          *     portion is not needed here since we're running at 
    2595                          *     interrupt time, but should be harmless. 
    2596                          */ 
    2597                         if (ath_tx_start(dev, ni, bf_ff, bf_ff->bf_skb, 0)) 
    2598                                 goto ff_flushbad; 
    2599                         goto ff_flushdone; 
    2600                 ff_flushbad: 
    2601                         DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
    2602                                 "%s: ff stageq flush failure\n", __func__); 
    2603                         ieee80211_unref_node(&ni); 
    2604                         if (bf_ff->bf_skb) { 
    2605                                 dev_kfree_skb(bf_ff->bf_skb); 
    2606                                 bf_ff->bf_skb = NULL; 
    2607                         } 
    2608                         bf_ff->bf_node = NULL; 
    26092587 
    2610                         ATH_TXBUF_LOCK(sc); 
    2611                         STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf_ff, bf_list); 
    2612                         ATH_TXBUF_UNLOCK(sc); 
    2613                         goto ff_flushdone; 
     2588                        if (!success) { 
     2589                                DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
     2590                                        "%s: ff stageq flush failure\n", __func__); 
     2591                                ieee80211_unref_node(&ni); 
     2592                                if (bf_ff->bf_skb) { 
     2593                                        dev_kfree_skb(bf_ff->bf_skb); 
     2594                                        bf_ff->bf_skb = NULL; 
     2595                                } 
     2596                                bf_ff->bf_node = NULL; 
     2597 
     2598                                ATH_TXBUF_LOCK_IRQ(sc); 
     2599                                STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf_ff, bf_list); 
     2600                                ATH_TXBUF_UNLOCK_IRQ(sc); 
     2601                        } 
    26142602                } 
    26152603                /* 
    26162604                 * XXX: out-of-order condition only occurs for AP mode and multicast. 
     
    26192607                else if (an->an_tx_ffbuf[skb->priority]) { 
    26202608                        DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
    26212609                                "%s: Out-Of-Order fast-frame\n", __func__); 
    2622                         ATH_TXQ_UNLOCK(txq); 
    2623                 } else 
    2624                         ATH_TXQ_UNLOCK(txq); 
    2625  
    2626         ff_flushdone: 
     2610                } 
     2611                 
    26272612                ATH_HARDSTART_GET_TX_BUF_WITH_LOCK; 
    2628                 if (bf == NULL) 
     2613                if (bf == NULL) { 
     2614                        ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 
    26292615                        goto hardstart_fail; 
     2616                } 
    26302617        } 
     2618         
     2619        ATH_TXQ_UNLOCK_IRQ(txq); 
    26312620 
    26322621ff_bypass: 
    26332622 
     
    26552644                 *  Allocate 1 ath_buf for each frame given 1 was  
    26562645                 *  already alloc'd 
    26572646                 */ 
    2658                 ATH_TXBUF_LOCK(sc); 
     2647                ATH_TXBUF_LOCK_IRQ(sc); 
    26592648                for (bfcnt = 1; bfcnt < framecnt; ++bfcnt) { 
    26602649                        if ((tbf = STAILQ_FIRST(&sc->sc_txbuf)) != NULL) { 
    26612650                                STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list); 
     
    26762665                                        STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list); 
    26772666                                } 
    26782667                        } 
    2679                         ATH_TXBUF_UNLOCK(sc); 
     2668                        ATH_TXBUF_UNLOCK_IRQ_EARLY(sc); 
    26802669                        STAILQ_INIT(&bf_head); 
    26812670                        goto hardstart_fail; 
    26822671                } 
    2683                 ATH_TXBUF_UNLOCK(sc); 
     2672                ATH_TXBUF_UNLOCK_IRQ(sc); 
    26842673 
    26852674                while ((bf = STAILQ_FIRST(&bf_head)) != NULL && skb != NULL) { 
    26862675                        unsigned int nextfraglen = 0; 
     
    27162705 
    27172706hardstart_fail: 
    27182707        if (!STAILQ_EMPTY(&bf_head)) { 
    2719                 ATH_TXBUF_LOCK(sc); 
     2708                ATH_TXBUF_LOCK_IRQ(sc); 
    27202709                STAILQ_FOREACH_SAFE(tbf, &bf_head, bf_list, tempbf) { 
    27212710                        tbf->bf_skb = NULL; 
    27222711                        tbf->bf_node = NULL; 
     
    27262715 
    27272716                        STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list); 
    27282717                } 
    2729                 ATH_TXBUF_UNLOCK(sc); 
     2718                ATH_TXBUF_UNLOCK_IRQ(sc); 
    27302719        } 
    27312720 
    27322721        /* free sk_buffs */ 
     
    27812770                ATH_SCHEDULE_TQUEUE(&sc->sc_txtq, NULL); 
    27822771        } 
    27832772        ATH_TXBUF_UNLOCK_IRQ(sc); 
     2773 
    27842774        if (bf == NULL) { 
    27852775                printk("ath_mgtstart: discard, no xmit buf\n"); 
    27862776                sc->sc_stats.ast_tx_nobufmgt++; 
     
    40484038                 * Move everything from the VAP's mcast queue  
    40494039                 * to the hardware cab queue. 
    40504040                 */ 
    4051                 ATH_TXQ_LOCK(&avp->av_mcastq); 
    4052                 ATH_TXQ_LOCK(cabq); 
     4041                ATH_TXQ_LOCK_IRQ(&avp->av_mcastq); 
     4042                ATH_TXQ_LOCK_IRQ(cabq); 
    40534043                bfmcast = STAILQ_FIRST(&avp->av_mcastq.axq_q); 
    40544044                /* link the descriptors */ 
    40554045                if (cabq->axq_link == NULL) 
     
    40724062                ATH_TXQ_MOVE_MCASTQ(&avp->av_mcastq, cabq); 
    40734063                /* NB: gated by beacon so safe to start here */ 
    40744064                ath_hal_txstart(ah, cabq->axq_qnum); 
    4075                 ATH_TXQ_UNLOCK(cabq); 
    4076                 ATH_TXQ_UNLOCK(&avp->av_mcastq); 
     4065                ATH_TXQ_UNLOCK_IRQ(cabq); 
     4066                ATH_TXQ_UNLOCK_IRQ(&avp->av_mcastq); 
    40774067        } 
    40784068 
    40794069        return bf; 
     
    47424732                ni->ni_flags &= ~IEEE80211_NODE_UAPSD_SP; 
    47434733        } 
    47444734        ATH_NODE_UAPSD_UNLOCK_IRQ(an); 
     4735 
    47454736        while (an->an_uapsd_qdepth) { 
    47464737                bf = STAILQ_FIRST(&an->an_uapsd_q); 
    47474738                STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); 
     
    48574848                index = WME_AC_VO; 
    48584849                while (index >= WME_AC_BE && txq != sc->sc_ac2q[index]) {  
    48594850                        txq = sc->sc_ac2q[index];  
    4860                         ATH_TXQ_LOCK(txq); 
     4851 
     4852                        ATH_TXQ_LOCK_IRQ(txq); 
    48614853                        ath_hal_stoptxdma(ah, txq->axq_qnum); 
    48624854                        bf = prev = STAILQ_FIRST(&txq->axq_q); 
    48634855                        /* 
     
    49404932                        } else 
    49414933                                txq->axq_link = NULL; 
    49424934 
    4943                         ATH_TXQ_UNLOCK(txq); 
     4935                        ATH_TXQ_UNLOCK_IRQ(txq); 
     4936 
    49444937                        /* 
    49454938                         * restart the DMA from the first  
    49464939                         * buffer that was not DMA'd. 
     
    49664959                        skb = bf->bf_skb; 
    49674960                        bf->bf_skb = NULL; 
    49684961                        bf->bf_node = NULL; 
    4969                         ATH_TXBUF_LOCK(sc); 
     4962                         
     4963                        ATH_TXBUF_LOCK_IRQ(sc); 
    49704964                        STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 
    4971                         ATH_TXBUF_UNLOCK(sc); 
     4965                        ATH_TXBUF_UNLOCK_IRQ(sc); 
     4966                         
    49724967                        ath_hardstart(skb,sc->sc_dev); 
    49734968                        ATH_TXQ_REMOVE_HEAD(&tmp_q, bf_list); 
    49744969                        bf = STAILQ_FIRST(&tmp_q.axq_q); 
     
    49904985                for (index = 0; index <= WME_AC_VO; index++) 
    49914986                        STAILQ_INIT(&wme_tmp_qs[index].axq_q); 
    49924987                txq = sc->sc_xrtxq;  
    4993                 ATH_TXQ_LOCK(txq); 
     4988                 
     4989                ATH_TXQ_LOCK_IRQ(txq); 
    49944990                ath_hal_stoptxdma(ah, txq->axq_qnum); 
    49954991                bf = prev = STAILQ_FIRST(&txq->axq_q); 
    49964992                /* 
     
    50935089                         */ 
    50945090                        txq->axq_link = NULL; 
    50955091                } 
    5096                 ATH_TXQ_UNLOCK(txq); 
     5092                ATH_TXQ_UNLOCK_IRQ(txq); 
     5093                 
    50975094                /* 
    50985095                 * restart the DMA from the first  
    50995096                 * buffer that was not DMA'd. 
     
    51025099                        bf = STAILQ_NEXT(bf_tmp1,bf_list); 
    51035100                else 
    51045101                        bf = STAILQ_FIRST(&txq->axq_q); 
     5102 
    51055103                if (bf) {        
    51065104                        ath_hal_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); 
    51075105                        ath_hal_txstart(ah, txq->axq_qnum); 
    51085106                } 
    51095107 
    5110                 /*  
    5111                  * move (concant) the lists from the temp sw queues in to 
    5112                  * WME queues. 
    5113                  */ 
     5108                /* Move (concat.) the lists from the temp. SW queues in to 
     5109                 * WME queues. */ 
    51145110                index = WME_AC_VO; 
    5115                 txq = NULL; 
    5116                 while (index >= WME_AC_BE) {  
    5117                         prevq = txq; 
     5111                while (index >= WME_AC_BE) { 
    51185112                        txq = sc->sc_ac2q[index]; 
    5119                         if (txq != prevq) { 
    5120                                 ATH_TXQ_LOCK(txq); 
    5121                                 ath_hal_stoptxdma(ah, txq->axq_qnum); 
    5122                         } 
    51235113                         
    5124                         wmeq = &wme_tmp_qs[index]; 
    5125                         bf = STAILQ_FIRST(&wmeq->axq_q); 
    5126                         if (bf) { 
    5127                                 ATH_TXQ_MOVE_Q(wmeq,txq); 
    5128                                 if (txq->axq_link != NULL) { 
     5114                        ATH_TXQ_LOCK_IRQ(txq); 
     5115                        ath_hal_stoptxdma(ah, txq->axq_qnum); 
     5116 
     5117                        while ((txq == sc->sc_ac2q[index]) && (index >= WME_AC_BE)) { 
     5118                                wmeq = &wme_tmp_qs[index]; 
     5119                                bf = STAILQ_FIRST(&wmeq->axq_q); 
     5120                                if (bf) { 
     5121                                        ATH_TXQ_MOVE_Q(wmeq, txq); 
     5122                                        if (txq->axq_link != NULL) { 
    51295123#ifdef AH_NEED_DESC_SWAP 
    5130                                         *(txq->axq_link) = cpu_to_le32(bf->bf_daddr); 
     5124                                               *(txq->axq_link) = cpu_to_le32(bf->bf_daddr); 
    51315125#else 
    5132                                         *(txq->axq_link) = bf->bf_daddr; 
     5126                                               *(txq->axq_link) = bf->bf_daddr; 
    51335127#endif 
    5134                                 }  
     5128                                        }  
     5129                                } 
     5130                                index--; 
    51355131                        } 
    5136                         if (index == WME_AC_BE || txq != prevq) { 
    5137                                 /*  
    5138                                  * find the first buffer to be DMA'd. 
    5139                                  */ 
    5140                                 bf = STAILQ_FIRST(&txq->axq_q); 
    5141                                 while (bf) { 
     5132 
     5133                        /* Find the first buffer to be DMA'd. */ 
     5134                        bf = STAILQ_FIRST(&txq->axq_q); 
     5135                        while (bf) { 
    51425136#ifdef ATH_SUPERG_FF 
    5143                                        ds = &bf->bf_desc[bf->bf_numdescff]; 
     5137                                ds = &bf->bf_desc[bf->bf_numdescff]; 
    51445138#else 
    5145                                        ds = bf->bf_desc;      /* NB: last descriptor */ 
     5139                                ds = bf->bf_desc;     /* NB: last descriptor */ 
    51465140#endif 
    5147                                         ts = &bf->bf_dsstatus.ds_txstat; 
    5148                                         status = ath_hal_txprocdesc(ah, ds, ts); 
    5149                                         if (status == HAL_EINPROGRESS) 
    5150                                                 break;  
    5151                                         bf = STAILQ_NEXT(bf,bf_list); 
    5152                                 } 
    5153                                 if (bf) { 
    5154                                         ath_hal_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); 
    5155                                         ath_hal_txstart(ah, txq->axq_qnum); 
    5156                                 } 
    5157                                 ATH_TXQ_UNLOCK(txq); 
     5141                                ts = &bf->bf_dsstatus.ds_txstat; 
     5142                                status = ath_hal_txprocdesc(ah, ds, ts); 
     5143                                if (status == HAL_EINPROGRESS) 
     5144                                        break;  
     5145                                bf = STAILQ_NEXT(bf, bf_list); 
    51585146                        } 
    5159                         index--; 
     5147 
     5148                        if (bf) { 
     5149                                ath_hal_puttxbuf(ah, txq->axq_qnum, bf->bf_daddr); 
     5150                                ath_hal_txstart(ah, txq->axq_qnum); 
     5151                        } 
     5152                         
     5153                        ATH_TXQ_UNLOCK_IRQ(txq); 
    51605154                } 
     5155 
    51615156                printk("moved %d buffers from XR to NORMAL\n", count); 
    51625157        } 
    51635158#endif 
     
    55785573                         * Reject error frames if we have no vaps that  
    55795574                         * are operating in monitor mode. 
    55805575                         */ 
    5581                         if(sc->sc_nmonvaps == 0) goto rx_next; 
     5576                        if (sc->sc_nmonvaps == 0) 
     5577                                goto rx_next; 
    55825578                } 
    55835579rx_accept: 
    55845580                /* 
     
    56565652                 * Normal receive. 
    56575653                 */ 
    56585654 
    5659                 if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) { 
     5655                if (IFF_DUMPPKTS(sc, ATH_DEBUG_RECV)) 
    56605656                        ieee80211_dump_pkt(ic, skb->data, skb->len, 
    56615657                                   sc->sc_hwmap[rs->rs_rate].ieeerate, 
    56625658                                   rs->rs_rssi); 
    5663                 } 
    56645659 
    56655660                /* 
    56665661                 * Locate the node for sender, track state, and then 
     
    61186113 
    61196114        /* move the grppool bufs back to the grppollbuf */ 
    61206115        for (;;) { 
    6121                 ATH_TXQ_LOCK(txq); 
     6116                ATH_TXQ_LOCK_IRQ(txq); 
    61226117                bf = STAILQ_FIRST(&txq->axq_q); 
    61236118                if (bf == NULL) { 
    61246119                        txq->axq_link = NULL; 
    6125                         ATH_TXQ_UNLOCK(txq); 
     6120                        ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 
    61266121                        break; 
    61276122                } 
    61286123                ATH_TXQ_REMOVE_HEAD(txq, bf_list); 
    6129                 ATH_TXQ_UNLOCK(txq); 
     6124                ATH_TXQ_UNLOCK_IRQ(txq); 
     6125 
    61306126                bus_unmap_single(sc->sc_bdev, 
    61316127                        bf->bf_skbaddr, bf->bf_skb->len, BUS_DMA_TODEVICE); 
    61326128                dev_kfree_skb(bf->bf_skb); 
    61336129                bf->bf_skb = NULL; 
    61346130                bf->bf_node = NULL; 
    61356131 
    6136                 ATH_TXBUF_LOCK(sc); 
     6132                ATH_TXBUF_LOCK_IRQ(sc); 
    61376133                STAILQ_INSERT_TAIL(&sc->sc_grppollbuf, bf, bf_list); 
    6138                 ATH_TXBUF_UNLOCK(sc); 
     6134                ATH_TXBUF_UNLOCK_IRQ(sc); 
    61396135        } 
    61406136        STAILQ_INIT(&txq->axq_q); 
    61416137        ATH_TXQ_LOCK_INIT(txq); 
     
    64976493                dev_kfree_skb(lastbuf->bf_skb); 
    64986494                lastbuf->bf_skb = NULL; 
    64996495                ieee80211_unref_node(&lastbuf->bf_node); 
     6496 
    65006497                ATH_TXBUF_LOCK_IRQ(sc); 
    65016498                STAILQ_INSERT_TAIL(&sc->sc_txbuf, lastbuf, bf_list); 
    65026499                ATH_TXBUF_UNLOCK_IRQ(sc); 
     
    71277124        struct ath_hal *ah = sc->sc_ah; 
    71287125        struct ath_buf *bf = NULL; 
    71297126        struct ath_desc *ds = NULL; 
    7130         struct ath_tx_status *ts
     7127        struct ath_tx_status *ts = NULL
    71317128        struct ieee80211_node *ni = NULL; 
    71327129        struct ath_node *an = NULL; 
    71337130        unsigned int sr, lr; 
    71347131        HAL_STATUS status; 
    71357132        int uapsdq = 0; 
    7136         unsigned long uapsdq_lockflags = 0; 
    71377133        u_int64_t tsf = 0; /* Only needed for monitor mode */ 
    71387134         
    71397135        DPRINTF(sc, ATH_DEBUG_TX_PROC, "%s: tx queue %d (0x%x), link %p\n", __func__, 
     
    71497145        } 
    71507146 
    71517147        for (;;) { 
    7152                 if (uapsdq) 
    7153                         ATH_TXQ_UAPSDQ_LOCK_IRQ(txq); 
    7154                 else 
    7155                         ATH_TXQ_LOCK(txq); 
     7148                ATH_TXQ_LOCK_IRQ(txq); 
     7149 
    71567150                txq->axq_intrcnt = 0; /* reset periodic desc intr count */ 
    71577151                bf = STAILQ_FIRST(&txq->axq_q); 
    71587152                if (bf == NULL) { 
    71597153                        txq->axq_link = NULL; 
    7160                         if (uapsdq) 
    7161                                 ATH_TXQ_UAPSDQ_UNLOCK_IRQ(txq); 
    7162                         else 
    7163                                 ATH_TXQ_UNLOCK(txq); 
     7154                        ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 
    71647155                        break; 
    71657156                } 
    71667157 
     
    71787169                        ath_printtxbuf(bf, status == HAL_OK); 
    71797170#endif 
    71807171                if (status == HAL_EINPROGRESS) { 
    7181                         if (uapsdq) 
    7182                                 ATH_TXQ_UAPSDQ_UNLOCK_IRQ(txq); 
    7183                         else 
    7184                                 ATH_TXQ_UNLOCK(txq); 
     7172                        ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 
    71857173                        break; 
    71867174                } 
    71877175 
    71887176                ATH_TXQ_REMOVE_HEAD(txq, bf_list); 
    7189                 if (uapsdq) 
    7190                         ATH_TXQ_UAPSDQ_UNLOCK_IRQ(txq); 
    7191                 else 
    7192                         ATH_TXQ_UNLOCK(txq); 
     7177                ATH_TXQ_UNLOCK_IRQ(txq); 
    71937178 
    71947179                ni = bf->bf_node; 
    71957180                if (ni != NULL) { 
     
    74657450         *     we do not need to block ath_tx_tasklet 
    74667451         */ 
    74677452        for (;;) { 
    7468                 ATH_TXQ_LOCK(txq); 
     7453                ATH_TXQ_LOCK_IRQ(txq); 
    74697454                bf = STAILQ_FIRST(&txq->axq_q); 
    74707455                if (bf == NULL) { 
    74717456                        txq->axq_link = NULL; 
    7472                         ATH_TXQ_UNLOCK(txq); 
     7457                        ATH_TXQ_UNLOCK_IRQ_EARLY(txq); 
    74737458                        break; 
    74747459                } 
    74757460                ATH_TXQ_REMOVE_HEAD(txq, bf_list); 
    7476                 ATH_TXQ_UNLOCK(txq); 
     7461                ATH_TXQ_UNLOCK_IRQ(txq); 
    74777462#ifdef AR_DEBUG 
    74787463                if (sc->sc_debug & ATH_DEBUG_RESET) 
    74797464                        ath_printtxbuf(bf, ath_hal_txprocdesc(ah, bf->bf_desc, &bf->bf_dsstatus.ds_txstat) == HAL_OK); 
     
    75007485                bf->bf_skb = NULL; 
    75017486                bf->bf_node = NULL; 
    75027487 
    7503                 ATH_TXBUF_LOCK(sc); 
     7488                ATH_TXBUF_LOCK_IRQ(sc); 
    75047489                STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 
    7505                 ATH_TXBUF_UNLOCK(sc); 
     7490                ATH_TXBUF_UNLOCK_IRQ(sc); 
    75067491        } 
    75077492} 
    75087493 
     
    76977682                sc->sc_curchan.channelFlags), sc->sc_curchan.channel, 
    76987683                ath_hal_mhz2ieee(ah, hchan.channel, hchan.channelFlags), 
    76997684                hchan.channel); 
     7685         
    77007686        /* check if it is turbo mode switch */ 
    77017687        if (hchan.channel == sc->sc_curchan.channel && 
    77027688           (hchan.channelFlags & IEEE80211_CHAN_TURBO) != (sc->sc_curchan.channelFlags & IEEE80211_CHAN_TURBO))  
    77037689                tswitch = 1; 
     7690         
    77047691        if (hchan.channel != sc->sc_curchan.channel || 
    77057692            hchan.channelFlags != sc->sc_curchan.channelFlags) { 
    77067693                HAL_STATUS status; 
     
    77677754                                        sc->sc_dfswaittimer.data = (unsigned long)sc; 
    77687755                                        add_timer(&sc->sc_dfswaittimer); 
    77697756                                } 
    7770                         } else 
    7771                                 if (sc->sc_dfswait == 1) 
    7772                                         mod_timer(&sc->sc_dfswaittimer, jiffies + 2); 
     7757                        } else if (sc->sc_dfswait == 1) 
     7758                                mod_timer(&sc->sc_dfswaittimer, jiffies + 2); 
    77737759                } 
    77747760                /* 
    77757761                 * re configure beacons when it is a turbo mode switch.