kernel: fix more bgmac dma init/cleanup issues
authorFelix Fietkau <nbd@openwrt.org>
Mon, 13 Apr 2015 20:08:30 +0000 (20:08 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 13 Apr 2015 20:08:30 +0000 (20:08 +0000)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 45422

target/linux/generic/patches-3.18/077-07-bgmac-simplify-rx-DMA-error-handling.patch
target/linux/generic/patches-3.18/077-08-bgmac-add-check-for-oversized-packets.patch
target/linux/generic/patches-3.18/077-10-bgmac-simplify-dma-init-cleanup.patch
target/linux/generic/patches-3.18/077-12-bgmac-drop-ring-num_slots.patch
target/linux/generic/patches-3.18/077-14-bgmac-reset-all-4-GMAC-cores-on-init.patch
target/linux/generic/patches-3.18/773-bgmac-add-srab-switch.patch

index e1e8c8f65611be87d2749dd67783f981a01ef4d7..d6feed05b24668ef7cd4651c5f7a2fcbc52cbe01 100644 (file)
@@ -49,7 +49,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
 -                                                         slot->dma_addr,
 -                                                         BGMAC_RX_BUF_SIZE,
 -                                                         DMA_FROM_DEVICE);
-+                              kfree(buf);
++                              put_page(virt_to_head_page(buf));
                                break;
                        }
  
@@ -99,3 +99,23 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
        }
  
        return handled;
+@@ -528,14 +512,14 @@ static void bgmac_dma_rx_ring_free(struc
+       for (i = 0; i < ring->num_slots; i++) {
+               slot = &ring->slots[i];
+-              if (!slot->buf)
++              if (!slot->dma_addr)
+                       continue;
+-              if (slot->dma_addr)
+-                      dma_unmap_single(dma_dev, slot->dma_addr,
+-                                       BGMAC_RX_BUF_SIZE,
+-                                       DMA_FROM_DEVICE);
++              dma_unmap_single(dma_dev, slot->dma_addr,
++                               BGMAC_RX_BUF_SIZE,
++                               DMA_FROM_DEVICE);
+               put_page(virt_to_head_page(slot->buf));
++              slot->dma_addr = 0;
+       }
+ }
index 89e1a3236885cac4da6aeb4cfe0fe3e22fe758ac..9785621cbc7caa1a30fd0abef888cdc440810bc0 100644 (file)
@@ -18,7 +18,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
 +                      if (len > BGMAC_RX_ALLOC_SIZE) {
 +                              bgmac_err(bgmac, "Found oversized packet at slot %d, DMA issue!\n",
 +                                        ring->start);
-+                              kfree(buf);
++                              put_page(virt_to_head_page(buf));
 +                              break;
 +                      }
 +
index 16bb64870dc06d05484d437be65ddcbb743ec515..423b204aa02ecbded17f65081faa2f8eca3211e2 100644 (file)
@@ -152,15 +152,18 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
  
        err = request_irq(bgmac->core->irq, bgmac_interrupt, IRQF_SHARED,
                          KBUILD_MODNAME, net_dev);
-@@ -1273,6 +1270,7 @@ static int bgmac_open(struct net_device 
+@@ -1271,8 +1268,10 @@ static int bgmac_open(struct net_device 
+       phy_start(bgmac->phy_dev);
        netif_carrier_on(net_dev);
++      return 0;
  
  err_out:
 +      bgmac_dma_cleanup(bgmac);
        return err;
  }
  
-@@ -1289,6 +1287,7 @@ static int bgmac_stop(struct net_device 
+@@ -1289,6 +1288,7 @@ static int bgmac_stop(struct net_device 
        free_irq(bgmac->core->irq, net_dev);
  
        bgmac_chip_reset(bgmac);
index 6709aaa4ea29f3eedb6389d732ac7dac37a9d931..36acc19716f9dd49e917900f6d39fa12bf81f0f9 100644 (file)
@@ -44,7 +44,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
 -      for (i = 0; i < ring->num_slots; i++) {
 +      for (i = 0; i < BGMAC_RX_RING_SLOTS; i++) {
                slot = &ring->slots[i];
-               if (!slot->buf)
+               if (!slot->dma_addr)
                        continue;
 @@ -543,7 +543,8 @@ static void bgmac_dma_rx_ring_free(struc
  }
index b38a116f933bc9c4542970432a4f7685cd394e2f..c23496bd43ef5b2b21bf4f88c12b7a26c48a789f 100644 (file)
@@ -12,7 +12,7 @@ Signed-off-by: Felix Fietkau <nbd@openwrt.org>
 
 --- a/drivers/net/ethernet/broadcom/bgmac.c
 +++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -1604,8 +1604,11 @@ static int bgmac_probe(struct bcma_devic
+@@ -1605,8 +1605,11 @@ static int bgmac_probe(struct bcma_devic
                        ns_core = bcma_find_core_unit(core->bus,
                                                      BCMA_CORE_MAC_GBIT,
                                                      ns_gmac);
index 14c640719cfce488bb0a1ec2691f28a7a3d7deef..d6f1f3301cd422a384cf3ec604bd8a4fe61ff9e1 100644 (file)
@@ -12,7 +12,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  #include <bcm47xx_nvram.h>
  
  static const struct bcma_device_id bgmac_bcma_tbl[] = {
-@@ -1519,6 +1520,17 @@ static void bgmac_mii_unregister(struct 
+@@ -1520,6 +1521,17 @@ static void bgmac_mii_unregister(struct 
        mdiobus_free(mii_bus);
  }
  
@@ -30,7 +30,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  /**************************************************
   * BCMA bus ops
   **************************************************/
-@@ -1645,6 +1657,16 @@ static int bgmac_probe(struct bcma_devic
+@@ -1646,6 +1658,16 @@ static int bgmac_probe(struct bcma_devic
        net_dev->hw_features = net_dev->features;
        net_dev->vlan_features = net_dev->features;
  
@@ -47,7 +47,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
        err = register_netdev(bgmac->net_dev);
        if (err) {
                bgmac_err(bgmac, "Cannot register net device\n");
-@@ -1671,6 +1693,10 @@ static void bgmac_remove(struct bcma_dev
+@@ -1672,6 +1694,10 @@ static void bgmac_remove(struct bcma_dev
  {
        struct bgmac *bgmac = bcma_get_drvdata(core);