diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2008-01-10 17:40:59 -0500 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2008-01-17 17:35:09 -0500 |
commit | 0da1b995aee447656c0eb77e4e32468e37f868a3 (patch) | |
tree | c8fc52f334131349d4886b362c766eacd168746e /drivers | |
parent | 227bc24d675d80de1cfb3ab72891cc932dadbc3b (diff) |
ipg: plug Tx completion leak
The Tx skb release could not free more than one skb per call.
Add it to the fact that the xmit handler does not check for
a queue full condition and you have a recipe to leak quickly.
Let's release every pending Tx descriptor which has been given
back to the host CPU by the network controller. The xmit handler
suggests that it is done through the IPG_TFC_TFDDONE bit.
Remove the former "curr" computing: it does not produce anything
usable in its current form.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ipg.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c index cd1650e99369..9752902f2d9a 100644 --- a/drivers/net/ipg.c +++ b/drivers/net/ipg.c | |||
@@ -857,21 +857,14 @@ static void init_tfdlist(struct net_device *dev) | |||
857 | static void ipg_nic_txfree(struct net_device *dev) | 857 | static void ipg_nic_txfree(struct net_device *dev) |
858 | { | 858 | { |
859 | struct ipg_nic_private *sp = netdev_priv(dev); | 859 | struct ipg_nic_private *sp = netdev_priv(dev); |
860 | void __iomem *ioaddr = sp->ioaddr; | 860 | unsigned int released, pending, dirty; |
861 | unsigned int curr; | ||
862 | u64 txd_map; | ||
863 | unsigned int released, pending; | ||
864 | |||
865 | txd_map = (u64)sp->txd_map; | ||
866 | curr = ipg_r32(TFD_LIST_PTR_0) - | ||
867 | do_div(txd_map, sizeof(struct ipg_tx)) - 1; | ||
868 | 861 | ||
869 | IPG_DEBUG_MSG("_nic_txfree\n"); | 862 | IPG_DEBUG_MSG("_nic_txfree\n"); |
870 | 863 | ||
871 | pending = sp->tx_current - sp->tx_dirty; | 864 | pending = sp->tx_current - sp->tx_dirty; |
865 | dirty = sp->tx_dirty % IPG_TFDLIST_LENGTH; | ||
872 | 866 | ||
873 | for (released = 0; released < pending; released++) { | 867 | for (released = 0; released < pending; released++) { |
874 | unsigned int dirty = sp->tx_dirty % IPG_TFDLIST_LENGTH; | ||
875 | struct sk_buff *skb = sp->TxBuff[dirty]; | 868 | struct sk_buff *skb = sp->TxBuff[dirty]; |
876 | struct ipg_tx *txfd = sp->txd + dirty; | 869 | struct ipg_tx *txfd = sp->txd + dirty; |
877 | 870 | ||
@@ -882,11 +875,8 @@ static void ipg_nic_txfree(struct net_device *dev) | |||
882 | * If the TFDDone bit is set, free the associated | 875 | * If the TFDDone bit is set, free the associated |
883 | * buffer. | 876 | * buffer. |
884 | */ | 877 | */ |
885 | if (dirty == curr) | 878 | if (!(txfd->tfc & cpu_to_le64(IPG_TFC_TFDDONE))) |
886 | break; | 879 | break; |
887 | |||
888 | /* Setup TFDDONE for compatible issue. */ | ||
889 | txfd->tfc |= cpu_to_le64(IPG_TFC_TFDDONE); | ||
890 | 880 | ||
891 | /* Free the transmit buffer. */ | 881 | /* Free the transmit buffer. */ |
892 | if (skb) { | 882 | if (skb) { |
@@ -898,6 +888,7 @@ static void ipg_nic_txfree(struct net_device *dev) | |||
898 | 888 | ||
899 | sp->TxBuff[dirty] = NULL; | 889 | sp->TxBuff[dirty] = NULL; |
900 | } | 890 | } |
891 | dirty = (dirty + 1) % IPG_TFDLIST_LENGTH; | ||
901 | } | 892 | } |
902 | 893 | ||
903 | sp->tx_dirty += released; | 894 | sp->tx_dirty += released; |