Skip to content

Commit 73b82bf

Browse files
thommyjlinvjw
authored andcommitted
B43: Handle DMA RX descriptor underrun
Add handling of rx descriptor underflow. This fixes a fault that could happen on slow machines, where data is received faster than the CPU can handle. In such a case the device will use up all rx descriptors and refuse to send any more data before confirming that it is ok. This patch enables necessary interrupt to discover such a situation and will handle them by dropping everything in the ring buffer. Reviewed-by: Michael Buesch <m@bues.ch> Signed-off-by: Thommy Jakobsson <thommyj@gmail.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent db17834 commit 73b82bf

3 files changed

Lines changed: 40 additions & 26 deletions

File tree

‎drivers/net/wireless/b43/dma.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,25 @@ static void dma_rx(struct b43_dmaring *ring, int *slot)
17331733
sync_descbuffer_for_device(ring, dmaaddr, ring->rx_buffersize);
17341734
}
17351735

1736+
void b43_dma_handle_rx_overflow(struct b43_dmaring *ring)
1737+
{
1738+
int current_slot, previous_slot;
1739+
1740+
B43_WARN_ON(ring->tx);
1741+
1742+
/* Device has filled all buffers, drop all packets and let TCP
1743+
* decrease speed.
1744+
* Decrement RX index by one will let the device to see all slots
1745+
* as free again
1746+
*/
1747+
/*
1748+
*TODO: How to increase rx_drop in mac80211?
1749+
*/
1750+
current_slot = ring->ops->get_current_rxslot(ring);
1751+
previous_slot = prev_slot(ring, current_slot);
1752+
ring->ops->set_current_rxslot(ring, previous_slot);
1753+
}
1754+
17361755
void b43_dma_rx(struct b43_dmaring *ring)
17371756
{
17381757
const struct b43_dma_ops *ops = ring->ops;

‎drivers/net/wireless/b43/dma.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/* DMA-Interrupt reasons. */
1010
#define B43_DMAIRQ_FATALMASK ((1 << 10) | (1 << 11) | (1 << 12) \
1111
| (1 << 14) | (1 << 15))
12-
#define B43_DMAIRQ_NONFATALMASK (1 << 13)
12+
#define B43_DMAIRQ_RDESC_UFLOW (1 << 13)
1313
#define B43_DMAIRQ_RX_DONE (1 << 16)
1414

1515
/*** 32-bit DMA Engine. ***/
@@ -295,6 +295,8 @@ int b43_dma_tx(struct b43_wldev *dev,
295295
void b43_dma_handle_txstatus(struct b43_wldev *dev,
296296
const struct b43_txstatus *status);
297297

298+
void b43_dma_handle_rx_overflow(struct b43_dmaring *ring);
299+
298300
void b43_dma_rx(struct b43_dmaring *ring);
299301

300302
void b43_dma_direct_fifo_rx(struct b43_wldev *dev,

‎drivers/net/wireless/b43/main.c‎

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,30 +1902,18 @@ static void b43_do_interrupt_thread(struct b43_wldev *dev)
19021902
}
19031903
}
19041904

1905-
if (unlikely(merged_dma_reason & (B43_DMAIRQ_FATALMASK |
1906-
B43_DMAIRQ_NONFATALMASK))) {
1907-
if (merged_dma_reason & B43_DMAIRQ_FATALMASK) {
1908-
b43err(dev->wl, "Fatal DMA error: "
1909-
"0x%08X, 0x%08X, 0x%08X, "
1910-
"0x%08X, 0x%08X, 0x%08X\n",
1911-
dma_reason[0], dma_reason[1],
1912-
dma_reason[2], dma_reason[3],
1913-
dma_reason[4], dma_reason[5]);
1914-
b43err(dev->wl, "This device does not support DMA "
1905+
if (unlikely(merged_dma_reason & (B43_DMAIRQ_FATALMASK))) {
1906+
b43err(dev->wl,
1907+
"Fatal DMA error: 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X, 0x%08X\n",
1908+
dma_reason[0], dma_reason[1],
1909+
dma_reason[2], dma_reason[3],
1910+
dma_reason[4], dma_reason[5]);
1911+
b43err(dev->wl, "This device does not support DMA "
19151912
"on your system. It will now be switched to PIO.\n");
1916-
/* Fall back to PIO transfers if we get fatal DMA errors! */
1917-
dev->use_pio = true;
1918-
b43_controller_restart(dev, "DMA error");
1919-
return;
1920-
}
1921-
if (merged_dma_reason & B43_DMAIRQ_NONFATALMASK) {
1922-
b43err(dev->wl, "DMA error: "
1923-
"0x%08X, 0x%08X, 0x%08X, "
1924-
"0x%08X, 0x%08X, 0x%08X\n",
1925-
dma_reason[0], dma_reason[1],
1926-
dma_reason[2], dma_reason[3],
1927-
dma_reason[4], dma_reason[5]);
1928-
}
1913+
/* Fall back to PIO transfers if we get fatal DMA errors! */
1914+
dev->use_pio = true;
1915+
b43_controller_restart(dev, "DMA error");
1916+
return;
19291917
}
19301918

19311919
if (unlikely(reason & B43_IRQ_UCODE_DEBUG))
@@ -1944,6 +1932,11 @@ static void b43_do_interrupt_thread(struct b43_wldev *dev)
19441932
handle_irq_noise(dev);
19451933

19461934
/* Check the DMA reason registers for received data. */
1935+
if (dma_reason[0] & B43_DMAIRQ_RDESC_UFLOW) {
1936+
if (B43_DEBUG)
1937+
b43warn(dev->wl, "RX descriptor underrun\n");
1938+
b43_dma_handle_rx_overflow(dev->dma.rx_ring);
1939+
}
19471940
if (dma_reason[0] & B43_DMAIRQ_RX_DONE) {
19481941
if (b43_using_pio_transfers(dev))
19491942
b43_pio_rx(dev->pio.rx_queue);
@@ -2001,7 +1994,7 @@ static irqreturn_t b43_do_interrupt(struct b43_wldev *dev)
20011994
return IRQ_NONE;
20021995

20031996
dev->dma_reason[0] = b43_read32(dev, B43_MMIO_DMA0_REASON)
2004-
& 0x0001DC00;
1997+
& 0x0001FC00;
20051998
dev->dma_reason[1] = b43_read32(dev, B43_MMIO_DMA1_REASON)
20061999
& 0x0000DC00;
20072000
dev->dma_reason[2] = b43_read32(dev, B43_MMIO_DMA2_REASON)
@@ -3130,7 +3123,7 @@ static int b43_chip_init(struct b43_wldev *dev)
31303123
b43_write32(dev, 0x018C, 0x02000000);
31313124
}
31323125
b43_write32(dev, B43_MMIO_GEN_IRQ_REASON, 0x00004000);
3133-
b43_write32(dev, B43_MMIO_DMA0_IRQ_MASK, 0x0001DC00);
3126+
b43_write32(dev, B43_MMIO_DMA0_IRQ_MASK, 0x0001FC00);
31343127
b43_write32(dev, B43_MMIO_DMA1_IRQ_MASK, 0x0000DC00);
31353128
b43_write32(dev, B43_MMIO_DMA2_IRQ_MASK, 0x0000DC00);
31363129
b43_write32(dev, B43_MMIO_DMA3_IRQ_MASK, 0x0001DC00);

0 commit comments

Comments
 (0)