aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/patches-3.18/077-11-bgmac-fix-DMA-rx-corruption.patch
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2015-04-12 22:10:40 +0000
committerFelix Fietkau <nbd@openwrt.org>2015-04-12 22:10:40 +0000
commit0ece8f99046d229ea6f57208c5acdd59250a8439 (patch)
tree7241433e79041484404c6648ae8620efdbe9fb3e /target/linux/generic/patches-3.18/077-11-bgmac-fix-DMA-rx-corruption.patch
parent92266f56f45d392e1a439b82119745fdf98c4f61 (diff)
downloadmaster-187ad058-0ece8f99046d229ea6f57208c5acdd59250a8439.tar.gz
master-187ad058-0ece8f99046d229ea6f57208c5acdd59250a8439.tar.bz2
master-187ad058-0ece8f99046d229ea6f57208c5acdd59250a8439.zip
kernel: bgmac: add more DMA related fixes
Signed-off-by: Felix Fietkau <nbd@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@45407 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/patches-3.18/077-11-bgmac-fix-DMA-rx-corruption.patch')
-rw-r--r--target/linux/generic/patches-3.18/077-11-bgmac-fix-DMA-rx-corruption.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/target/linux/generic/patches-3.18/077-11-bgmac-fix-DMA-rx-corruption.patch b/target/linux/generic/patches-3.18/077-11-bgmac-fix-DMA-rx-corruption.patch
new file mode 100644
index 0000000000..5f5fe93703
--- /dev/null
+++ b/target/linux/generic/patches-3.18/077-11-bgmac-fix-DMA-rx-corruption.patch
@@ -0,0 +1,88 @@
+From: Felix Fietkau <nbd@openwrt.org>
+Date: Sun, 12 Apr 2015 11:59:47 +0200
+Subject: [PATCH] bgmac: fix DMA rx corruption
+
+The driver needs to inform the hardware about the first invalid (not yet
+filled) rx slot, by writing its DMA descriptor pointer offset to the
+BGMAC_DMA_RX_INDEX register.
+
+This register was set to a value exceeding the rx ring size, effectively
+allowing the hardware constant access to the full ring, regardless of
+which slots are initialized.
+
+To fix this issue, always mark the last filled rx slot as invalid.
+
+Signed-off-by: Felix Fietkau <nbd@openwrt.org>
+---
+
+--- a/drivers/net/ethernet/broadcom/bgmac.c
++++ b/drivers/net/ethernet/broadcom/bgmac.c
+@@ -362,6 +362,16 @@ static int bgmac_dma_rx_skb_for_slot(str
+ return 0;
+ }
+
++static void bgmac_dma_rx_update_index(struct bgmac *bgmac,
++ struct bgmac_dma_ring *ring)
++{
++ wmb();
++
++ bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_INDEX,
++ ring->index_base +
++ ring->end * sizeof(struct bgmac_dma_desc));
++}
++
+ static void bgmac_dma_rx_setup_desc(struct bgmac *bgmac,
+ struct bgmac_dma_ring *ring, int desc_idx)
+ {
+@@ -380,6 +390,8 @@ static void bgmac_dma_rx_setup_desc(stru
+ dma_desc->addr_high = cpu_to_le32(upper_32_bits(ring->slots[desc_idx].dma_addr));
+ dma_desc->ctl0 = cpu_to_le32(ctl0);
+ dma_desc->ctl1 = cpu_to_le32(ctl1);
++
++ ring->end = desc_idx;
+ }
+
+ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
+@@ -394,9 +406,7 @@ static int bgmac_dma_rx_read(struct bgma
+ end_slot &= BGMAC_DMA_RX_STATDPTR;
+ end_slot /= sizeof(struct bgmac_dma_desc);
+
+- ring->end = end_slot;
+-
+- while (ring->start != ring->end) {
++ while (ring->start != end_slot) {
+ struct device *dma_dev = bgmac->core->dma_dev;
+ struct bgmac_slot_info *slot = &ring->slots[ring->start];
+ struct bgmac_rx_header *rx = slot->buf + BGMAC_RX_BUF_OFFSET;
+@@ -463,6 +473,8 @@ static int bgmac_dma_rx_read(struct bgma
+ break;
+ }
+
++ bgmac_dma_rx_update_index(bgmac, ring);
++
+ return handled;
+ }
+
+@@ -682,6 +694,8 @@ static int bgmac_dma_init(struct bgmac *
+ if (ring->unaligned)
+ bgmac_dma_rx_enable(bgmac, ring);
+
++ ring->start = 0;
++ ring->end = 0;
+ for (j = 0; j < ring->num_slots; j++) {
+ err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]);
+ if (err)
+@@ -690,12 +704,7 @@ static int bgmac_dma_init(struct bgmac *
+ bgmac_dma_rx_setup_desc(bgmac, ring, j);
+ }
+
+- bgmac_write(bgmac, ring->mmio_base + BGMAC_DMA_RX_INDEX,
+- ring->index_base +
+- ring->num_slots * sizeof(struct bgmac_dma_desc));
+-
+- ring->start = 0;
+- ring->end = 0;
++ bgmac_dma_rx_update_index(bgmac, ring);
+ }
+
+ return 0;