Skip to content

Commit

Permalink
mac80211: remove dev_hold/put calls
Browse files Browse the repository at this point in the history
If we move the rcu sections a little, there's
no need to touch the device refcount.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Nov 18, 2009
1 parent 5f0b7de commit d84f323
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions net/mac80211/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,8 +1430,6 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
int headroom;
bool may_encrypt;

dev_hold(sdata->dev);

if (need_dynamic_ps(local)) {
if (local->hw.conf.flags & IEEE80211_CONF_PS) {
ieee80211_stop_queues_by_reason(&local->hw,
Expand All @@ -1446,6 +1444,8 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,

info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS;

rcu_read_lock();

if (unlikely(sdata->vif.type == NL80211_IFTYPE_MONITOR)) {
int hdrlen;
u16 len_rthdr;
Expand All @@ -1468,7 +1468,6 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
* support we will need a different mechanism.
*/

rcu_read_lock();
list_for_each_entry_rcu(tmp_sdata, &local->interfaces,
list) {
if (!netif_running(tmp_sdata->dev))
Expand All @@ -1477,13 +1476,10 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
continue;
if (compare_ether_addr(tmp_sdata->dev->dev_addr,
hdr->addr2) == 0) {
dev_hold(tmp_sdata->dev);
dev_put(sdata->dev);
sdata = tmp_sdata;
break;
}
}
rcu_read_unlock();
}
}

Expand All @@ -1497,7 +1493,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,

if (ieee80211_skb_resize(local, skb, headroom, may_encrypt)) {
dev_kfree_skb(skb);
dev_put(sdata->dev);
rcu_read_unlock();
return;
}

Expand All @@ -1508,13 +1504,13 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
!is_multicast_ether_addr(hdr->addr1))
if (mesh_nexthop_lookup(skb, sdata)) {
/* skb queued: don't free */
dev_put(sdata->dev);
rcu_read_unlock();
return;
}

ieee80211_select_queue(local, skb);
ieee80211_tx(sdata, skb, false);
dev_put(sdata->dev);
rcu_read_unlock();
}

netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
Expand Down Expand Up @@ -1964,12 +1960,10 @@ void ieee80211_tx_pending(unsigned long data)
}

sdata = vif_to_sdata(info->control.vif);
dev_hold(sdata->dev);
spin_unlock_irqrestore(&local->queue_stop_reason_lock,
flags);

txok = ieee80211_tx_pending_skb(local, skb);
dev_put(sdata->dev);
if (!txok)
__skb_queue_head(&local->pending[i], skb);
spin_lock_irqsave(&local->queue_stop_reason_lock,
Expand Down

0 comments on commit d84f323

Please sign in to comment.