Skip to content

Commit 39ca5bb

Browse files
Christian Lamparterlinvjw
authored andcommitted
p54: enforce strict tx_queue limits
The patch fixes an old FIXME in p54pci.c by moving the "queue full" check into the common library, where we can deal with it properly. Signed-off-by: Christian Lamparter <[email protected]> Signed-off-by: John W. Linville <[email protected]>
1 parent 30dab79 commit 39ca5bb

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

drivers/net/wireless/p54/p54common.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,27 @@ static int p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb,
874874
return -EINVAL;
875875

876876
spin_lock_irqsave(&priv->tx_queue.lock, flags);
877+
877878
left = skb_queue_len(&priv->tx_queue);
879+
if (unlikely(left >= 28)) {
880+
/*
881+
* The tx_queue is nearly full!
882+
* We have throttle normal data traffic, because we must
883+
* have a few spare slots for control frames left.
884+
*/
885+
ieee80211_stop_queues(dev);
886+
887+
if (unlikely(left == 32)) {
888+
/*
889+
* The tx_queue is now really full.
890+
*
891+
* TODO: check if the device has crashed and reset it.
892+
*/
893+
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
894+
return -ENOSPC;
895+
}
896+
}
897+
878898
while (left--) {
879899
u32 hole_size;
880900
info = IEEE80211_SKB_CB(entry);
@@ -903,7 +923,7 @@ static int p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb,
903923
if (!target_skb) {
904924
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
905925
ieee80211_stop_queues(dev);
906-
return -ENOMEM;
926+
return -ENOSPC;
907927
}
908928

909929
info = IEEE80211_SKB_CB(skb);

drivers/net/wireless/p54/p54pci.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,6 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
332332

333333
P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
334334
P54P_READ(dev_int);
335-
336-
/* FIXME: unlikely to happen because the device usually runs out of
337-
memory before we fill the ring up, but we can make it impossible */
338-
if (idx - device_idx > ARRAY_SIZE(ring_control->tx_data) - 2) {
339-
p54_free_skb(dev, skb);
340-
printk(KERN_INFO "%s: tx overflow.\n", wiphy_name(dev->wiphy));
341-
}
342335
}
343336

344337
static void p54p_stop(struct ieee80211_hw *dev)

0 commit comments

Comments
 (0)