mv643xx_eth: Fix race condition in mv643xx_eth_free_tx_descs
Subsystems (2)
PATCH 1/1 mv643xx_eth: Fix race condition in mv643xx_eth_free_tx_descs
Quoted 1 line
From Dale Farnsworth <[email protected]>
mv643xx_eth: Fix race condition in mv643xx_eth_free_tx_descs
This bug was found and isolated by Thibaut VARENE <[email protected]> and Jarek Poplawski <[email protected]>. This patch is a modification of their fixes. We acquire and release the lock for each descriptor that is freed to minimize the time the lock is held.
---
drivers/net/mv643xx_eth.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/mv643xx_eth.c +9 -2
@@ -314,6 +314,13 @@ int mv643xx_eth_free_tx_descs(struct netwhile (mp->tx_desc_count >0 ) {spin_lock_irqsave (&mp->lock, flags); + +/* tx_desc_count might have changed before acquiring the lock */ +if (mp->tx_desc_count <=0 ) { +spin_unlock_irqrestore (&mp->lock, flags); +return released; + } + tx_index = mp->tx_used_desc_q; desc = &mp->p_tx_desc_area[tx_index]; cmd_sts = desc->cmd_sts;
@@ -332,13 +339,13 @@ int mv643xx_eth_free_tx_descs(struct netif (skb) mp->tx_skb[tx_index] =NULL ; -spin_unlock_irqrestore (&mp->lock, flags); -if (cmd_sts Ð_ERROR_SUMMARY ) {printk ("%s: Error in TX\n" , dev->name); mp->stats.tx_errors++; } +spin_unlock_irqrestore (&mp->lock, flags); +if (cmd_sts Ð_TX_FIRST_DESC )dma_unmap_single (NULL , addr, count,DMA_TO_DEVICE );else
Quoted 19 lines · Dale Farnsworth
From Dale Farnsworth <[email protected]>
mv643xx_eth: Fix race condition inmv643xx_eth_free_tx_descsThis bug was found and isolated by Thibaut VARENE <[email protected]> and Jarek Poplawski <[email protected]>. This patch is a modification of their fixes. We acquire and release the lock for each descriptor that is freed to minimize the time the lock is held.
---
drivers/net/mv643xx_eth.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)drivers/net/mv643xx_eth.c +0
-0
drivers/net/mv643xx_eth.c int mv643xx_eth_free_tx_descs(struct net · line 345
Quoted 9 lines
drivers/net/mv643xx_eth.c +0
-2@@ -332,13 +339,13 @@ int mv643xx_eth_free_tx_descs(struct netif (skb) mp->tx_skb[tx_index] =NULL ; -spin_unlock_irqrestore (&mp->lock, flags); -if (cmd_sts Ð_ERROR_SUMMARY ) {printk ("%s: Error in TX\n" , dev->name); mp->stats.tx_errors++; }
Note that this printk probably won't show immediately because IRQs are disabled. But that's maybe not a big deal.
HTH
Signature · 2 lines
Thibaut VARENE http://www.parisc-linux.org/~varenet/
Jeff Garzik
AppliedQuoted 9 lines · Dale Farnsworth
Quoted 1 line
From Dale Farnsworth <[email protected]>
mv643xx_eth: Fix race condition inmv643xx_eth_free_tx_descsThis bug was found and isolated by Thibaut VARENE <[email protected]> and Jarek Poplawski <[email protected]>. This patch is a modification of their fixes. We acquire and release the lock for each descriptor that is freed to minimize the time the lock is held.
Quoted 4 lines
---
drivers/net/mv643xx_eth.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
applied