Commit cf68636a authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville

b43: Refresh RX poison on buffer recycling

The RX buffer poison needs to be refreshed, if we recycle an RX buffer,
because it might be (partially) overwritten by some DMA operations.

Cc: stable@kernel.org
Cc: Francesco Gringoli <francesco.gringoli@ing.unibs.it>
Signed-off-by: default avatarMichael Buesch <mb@bu3sch.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent ec9a1d8c
...@@ -1503,20 +1503,16 @@ static void dma_rx(struct b43_dmaring *ring, int *slot) ...@@ -1503,20 +1503,16 @@ static void dma_rx(struct b43_dmaring *ring, int *slot)
len = le16_to_cpu(rxhdr->frame_len); len = le16_to_cpu(rxhdr->frame_len);
} while (len == 0 && i++ < 5); } while (len == 0 && i++ < 5);
if (unlikely(len == 0)) { if (unlikely(len == 0)) {
/* recycle the descriptor buffer. */ dmaaddr = meta->dmaaddr;
sync_descbuffer_for_device(ring, meta->dmaaddr, goto drop_recycle_buffer;
ring->rx_buffersize);
goto drop;
} }
} }
if (unlikely(b43_rx_buffer_is_poisoned(ring, skb))) { if (unlikely(b43_rx_buffer_is_poisoned(ring, skb))) {
/* Something went wrong with the DMA. /* Something went wrong with the DMA.
* The device did not touch the buffer and did not overwrite the poison. */ * The device did not touch the buffer and did not overwrite the poison. */
b43dbg(ring->dev->wl, "DMA RX: Dropping poisoned buffer.\n"); b43dbg(ring->dev->wl, "DMA RX: Dropping poisoned buffer.\n");
/* recycle the descriptor buffer. */ dmaaddr = meta->dmaaddr;
sync_descbuffer_for_device(ring, meta->dmaaddr, goto drop_recycle_buffer;
ring->rx_buffersize);
goto drop;
} }
if (unlikely(len > ring->rx_buffersize)) { if (unlikely(len > ring->rx_buffersize)) {
/* The data did not fit into one descriptor buffer /* The data did not fit into one descriptor buffer
...@@ -1530,6 +1526,7 @@ static void dma_rx(struct b43_dmaring *ring, int *slot) ...@@ -1530,6 +1526,7 @@ static void dma_rx(struct b43_dmaring *ring, int *slot)
while (1) { while (1) {
desc = ops->idx2desc(ring, *slot, &meta); desc = ops->idx2desc(ring, *slot, &meta);
/* recycle the descriptor buffer. */ /* recycle the descriptor buffer. */
b43_poison_rx_buffer(ring, meta->skb);
sync_descbuffer_for_device(ring, meta->dmaaddr, sync_descbuffer_for_device(ring, meta->dmaaddr,
ring->rx_buffersize); ring->rx_buffersize);
*slot = next_slot(ring, *slot); *slot = next_slot(ring, *slot);
...@@ -1548,8 +1545,7 @@ static void dma_rx(struct b43_dmaring *ring, int *slot) ...@@ -1548,8 +1545,7 @@ static void dma_rx(struct b43_dmaring *ring, int *slot)
err = setup_rx_descbuffer(ring, desc, meta, GFP_ATOMIC); err = setup_rx_descbuffer(ring, desc, meta, GFP_ATOMIC);
if (unlikely(err)) { if (unlikely(err)) {
b43dbg(ring->dev->wl, "DMA RX: setup_rx_descbuffer() failed\n"); b43dbg(ring->dev->wl, "DMA RX: setup_rx_descbuffer() failed\n");
sync_descbuffer_for_device(ring, dmaaddr, ring->rx_buffersize); goto drop_recycle_buffer;
goto drop;
} }
unmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0); unmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0);
...@@ -1559,6 +1555,11 @@ static void dma_rx(struct b43_dmaring *ring, int *slot) ...@@ -1559,6 +1555,11 @@ static void dma_rx(struct b43_dmaring *ring, int *slot)
b43_rx(ring->dev, skb, rxhdr); b43_rx(ring->dev, skb, rxhdr);
drop: drop:
return; return;
drop_recycle_buffer:
/* Poison and recycle the RX buffer. */
b43_poison_rx_buffer(ring, skb);
sync_descbuffer_for_device(ring, dmaaddr, ring->rx_buffersize);
} }
void b43_dma_rx(struct b43_dmaring *ring) void b43_dma_rx(struct b43_dmaring *ring)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment