diff options
author | David Daney <ddaney@caviumnetworks.com> | 2010-05-05 15:03:09 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-06 06:22:33 +0200 |
commit | 4d30b8013b2d82138d6900965fe9fcd062f2d06d (patch) | |
tree | a52d03c623016cd9a7716a2641c105e7def47b3f /drivers/net/octeon | |
parent | netdev: octeon_mgmt: Use proper MAC addresses. (diff) | |
download | linux-4d30b8013b2d82138d6900965fe9fcd062f2d06d.tar.xz linux-4d30b8013b2d82138d6900965fe9fcd062f2d06d.zip |
netdev: octeon_mgmt: Fix race condition freeing TX buffers.
Under heavy load the TX cleanup tasklet and xmit threads would race
and try to free too many buffers.
Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/octeon')
-rw-r--r-- | drivers/net/octeon/octeon_mgmt.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/net/octeon/octeon_mgmt.c b/drivers/net/octeon/octeon_mgmt.c index bbbd737210f9..b975a2fad953 100644 --- a/drivers/net/octeon/octeon_mgmt.c +++ b/drivers/net/octeon/octeon_mgmt.c @@ -189,12 +189,19 @@ static void octeon_mgmt_clean_tx_buffers(struct octeon_mgmt *p) mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port)); while (mix_orcnt.s.orcnt) { + spin_lock_irqsave(&p->tx_list.lock, flags); + + mix_orcnt.u64 = cvmx_read_csr(CVMX_MIXX_ORCNT(port)); + + if (mix_orcnt.s.orcnt == 0) { + spin_unlock_irqrestore(&p->tx_list.lock, flags); + break; + } + dma_sync_single_for_cpu(p->dev, p->tx_ring_handle, ring_size_to_bytes(OCTEON_MGMT_TX_RING_SIZE), DMA_BIDIRECTIONAL); - spin_lock_irqsave(&p->tx_list.lock, flags); - re.d64 = p->tx_ring[p->tx_next_clean]; p->tx_next_clean = (p->tx_next_clean + 1) % OCTEON_MGMT_TX_RING_SIZE; |