mac80211: do not use irq locks where not necessary
Johannes Berg
maintainerExcept for places where we take locks that we need in functions exported to drivers (which might call them in interrupt context) we don't need to ever disable IRQs in mac80211, just softirqs.
Signed-off-by Johannes Berg <[email protected]>
---
This patch works fine here, and would seem to be correct based on the description ;) but so far I've only tried with ar9170 (USB) I think.
net/mac80211/key.c | 33 +++++++++--------------- net/mac80211/pm.c | 5 +-- net/mac80211/rc80211_pid_debugfs.c | 15 ++++------- net/mac80211/sta_info.c | 49 ++++++++++++++----------------------- net/mac80211/sta_info.h | 33 +++++++++--------------- net/mac80211/tx.c | 11 +++----- net/mac80211/util.c | 9 +++--- 7 files changed, 59 insertions(+), 96 deletions(-)
net/mac80211/key.c +12 -21
@@ -211,11 +211,9 @@ static void __ieee80211_set_default_key(void ieee80211_set_default_key (struct ieee80211_sub_if_data *sdata,int idx) { -unsigned long flags; - -spin_lock_irqsave (&sdata->local->key_lock, flags); +spin_lock_bh (&sdata->local->key_lock);__ieee80211_set_default_key (sdata, idx); -spin_unlock_irqrestore (&sdata->local->key_lock, flags); +spin_unlock_bh (&sdata->local->key_lock); } static void
@@ -236,11 +234,9 @@ __ieee80211_set_default_mgmt_key(structvoid ieee80211_set_default_mgmt_key (struct ieee80211_sub_if_data *sdata,int idx) { -unsigned long flags; - -spin_lock_irqsave (&sdata->local->key_lock, flags); +spin_lock_bh (&sdata->local->key_lock);__ieee80211_set_default_mgmt_key (sdata, idx); -spin_unlock_irqrestore (&sdata->local->key_lock, flags); +spin_unlock_bh (&sdata->local->key_lock); }
@@ -386,7 +382,6 @@ void ieee80211_key_link(struct ieee80211 struct sta_info *sta) {struct ieee80211_key *old_key; -unsigned long flags;int idx;BUG_ON (!sdata);
@@ -430,7 +425,7 @@ void ieee80211_key_link(struct ieee80211 } } -spin_lock_irqsave (&sdata->local->key_lock, flags); +spin_lock_bh (&sdata->local->key_lock);if (sta) old_key = sta->key;
@@ -446,7 +441,7 @@ void ieee80211_key_link(struct ieee80211if (netif_running (sdata->dev))add_todo (key,KEY_FLAG_TODO_HWACCEL_ADD ); -spin_unlock_irqrestore (&sdata->local->key_lock, flags); +spin_unlock_bh (&sdata->local->key_lock); }static void __ieee80211_key_free (struct ieee80211_key *key)
@@ -463,8 +458,6 @@ static void __ieee80211_key_free(structvoid ieee80211_key_free (struct ieee80211_key *key) { -unsigned long flags; -if (!key)return ;
@@ -477,9 +470,9 @@ void ieee80211_key_free(struct ieee80211return ; } -spin_lock_irqsave (&key->sdata->local->key_lock, flags); +spin_lock_bh (&key->sdata->local->key_lock);__ieee80211_key_free (key); -spin_unlock_irqrestore (&key->sdata->local->key_lock, flags); +spin_unlock_bh (&key->sdata->local->key_lock); }/*
@@ -493,14 +486,13 @@ static void ieee80211_todo_for_each_key( u32 todo_flags) {struct ieee80211_key *key; -unsigned long flags;might_sleep (); -spin_lock_irqsave (&sdata->local->key_lock, flags); +spin_lock_bh (&sdata->local->key_lock);list_for_each_entry (key, &sdata->key_list, list)add_todo (key, todo_flags); -spin_unlock_irqrestore (&sdata->local->key_lock, flags); +spin_unlock_bh (&sdata->local->key_lock);ieee80211_key_todo (); }
@@ -608,17 +600,16 @@ void ieee80211_key_todo(void)void ieee80211_free_keys (struct ieee80211_sub_if_data *sdata) {struct ieee80211_key *key, *tmp; -unsigned long flags;ieee80211_key_lock ();ieee80211_debugfs_key_remove_default (sdata);ieee80211_debugfs_key_remove_mgmt_default (sdata); -spin_lock_irqsave (&sdata->local->key_lock, flags); +spin_lock_bh (&sdata->local->key_lock);list_for_each_entry_safe (key, tmp, &sdata->key_list, list)__ieee80211_key_free (key); -spin_unlock_irqrestore (&sdata->local->key_lock, flags); +spin_unlock_bh (&sdata->local->key_lock);__ieee80211_key_todo ();
net/mac80211/pm.c +2 -3
@@ -12,7 +12,6 @@ int __ieee80211_suspend(struct ieee80211struct ieee80211_sub_if_data *sdata;struct ieee80211_if_init_conf conf;struct sta_info *sta; -unsigned long flags;ieee80211_scan_cancel (local);
@@ -65,7 +64,7 @@ int __ieee80211_suspend(struct ieee80211 }/* remove STAs */ -spin_lock_irqsave (&local->sta_lock, flags); +spin_lock_bh (&local->sta_lock);list_for_each_entry (sta, &local->sta_list, list) {if (local->ops->sta_notify) { sdata = sta->sdata;
@@ -80,7 +79,7 @@ int __ieee80211_suspend(struct ieee80211mesh_plink_quiesce (sta); } -spin_unlock_irqrestore (&local->sta_lock, flags); +spin_unlock_bh (&local->sta_lock);/* remove all interfaces */ list_for_each_entry (sdata, &local->interfaces, list) {
net/mac80211/rc80211_pid_debugfs.c +6 -9
@@ -22,9 +22,8 @@ static void rate_control_pid_event(struc union rc_pid_event_data *data) {struct rc_pid_event *ev; -unsigned long status; -spin_lock_irqsave (&buf->lock, status); +spin_lock_bh (&buf->lock); ev = &(buf->ring[buf->next_entry]); buf->next_entry = (buf->next_entry +1 ) %RC_PID_EVENT_RING_SIZE ;
@@ -33,7 +32,7 @@ static void rate_control_pid_event(struc ev->type = type; ev->data = *data; -spin_unlock_irqrestore (&buf->lock, status); +spin_unlock_bh (&buf->lock);wake_up_all (&buf->waitqueue); }
@@ -86,19 +85,18 @@ static int rate_control_pid_events_open(struct rc_pid_sta_info *sinfo = inode->i_private;struct rc_pid_event_buffer *events = &sinfo->events;struct rc_pid_events_file_info *file_info; -unsigned long status;/* Allocate a state struct */ file_info =kmalloc (sizeof (*file_info),GFP_KERNEL );if (file_info ==NULL )return -ENOMEM ; -spin_lock_irqsave (&events->lock, status); +spin_lock_bh (&events->lock); file_info->next_entry = events->next_entry; file_info->events = events; -spin_unlock_irqrestore (&events->lock, status); +spin_unlock_bh (&events->lock); file->private_data = file_info;
@@ -136,7 +134,6 @@ static ssize_t rate_control_pid_events_rchar pb[RC_PID_PRINT_BUF_SIZE ];int ret;int p; -unsigned long status;/* Check if there is something to read. */ if (events->next_entry == file_info->next_entry) {
@@ -153,7 +150,7 @@ static ssize_t rate_control_pid_events_r/* Write out one event per call. I don't care whether it's a little * inefficient, this is debugging code anyway. */ -spin_lock_irqsave (&events->lock, status); +spin_lock_bh (&events->lock);/* Get an event */ ev = &(events->ring[file_info->next_entry]);
@@ -188,7 +185,7 @@ static ssize_t rate_control_pid_events_r } p +=snprintf (pb + p, length - p,"\n" ); -spin_unlock_irqrestore (&events->lock, status); +spin_unlock_bh (&events->lock);if (copy_to_user (buf, pb, p))return -EFAULT ;
net/mac80211/sta_info.c +19 -30
170 lines not on this page · raw message
net/mac80211/sta_info.h +12 -21
@@ -343,41 +343,34 @@ static inline enum plink_state sta_plinkstatic inline void set_sta_flags (struct sta_info *sta,const u32 flags) { -unsigned long irqfl; - -spin_lock_irqsave (&sta->flaglock, irqfl); +spin_lock_bh (&sta->flaglock); sta->flags |= flags; -spin_unlock_irqrestore (&sta->flaglock, irqfl); +spin_unlock_bh (&sta->flaglock); }static inline void clear_sta_flags (struct sta_info *sta,const u32 flags) { -unsigned long irqfl; - -spin_lock_irqsave (&sta->flaglock, irqfl); +spin_lock_bh (&sta->flaglock); sta->flags &= ~flags; -spin_unlock_irqrestore (&sta->flaglock, irqfl); +spin_unlock_bh (&sta->flaglock); }static inline void set_and_clear_sta_flags (struct sta_info *sta,const u32 set,const u32 clear) { -unsigned long irqfl; - -spin_lock_irqsave (&sta->flaglock, irqfl); +spin_lock_bh (&sta->flaglock); sta->flags |= set; sta->flags &= ~clear; -spin_unlock_irqrestore (&sta->flaglock, irqfl); +spin_unlock_bh (&sta->flaglock); }static inline u32 test_sta_flags (struct sta_info *sta,const u32 flags) {u32 ret; -unsigned long irqfl; -spin_lock_irqsave (&sta->flaglock, irqfl); +spin_lock_bh (&sta->flaglock); ret = sta->flags & flags; -spin_unlock_irqrestore (&sta->flaglock, irqfl); +spin_unlock_bh (&sta->flaglock);return ret; }
@@ -386,12 +379,11 @@ static inline u32 test_and_clear_sta_fla const u32 flags) {u32 ret; -unsigned long irqfl; -spin_lock_irqsave (&sta->flaglock, irqfl); +spin_lock_bh (&sta->flaglock); ret = sta->flags & flags; sta->flags &= ~flags; -spin_unlock_irqrestore (&sta->flaglock, irqfl); +spin_unlock_bh (&sta->flaglock);return ret; }
@@ -399,11 +391,10 @@ static inline u32 test_and_clear_sta_flastatic inline u32 get_sta_flags (struct sta_info *sta) {u32 ret; -unsigned long irqfl; -spin_lock_irqsave (&sta->flaglock, irqfl); +spin_lock_bh (&sta->flaglock); ret = sta->flags; -spin_unlock_irqrestore (&sta->flaglock, irqfl); +spin_unlock_bh (&sta->flaglock);return ret; }
net/mac80211/tx.c +4 -7
@@ -1045,13 +1045,12 @@ ieee80211_tx_prepare(struct ieee80211_suif (tx->sta &&ieee80211_is_data_qos (hdr->frame_control) && (local->hw.flags &IEEE80211_HW_AMPDU_AGGREGATION )) { -unsigned long flags;struct tid_ampdu_tx *tid_tx; qc =ieee80211_get_qos_ctl (hdr); tid = *qc &IEEE80211_QOS_CTL_TID_MASK ; -spin_lock_irqsave (&tx->sta->lock, flags); +spin_lock_bh (&tx->sta->lock);/* * XXX: This spinlock could be fairly expensive, but see the * comment in agg-tx.c:ieee80211_agg_tx_operational().
@@ -1075,7 +1074,7 @@ ieee80211_tx_prepare(struct ieee80211_su info->flags |=IEEE80211_TX_INTFL_NEED_TXPROCESSING ;__skb_queue_tail (&tid_tx->pending, skb); } -spin_unlock_irqrestore (&tx->sta->lock, flags); +spin_unlock_bh (&tx->sta->lock);if (unlikely (queued))return TX_QUEUED ;
@@ -2028,11 +2027,9 @@ struct sk_buff *ieee80211_beacon_get(strif (local->tim_in_locked_section) {ieee80211_beacon_add_tim (ap, skb, beacon); }else { -unsigned long flags; - -spin_lock_irqsave (&local->sta_lock, flags); +spin_lock_bh (&local->sta_lock);ieee80211_beacon_add_tim (ap, skb, beacon); -spin_unlock_irqrestore (&local->sta_lock, flags); +spin_unlock_bh (&local->sta_lock); }if (beacon->tail)
net/mac80211/util.c +4 -5
@@ -960,7 +960,6 @@ int ieee80211_reconfig(struct ieee80211_struct ieee80211_sub_if_data *sdata;struct ieee80211_if_init_conf conf;struct sta_info *sta; -unsigned long flags;int res;bool from_suspend = local->suspended;
@@ -991,7 +990,7 @@ int ieee80211_reconfig(struct ieee80211_/* add STAs back */ if (local->ops->sta_notify) { -spin_lock_irqsave (&local->sta_lock, flags); +spin_lock_bh (&local->sta_lock);list_for_each_entry (sta, &local->sta_list, list) { sdata = sta->sdata;if (sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )
@@ -1002,7 +1001,7 @@ int ieee80211_reconfig(struct ieee80211_drv_sta_notify (local, &sdata->vif,STA_NOTIFY_ADD , &sta->sta); } -spin_unlock_irqrestore (&local->sta_lock, flags); +spin_unlock_bh (&local->sta_lock); }/* Clear Suspend state so that ADDBA requests can be processed */
@@ -1092,10 +1091,10 @@ int ieee80211_reconfig(struct ieee80211_add_timer (&local->sta_cleanup); -spin_lock_irqsave (&local->sta_lock, flags); +spin_lock_bh (&local->sta_lock);list_for_each_entry (sta, &local->sta_list, list)mesh_plink_restart (sta); -spin_unlock_irqrestore (&local->sta_lock, flags); +spin_unlock_bh (&local->sta_lock);#else WARN_ON (1 );#endif