- Refreshed all patches

Compile tested on: ar71xx
Runtime tested on: ar71xx

Signed-off-by: Koen Vandeputte <koen.vandepu...@ncentric.com>
---
 include/kernel-version.mk                          |   4 +-
 .../patches-4.9/910-unaligned_access_hacks.patch   |   2 +-
 ...-tcp-tsq-add-shortcut-in-tcp_tasklet_func.patch |   2 +-
 ...q-add-a-shortcut-in-tcp_small_queue_check.patch |   2 +-
 ...tcp-tcp_mtu_probe-is-likely-to-exit-early.patch |   2 +-
 ...tsq-move-tsq_flags-close-to-sk_wmem_alloc.patch |   6 +-
 .../025-tcp-allow-drivers-to-tweak-TSQ-logic.patch |   2 +-
 ...-r4k_cache-use-more-efficient-cache-blast.patch |   2 +-
 .../linux/generic/hack-4.9/721-phy_packets.patch   |   2 +-
 .../linux/generic/hack-4.9/902-debloat_proc.patch  |   2 +-
 ...80-NET-skip-GRO-for-foreign-MAC-addresses.patch |  10 +-
 .../202-core-linux-support-layerscape.patch        |   2 +-
 .../sunxi/patches-4.9/0052-stmmac-form-4-12.patch  | 386 +++++++++++----------
 13 files changed, 223 insertions(+), 201 deletions(-)

diff --git a/include/kernel-version.mk b/include/kernel-version.mk
index d20b2262352d..95103c5ffe7f 100644
--- a/include/kernel-version.mk
+++ b/include/kernel-version.mk
@@ -4,12 +4,12 @@ LINUX_RELEASE?=1
 
 LINUX_VERSION-3.18 = .71
 LINUX_VERSION-4.4 = .119
-LINUX_VERSION-4.9 = .86
+LINUX_VERSION-4.9 = .87
 LINUX_VERSION-4.14 = .26
 
 LINUX_KERNEL_HASH-3.18.71 = 
5abc9778ad44ce02ed6c8ab52ece8a21c6d20d21f6ed8a19287b4a38a50c1240
 LINUX_KERNEL_HASH-4.4.119 = 
4f1f9b7b6b2ee93597239d89bb3b6b60c71ebd8c91d706fadd36f515c68443e6
-LINUX_KERNEL_HASH-4.9.86 = 
a7cf6eb5efcf182f1760fdfc06118eecce5d8c9d82d6945e68fc15db990c6e85
+LINUX_KERNEL_HASH-4.9.87 = 
7ac9f6af69dc5a7e38bf35cc3fa889e3a4b22504a85f57fdc87734a8abe4c917
 LINUX_KERNEL_HASH-4.14.26 = 
99a466c54261007b984ee149167d89755051dd09bfc31df37332207b0e9c6c58
 
 remove_uri_prefix=$(subst git://,,$(subst http://,,$(subst https://,,$(1))))
diff --git a/target/linux/ar71xx/patches-4.9/910-unaligned_access_hacks.patch 
b/target/linux/ar71xx/patches-4.9/910-unaligned_access_hacks.patch
index a45375290037..464a930f3275 100644
--- a/target/linux/ar71xx/patches-4.9/910-unaligned_access_hacks.patch
+++ b/target/linux/ar71xx/patches-4.9/910-unaligned_access_hacks.patch
@@ -316,7 +316,7 @@
        for (p = *head; p; p = p->next) {
 --- a/net/ipv4/route.c
 +++ b/net/ipv4/route.c
-@@ -458,7 +458,7 @@ static struct neighbour *ipv4_neigh_look
+@@ -461,7 +461,7 @@ static struct neighbour *ipv4_neigh_look
        else if (skb)
                pkey = &ip_hdr(skb)->daddr;
  
diff --git 
a/target/linux/generic/backport-4.9/024-3-tcp-tsq-add-shortcut-in-tcp_tasklet_func.patch
 
b/target/linux/generic/backport-4.9/024-3-tcp-tsq-add-shortcut-in-tcp_tasklet_func.patch
index 249a2ce27e05..f5004d3ffcb0 100644
--- 
a/target/linux/generic/backport-4.9/024-3-tcp-tsq-add-shortcut-in-tcp_tasklet_func.patch
+++ 
b/target/linux/generic/backport-4.9/024-3-tcp-tsq-add-shortcut-in-tcp_tasklet_func.patch
@@ -60,7 +60,7 @@ Signed-off-by: David S. Miller <da...@davemloft.net>
                nval = cmpxchg(&tp->tsq_flags, oval, nval);
                if (nval != oval)
                        continue;
-@@ -2183,6 +2183,8 @@ static bool tcp_write_xmit(struct sock *
+@@ -2210,6 +2210,8 @@ static bool tcp_write_xmit(struct sock *
                    unlikely(tso_fragment(sk, skb, limit, mss_now, gfp)))
                        break;
  
diff --git 
a/target/linux/generic/backport-4.9/024-5-tcp-tsq-add-a-shortcut-in-tcp_small_queue_check.patch
 
b/target/linux/generic/backport-4.9/024-5-tcp-tsq-add-a-shortcut-in-tcp_small_queue_check.patch
index 463b9553414c..65013b6aa7f3 100644
--- 
a/target/linux/generic/backport-4.9/024-5-tcp-tsq-add-a-shortcut-in-tcp_small_queue_check.patch
+++ 
b/target/linux/generic/backport-4.9/024-5-tcp-tsq-add-a-shortcut-in-tcp_small_queue_check.patch
@@ -19,7 +19,7 @@ Signed-off-by: David S. Miller <da...@davemloft.net>
 
 --- a/net/ipv4/tcp_output.c
 +++ b/net/ipv4/tcp_output.c
-@@ -2088,6 +2088,15 @@ static bool tcp_small_queue_check(struct
+@@ -2115,6 +2115,15 @@ static bool tcp_small_queue_check(struct
        limit <<= factor;
  
        if (atomic_read(&sk->sk_wmem_alloc) > limit) {
diff --git 
a/target/linux/generic/backport-4.9/024-6-tcp-tcp_mtu_probe-is-likely-to-exit-early.patch
 
b/target/linux/generic/backport-4.9/024-6-tcp-tcp_mtu_probe-is-likely-to-exit-early.patch
index c5bb42d44818..6f2d196687a2 100644
--- 
a/target/linux/generic/backport-4.9/024-6-tcp-tcp_mtu_probe-is-likely-to-exit-early.patch
+++ 
b/target/linux/generic/backport-4.9/024-6-tcp-tcp_mtu_probe-is-likely-to-exit-early.patch
@@ -17,7 +17,7 @@ Signed-off-by: David S. Miller <da...@davemloft.net>
 
 --- a/net/ipv4/tcp_output.c
 +++ b/net/ipv4/tcp_output.c
-@@ -1928,26 +1928,26 @@ static inline void tcp_mtu_check_reprobe
+@@ -1948,26 +1948,26 @@ static bool tcp_can_coalesce_send_queue_
   */
  static int tcp_mtu_probe(struct sock *sk)
  {
diff --git 
a/target/linux/generic/backport-4.9/024-8-tcp-tsq-move-tsq_flags-close-to-sk_wmem_alloc.patch
 
b/target/linux/generic/backport-4.9/024-8-tcp-tsq-move-tsq_flags-close-to-sk_wmem_alloc.patch
index 87b5253abbea..407d508f9417 100644
--- 
a/target/linux/generic/backport-4.9/024-8-tcp-tsq-move-tsq_flags-close-to-sk_wmem_alloc.patch
+++ 
b/target/linux/generic/backport-4.9/024-8-tcp-tsq-move-tsq_flags-close-to-sk_wmem_alloc.patch
@@ -114,7 +114,7 @@ Signed-off-by: David S. Miller <da...@davemloft.net>
                if (nval != oval)
                        continue;
  
-@@ -2097,7 +2097,7 @@ static bool tcp_small_queue_check(struct
+@@ -2124,7 +2124,7 @@ static bool tcp_small_queue_check(struct
                    skb->prev == sk->sk_write_queue.next)
                        return false;
  
@@ -123,7 +123,7 @@ Signed-off-by: David S. Miller <da...@davemloft.net>
                /* It is possible TX completion already happened
                 * before we set TSQ_THROTTLED, so we must
                 * test again the condition.
-@@ -2195,8 +2195,8 @@ static bool tcp_write_xmit(struct sock *
+@@ -2222,8 +2222,8 @@ static bool tcp_write_xmit(struct sock *
                    unlikely(tso_fragment(sk, skb, limit, mss_now, gfp)))
                        break;
  
@@ -134,7 +134,7 @@ Signed-off-by: David S. Miller <da...@davemloft.net>
                if (tcp_small_queue_check(sk, skb, 0))
                        break;
  
-@@ -3504,8 +3504,6 @@ void tcp_send_ack(struct sock *sk)
+@@ -3531,8 +3531,6 @@ void tcp_send_ack(struct sock *sk)
        /* We do not want pure acks influencing TCP Small Queues or fq/pacing
         * too much.
         * SKB_TRUESIZE(max(1 .. 66, MAX_TCP_HEADER)) is unfortunately ~784
diff --git 
a/target/linux/generic/backport-4.9/025-tcp-allow-drivers-to-tweak-TSQ-logic.patch
 
b/target/linux/generic/backport-4.9/025-tcp-allow-drivers-to-tweak-TSQ-logic.patch
index d92ce0747820..33593194d573 100644
--- 
a/target/linux/generic/backport-4.9/025-tcp-allow-drivers-to-tweak-TSQ-logic.patch
+++ 
b/target/linux/generic/backport-4.9/025-tcp-allow-drivers-to-tweak-TSQ-logic.patch
@@ -74,7 +74,7 @@ Cc: Kir Kolyshkin <k...@openvz.org>
                    sk->sk_gso_max_size - 1 - MAX_TCP_HEADER);
  
        /* Goal is to send at least one packet per ms,
-@@ -2084,7 +2084,7 @@ static bool tcp_small_queue_check(struct
+@@ -2111,7 +2111,7 @@ static bool tcp_small_queue_check(struct
  {
        unsigned int limit;
  
diff --git 
a/target/linux/generic/hack-4.9/300-MIPS-r4k_cache-use-more-efficient-cache-blast.patch
 
b/target/linux/generic/hack-4.9/300-MIPS-r4k_cache-use-more-efficient-cache-blast.patch
index ce7901af40bb..690b30ee9bda 100644
--- 
a/target/linux/generic/hack-4.9/300-MIPS-r4k_cache-use-more-efficient-cache-blast.patch
+++ 
b/target/linux/generic/hack-4.9/300-MIPS-r4k_cache-use-more-efficient-cache-blast.patch
@@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
 ---
 --- a/arch/mips/include/asm/r4kcache.h
 +++ b/arch/mips/include/asm/r4kcache.h
-@@ -665,16 +665,48 @@ static inline void 
prot##extra##blast_##pfx##cache##_range(unsigned long start,
+@@ -665,16 +665,48 @@ static inline void prot##extra##blast_##
                                                    unsigned long end)  \
  {                                                                     \
        unsigned long lsize = cpu_##desc##_line_size();                 \
diff --git a/target/linux/generic/hack-4.9/721-phy_packets.patch 
b/target/linux/generic/hack-4.9/721-phy_packets.patch
index b312ac7d4170..fbf3c70cac6a 100644
--- a/target/linux/generic/hack-4.9/721-phy_packets.patch
+++ b/target/linux/generic/hack-4.9/721-phy_packets.patch
@@ -101,7 +101,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
        help
 --- a/net/core/dev.c
 +++ b/net/core/dev.c
-@@ -2943,10 +2943,20 @@ static int xmit_one(struct sk_buff *skb,
+@@ -2950,10 +2950,20 @@ static int xmit_one(struct sk_buff *skb,
        if (!list_empty(&ptype_all) || !list_empty(&dev->ptype_all))
                dev_queue_xmit_nit(skb, dev);
  
diff --git a/target/linux/generic/hack-4.9/902-debloat_proc.patch 
b/target/linux/generic/hack-4.9/902-debloat_proc.patch
index f2b326fe34fa..0559310a1829 100644
--- a/target/linux/generic/hack-4.9/902-debloat_proc.patch
+++ b/target/linux/generic/hack-4.9/902-debloat_proc.patch
@@ -393,7 +393,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
  
 --- a/net/ipv4/route.c
 +++ b/net/ipv4/route.c
-@@ -420,6 +420,9 @@ static struct pernet_operations ip_rt_pr
+@@ -423,6 +423,9 @@ static struct pernet_operations ip_rt_pr
  
  static int __init ip_rt_proc_init(void)
  {
diff --git 
a/target/linux/generic/pending-4.9/680-NET-skip-GRO-for-foreign-MAC-addresses.patch
 
b/target/linux/generic/pending-4.9/680-NET-skip-GRO-for-foreign-MAC-addresses.patch
index 5d432b1f3e78..86a64d84245b 100644
--- 
a/target/linux/generic/pending-4.9/680-NET-skip-GRO-for-foreign-MAC-addresses.patch
+++ 
b/target/linux/generic/pending-4.9/680-NET-skip-GRO-for-foreign-MAC-addresses.patch
@@ -34,7 +34,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
        __u16                   tc_index;       /* traffic control index */
 --- a/net/core/dev.c
 +++ b/net/core/dev.c
-@@ -4535,6 +4535,9 @@ static enum gro_result dev_gro_receive(s
+@@ -4542,6 +4542,9 @@ static enum gro_result dev_gro_receive(s
        enum gro_result ret;
        int grow;
  
@@ -44,7 +44,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
        if (!(skb->dev->features & NETIF_F_GRO))
                goto normal;
  
-@@ -5823,6 +5826,48 @@ static void __netdev_adjacent_dev_unlink
+@@ -5830,6 +5833,48 @@ static void __netdev_adjacent_dev_unlink
                                           &upper_dev->adj_list.lower);
  }
  
@@ -93,7 +93,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
  static int __netdev_upper_dev_link(struct net_device *dev,
                                   struct net_device *upper_dev, bool master,
                                   void *upper_priv, void *upper_info)
-@@ -5895,6 +5940,7 @@ static int __netdev_upper_dev_link(struc
+@@ -5902,6 +5947,7 @@ static int __netdev_upper_dev_link(struc
                        goto rollback_lower_mesh;
        }
  
@@ -101,7 +101,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
        ret = call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
                                            &changeupper_info.info);
        ret = notifier_to_errno(ret);
-@@ -6021,6 +6067,7 @@ void netdev_upper_dev_unlink(struct net_
+@@ -6028,6 +6074,7 @@ void netdev_upper_dev_unlink(struct net_
        list_for_each_entry(i, &upper_dev->all_adj_list.upper, list)
                __netdev_adjacent_dev_unlink(dev, i->dev, i->ref_nr);
  
@@ -109,7 +109,7 @@ Signed-off-by: Felix Fietkau <n...@nbd.name>
        call_netdevice_notifiers_info(NETDEV_CHANGEUPPER, dev,
                                      &changeupper_info.info);
  }
-@@ -6621,6 +6668,7 @@ int dev_set_mac_address(struct net_devic
+@@ -6628,6 +6675,7 @@ int dev_set_mac_address(struct net_devic
        if (err)
                return err;
        dev->addr_assign_type = NET_ADDR_SET;
diff --git 
a/target/linux/layerscape/patches-4.9/202-core-linux-support-layerscape.patch 
b/target/linux/layerscape/patches-4.9/202-core-linux-support-layerscape.patch
index 9dcecb07892e..77e54f83403e 100644
--- 
a/target/linux/layerscape/patches-4.9/202-core-linux-support-layerscape.patch
+++ 
b/target/linux/layerscape/patches-4.9/202-core-linux-support-layerscape.patch
@@ -421,7 +421,7 @@ Signed-off-by: Yangbo Lu <yangbo...@nxp.com>
   *    These are the defined Ethernet Protocol ID's.
 --- a/net/core/dev.c
 +++ b/net/core/dev.c
-@@ -6615,9 +6615,18 @@ int dev_set_mtu(struct net_device *dev,
+@@ -6622,9 +6622,18 @@ int dev_set_mtu(struct net_device *dev,
        if (new_mtu == dev->mtu)
                return 0;
  
diff --git a/target/linux/sunxi/patches-4.9/0052-stmmac-form-4-12.patch 
b/target/linux/sunxi/patches-4.9/0052-stmmac-form-4-12.patch
index 1356a4b9e97a..182648b98fa7 100644
--- a/target/linux/sunxi/patches-4.9/0052-stmmac-form-4-12.patch
+++ b/target/linux/sunxi/patches-4.9/0052-stmmac-form-4-12.patch
@@ -2887,7 +2887,7 @@
 +
 +              /* Display RX ring */
 +              priv->hw->desc->display_ring(head_rx, DMA_RX_SIZE, true);
-       }
++      }
 +}
 +
 +static void stmmac_display_tx_rings(struct stmmac_priv *priv)
@@ -2906,15 +2906,15 @@
 +                      head_tx = (void *)tx_q->dma_etx;
 +              else
 +                      head_tx = (void *)tx_q->dma_tx;
++
++              priv->hw->desc->display_ring(head_tx, DMA_TX_SIZE, false);
+       }
++}
  
 -      /* Display Rx ring */
 -      priv->hw->desc->display_ring(head_rx, DMA_RX_SIZE, true);
 -      /* Display Tx ring */
 -      priv->hw->desc->display_ring(head_tx, DMA_TX_SIZE, false);
-+              priv->hw->desc->display_ring(head_tx, DMA_TX_SIZE, false);
-+      }
-+}
-+
 +static void stmmac_display_rings(struct stmmac_priv *priv)
 +{
 +      /* Display RX ring */
@@ -3131,7 +3131,7 @@
  
        if (priv->hw->mode->set_16kib_bfsize)
                bfsize = priv->hw->mode->set_16kib_bfsize(dev->mtu);
-@@ -1024,235 +1234,409 @@ static int init_dma_desc_rings(struct ne
+@@ -1024,257 +1234,516 @@ static int init_dma_desc_rings(struct ne
  
        priv->dma_buf_sz = bfsize;
  
@@ -3163,7 +3163,10 @@
 +                              p = &((rx_q->dma_erx + i)->basic);
 +                      else
 +                              p = rx_q->dma_rx + i;
-+
+ 
+-              ret = stmmac_init_rx_buffers(priv, p, i, flags);
+-              if (ret)
+-                      goto err_init_rx_buffers;
 +                      ret = stmmac_init_rx_buffers(priv, p, i, flags,
 +                                                   queue);
 +                      if (ret)
@@ -3173,18 +3176,15 @@
 +                                rx_q->rx_skbuff[i], rx_q->rx_skbuff[i]->data,
 +                                (unsigned int)rx_q->rx_skbuff_dma[i]);
 +              }
- 
--              ret = stmmac_init_rx_buffers(priv, p, i, flags);
--              if (ret)
--                      goto err_init_rx_buffers;
++
 +              rx_q->cur_rx = 0;
 +              rx_q->dirty_rx = (unsigned int)(i - DMA_RX_SIZE);
++
++              stmmac_clear_rx_descriptors(priv, queue);
  
 -              netif_dbg(priv, probe, priv->dev, "[%p]\t[%p]\t[%x]\n",
 -                        priv->rx_skbuff[i], priv->rx_skbuff[i]->data,
 -                        (unsigned int)priv->rx_skbuff_dma[i]);
-+              stmmac_clear_rx_descriptors(priv, queue);
-+
 +              /* Setup the chained descriptor addresses */
 +              if (priv->mode == STMMAC_CHAIN_MODE) {
 +                      if (priv->extend_desc)
@@ -3277,8 +3277,13 @@
 +                              priv->hw->mode->init(tx_q->dma_tx,
 +                                                   tx_q->dma_tx_phy,
 +                                                   DMA_TX_SIZE, 0);
-+              }
-+
+               }
+ 
+-              priv->tx_skbuff_dma[i].buf = 0;
+-              priv->tx_skbuff_dma[i].map_as_page = false;
+-              priv->tx_skbuff_dma[i].len = 0;
+-              priv->tx_skbuff_dma[i].last_segment = false;
+-              priv->tx_skbuff[i] = NULL;
 +              for (i = 0; i < DMA_TX_SIZE; i++) {
 +                      struct dma_desc *p;
 +                      if (priv->extend_desc)
@@ -3300,13 +3305,8 @@
 +                      tx_q->tx_skbuff_dma[i].len = 0;
 +                      tx_q->tx_skbuff_dma[i].last_segment = false;
 +                      tx_q->tx_skbuff[i] = NULL;
-               }
- 
--              priv->tx_skbuff_dma[i].buf = 0;
--              priv->tx_skbuff_dma[i].map_as_page = false;
--              priv->tx_skbuff_dma[i].len = 0;
--              priv->tx_skbuff_dma[i].last_segment = false;
--              priv->tx_skbuff[i] = NULL;
++              }
++
 +              tx_q->dirty_tx = 0;
 +              tx_q->cur_tx = 0;
 +
@@ -3387,17 +3387,10 @@
 -                                               priv->tx_skbuff_dma[i].buf,
 -                                               priv->tx_skbuff_dma[i].len,
 -                                               DMA_TO_DEVICE);
--              }
 +      for (i = 0; i < DMA_TX_SIZE; i++)
 +              stmmac_free_tx_buffer(priv, queue, i);
 +}
- 
--              if (priv->tx_skbuff[i]) {
--                      dev_kfree_skb_any(priv->tx_skbuff[i]);
--                      priv->tx_skbuff[i] = NULL;
--                      priv->tx_skbuff_dma[i].buf = 0;
--                      priv->tx_skbuff_dma[i].map_as_page = false;
--              }
++
 +/**
 + * free_dma_rx_desc_resources - free RX dma desc resources
 + * @priv: private structure
@@ -3426,11 +3419,10 @@
 +
 +              kfree(rx_q->rx_skbuff_dma);
 +              kfree(rx_q->rx_skbuff);
-       }
- }
- 
- /**
-- * alloc_dma_desc_resources - alloc TX/RX resources.
++      }
++}
++
++/**
 + * free_dma_tx_desc_resources - free TX dma desc resources
 + * @priv: private structure
 + */
@@ -3463,90 +3455,36 @@
 +
 +/**
 + * alloc_dma_rx_desc_resources - alloc RX resources.
-  * @priv: private structure
-  * Description: according to which descriptor can be used (extend or basic)
-  * this function allocates the resources for TX and RX paths. In case of
-  * reception, for example, it pre-allocated the RX socket buffer in order to
-  * allow zero-copy mechanism.
-  */
--static int alloc_dma_desc_resources(struct stmmac_priv *priv)
++ * @priv: private structure
++ * Description: according to which descriptor can be used (extend or basic)
++ * this function allocates the resources for TX and RX paths. In case of
++ * reception, for example, it pre-allocated the RX socket buffer in order to
++ * allow zero-copy mechanism.
++ */
 +static int alloc_dma_rx_desc_resources(struct stmmac_priv *priv)
- {
++{
 +      u32 rx_count = priv->plat->rx_queues_to_use;
-       int ret = -ENOMEM;
++      int ret = -ENOMEM;
 +      u32 queue;
- 
--      priv->rx_skbuff_dma = kmalloc_array(DMA_RX_SIZE, sizeof(dma_addr_t),
--                                          GFP_KERNEL);
--      if (!priv->rx_skbuff_dma)
--              return -ENOMEM;
++
 +      /* RX queues buffers and DMA */
 +      for (queue = 0; queue < rx_count; queue++) {
 +              struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
- 
--      priv->rx_skbuff = kmalloc_array(DMA_RX_SIZE, sizeof(struct sk_buff *),
--                                      GFP_KERNEL);
--      if (!priv->rx_skbuff)
--              goto err_rx_skbuff;
--
--      priv->tx_skbuff_dma = kmalloc_array(DMA_TX_SIZE,
--                                          sizeof(*priv->tx_skbuff_dma),
--                                          GFP_KERNEL);
--      if (!priv->tx_skbuff_dma)
--              goto err_tx_skbuff_dma;
--
--      priv->tx_skbuff = kmalloc_array(DMA_TX_SIZE, sizeof(struct sk_buff *),
--                                      GFP_KERNEL);
--      if (!priv->tx_skbuff)
--              goto err_tx_skbuff;
--
--      if (priv->extend_desc) {
--              priv->dma_erx = dma_zalloc_coherent(priv->device, DMA_RX_SIZE *
--                                                  sizeof(struct
--                                                         dma_extended_desc),
--                                                  &priv->dma_rx_phy,
--                                                  GFP_KERNEL);
--              if (!priv->dma_erx)
--                      goto err_dma;
++
 +              rx_q->queue_index = queue;
 +              rx_q->priv_data = priv;
- 
--              priv->dma_etx = dma_zalloc_coherent(priv->device, DMA_TX_SIZE *
--                                                  sizeof(struct
--                                                         dma_extended_desc),
--                                                  &priv->dma_tx_phy,
++
 +              rx_q->rx_skbuff_dma = kmalloc_array(DMA_RX_SIZE,
 +                                                  sizeof(dma_addr_t),
-                                                   GFP_KERNEL);
--              if (!priv->dma_etx) {
--                      dma_free_coherent(priv->device, DMA_RX_SIZE *
--                                        sizeof(struct dma_extended_desc),
--                                        priv->dma_erx, priv->dma_rx_phy);
--                      goto err_dma;
--              }
--      } else {
--              priv->dma_rx = dma_zalloc_coherent(priv->device, DMA_RX_SIZE *
--                                                 sizeof(struct dma_desc),
--                                                 &priv->dma_rx_phy,
--                                                 GFP_KERNEL);
--              if (!priv->dma_rx)
--                      goto err_dma;
++                                                  GFP_KERNEL);
 +              if (!rx_q->rx_skbuff_dma)
 +                      return -ENOMEM;
- 
--              priv->dma_tx = dma_zalloc_coherent(priv->device, DMA_TX_SIZE *
--                                                 sizeof(struct dma_desc),
--                                                 &priv->dma_tx_phy,
--                                                 GFP_KERNEL);
--              if (!priv->dma_tx) {
--                      dma_free_coherent(priv->device, DMA_RX_SIZE *
--                                        sizeof(struct dma_desc),
--                                        priv->dma_rx, priv->dma_rx_phy);
++
 +              rx_q->rx_skbuff = kmalloc_array(DMA_RX_SIZE,
 +                                              sizeof(struct sk_buff *),
 +                                              GFP_KERNEL);
 +              if (!rx_q->rx_skbuff)
-                       goto err_dma;
++                      goto err_dma;
 +
 +              if (priv->extend_desc) {
 +                      rx_q->dma_erx = dma_zalloc_coherent(priv->device,
@@ -3567,19 +3505,12 @@
 +                                                         GFP_KERNEL);
 +                      if (!rx_q->dma_rx)
 +                              goto err_dma;
-               }
-       }
- 
-       return 0;
- 
- err_dma:
--      kfree(priv->tx_skbuff);
--err_tx_skbuff:
--      kfree(priv->tx_skbuff_dma);
--err_tx_skbuff_dma:
--      kfree(priv->rx_skbuff);
--err_rx_skbuff:
--      kfree(priv->rx_skbuff_dma);
++              }
++      }
++
++      return 0;
++
++err_dma:
 +      free_dma_rx_desc_resources(priv);
 +
 +      return ret;
@@ -3636,7 +3567,7 @@
 +                                                         GFP_KERNEL);
 +                      if (!tx_q->dma_tx)
 +                              goto err_dma_buffers;
-+              }
+               }
 +      }
 +
 +      return 0;
@@ -3644,9 +3575,9 @@
 +err_dma_buffers:
 +      free_dma_tx_desc_resources(priv);
 +
-       return ret;
- }
- 
++      return ret;
++}
++
 +/**
 + * alloc_dma_desc_resources - alloc TX/RX resources.
 + * @priv: private structure
@@ -3672,78 +3603,119 @@
 + * free_dma_desc_resources - free dma desc resources
 + * @priv: private structure
 + */
- static void free_dma_desc_resources(struct stmmac_priv *priv)
- {
--      /* Release the DMA TX/RX socket buffers */
--      dma_free_rx_skbufs(priv);
--      dma_free_tx_skbufs(priv);
--
--      /* Free DMA regions of consistent memory previously allocated */
--      if (!priv->extend_desc) {
--              dma_free_coherent(priv->device,
--                                DMA_TX_SIZE * sizeof(struct dma_desc),
--                                priv->dma_tx, priv->dma_tx_phy);
--              dma_free_coherent(priv->device,
--                                DMA_RX_SIZE * sizeof(struct dma_desc),
--                                priv->dma_rx, priv->dma_rx_phy);
--      } else {
--              dma_free_coherent(priv->device, DMA_TX_SIZE *
--                                sizeof(struct dma_extended_desc),
--                                priv->dma_etx, priv->dma_tx_phy);
--              dma_free_coherent(priv->device, DMA_RX_SIZE *
--                                sizeof(struct dma_extended_desc),
--                                priv->dma_erx, priv->dma_rx_phy);
--      }
--      kfree(priv->rx_skbuff_dma);
--      kfree(priv->rx_skbuff);
--      kfree(priv->tx_skbuff_dma);
--      kfree(priv->tx_skbuff);
++static void free_dma_desc_resources(struct stmmac_priv *priv)
++{
 +      /* Release the DMA RX socket buffers */
 +      free_dma_rx_desc_resources(priv);
 +
 +      /* Release the DMA TX socket buffers */
 +      free_dma_tx_desc_resources(priv);
- }
- 
- /**
-@@ -1262,19 +1646,104 @@ static void free_dma_desc_resources(stru
-  */
- static void stmmac_mac_enable_rx_queues(struct stmmac_priv *priv)
- {
--      int rx_count = priv->dma_cap.number_rx_queues;
--      int queue = 0;
++}
++
++/**
++ *  stmmac_mac_enable_rx_queues - Enable MAC rx queues
++ *  @priv: driver private structure
++ *  Description: It is used for enabling the rx queues in the MAC
++ */
++static void stmmac_mac_enable_rx_queues(struct stmmac_priv *priv)
++{
 +      u32 rx_queues_count = priv->plat->rx_queues_to_use;
 +      int queue;
 +      u8 mode;
  
--      /* If GMAC does not have multiple queues, then this is not necessary*/
--      if (rx_count == 1)
--              return;
+-              if (priv->tx_skbuff[i]) {
+-                      dev_kfree_skb_any(priv->tx_skbuff[i]);
+-                      priv->tx_skbuff[i] = NULL;
+-                      priv->tx_skbuff_dma[i].buf = 0;
+-                      priv->tx_skbuff_dma[i].map_as_page = false;
+-              }
 +      for (queue = 0; queue < rx_queues_count; queue++) {
 +              mode = priv->plat->rx_queues_cfg[queue].mode_to_use;
 +              priv->hw->mac->rx_queue_enable(priv->hw, mode, queue);
-+      }
-+}
+       }
+ }
  
--      /**
--       *  If the core is synthesized with multiple rx queues / multiple
--       *  dma channels, then rx queues will be disabled by default.
--       *  For now only rx queue 0 is enabled.
--       */
--      priv->hw->mac->rx_queue_enable(priv->hw, queue);
-+/**
+ /**
+- * alloc_dma_desc_resources - alloc TX/RX resources.
+- * @priv: private structure
+- * Description: according to which descriptor can be used (extend or basic)
+- * this function allocates the resources for TX and RX paths. In case of
+- * reception, for example, it pre-allocated the RX socket buffer in order to
+- * allow zero-copy mechanism.
 + * stmmac_start_rx_dma - start RX DMA channel
 + * @priv: driver private structure
 + * @chan: RX channel index
 + * Description:
 + * This starts a RX DMA channel
-+ */
+  */
+-static int alloc_dma_desc_resources(struct stmmac_priv *priv)
 +static void stmmac_start_rx_dma(struct stmmac_priv *priv, u32 chan)
-+{
+ {
+-      int ret = -ENOMEM;
+-
+-      priv->rx_skbuff_dma = kmalloc_array(DMA_RX_SIZE, sizeof(dma_addr_t),
+-                                          GFP_KERNEL);
+-      if (!priv->rx_skbuff_dma)
+-              return -ENOMEM;
+-
+-      priv->rx_skbuff = kmalloc_array(DMA_RX_SIZE, sizeof(struct sk_buff *),
+-                                      GFP_KERNEL);
+-      if (!priv->rx_skbuff)
+-              goto err_rx_skbuff;
+-
+-      priv->tx_skbuff_dma = kmalloc_array(DMA_TX_SIZE,
+-                                          sizeof(*priv->tx_skbuff_dma),
+-                                          GFP_KERNEL);
+-      if (!priv->tx_skbuff_dma)
+-              goto err_tx_skbuff_dma;
+-
+-      priv->tx_skbuff = kmalloc_array(DMA_TX_SIZE, sizeof(struct sk_buff *),
+-                                      GFP_KERNEL);
+-      if (!priv->tx_skbuff)
+-              goto err_tx_skbuff;
+-
+-      if (priv->extend_desc) {
+-              priv->dma_erx = dma_zalloc_coherent(priv->device, DMA_RX_SIZE *
+-                                                  sizeof(struct
+-                                                         dma_extended_desc),
+-                                                  &priv->dma_rx_phy,
+-                                                  GFP_KERNEL);
+-              if (!priv->dma_erx)
+-                      goto err_dma;
+-
+-              priv->dma_etx = dma_zalloc_coherent(priv->device, DMA_TX_SIZE *
+-                                                  sizeof(struct
+-                                                         dma_extended_desc),
+-                                                  &priv->dma_tx_phy,
+-                                                  GFP_KERNEL);
+-              if (!priv->dma_etx) {
+-                      dma_free_coherent(priv->device, DMA_RX_SIZE *
+-                                        sizeof(struct dma_extended_desc),
+-                                        priv->dma_erx, priv->dma_rx_phy);
+-                      goto err_dma;
+-              }
+-      } else {
+-              priv->dma_rx = dma_zalloc_coherent(priv->device, DMA_RX_SIZE *
+-                                                 sizeof(struct dma_desc),
+-                                                 &priv->dma_rx_phy,
+-                                                 GFP_KERNEL);
+-              if (!priv->dma_rx)
+-                      goto err_dma;
 +      netdev_dbg(priv->dev, "DMA RX processes started in channel %d\n", chan);
 +      priv->hw->dma->start_rx(priv->ioaddr, chan);
 +}
-+
+ 
+-              priv->dma_tx = dma_zalloc_coherent(priv->device, DMA_TX_SIZE *
+-                                                 sizeof(struct dma_desc),
+-                                                 &priv->dma_tx_phy,
+-                                                 GFP_KERNEL);
+-              if (!priv->dma_tx) {
+-                      dma_free_coherent(priv->device, DMA_RX_SIZE *
+-                                        sizeof(struct dma_desc),
+-                                        priv->dma_rx, priv->dma_rx_phy);
+-                      goto err_dma;
+-              }
+-      }
 +/**
 + * stmmac_start_tx_dma - start TX DMA channel
 + * @priv: driver private structure
@@ -3756,7 +3728,8 @@
 +      netdev_dbg(priv->dev, "DMA TX processes started in channel %d\n", chan);
 +      priv->hw->dma->start_tx(priv->ioaddr, chan);
 +}
-+
+ 
+-      return 0;
 +/**
 + * stmmac_stop_rx_dma - stop RX DMA channel
 + * @priv: driver private structure
@@ -3769,7 +3742,16 @@
 +      netdev_dbg(priv->dev, "DMA RX processes stopped in channel %d\n", chan);
 +      priv->hw->dma->stop_rx(priv->ioaddr, chan);
 +}
-+
+ 
+-err_dma:
+-      kfree(priv->tx_skbuff);
+-err_tx_skbuff:
+-      kfree(priv->tx_skbuff_dma);
+-err_tx_skbuff_dma:
+-      kfree(priv->rx_skbuff);
+-err_rx_skbuff:
+-      kfree(priv->rx_skbuff_dma);
+-      return ret;
 +/**
 + * stmmac_stop_tx_dma - stop TX DMA channel
 + * @priv: driver private structure
@@ -3781,8 +3763,9 @@
 +{
 +      netdev_dbg(priv->dev, "DMA TX processes stopped in channel %d\n", chan);
 +      priv->hw->dma->stop_tx(priv->ioaddr, chan);
-+}
-+
+ }
+ 
+-static void free_dma_desc_resources(struct stmmac_priv *priv)
 +/**
 + * stmmac_start_all_dma - start all RX and TX DMA channels
 + * @priv: driver private structure
@@ -3790,7 +3773,31 @@
 + * This starts all the RX and TX DMA channels
 + */
 +static void stmmac_start_all_dma(struct stmmac_priv *priv)
-+{
+ {
+-      /* Release the DMA TX/RX socket buffers */
+-      dma_free_rx_skbufs(priv);
+-      dma_free_tx_skbufs(priv);
+-
+-      /* Free DMA regions of consistent memory previously allocated */
+-      if (!priv->extend_desc) {
+-              dma_free_coherent(priv->device,
+-                                DMA_TX_SIZE * sizeof(struct dma_desc),
+-                                priv->dma_tx, priv->dma_tx_phy);
+-              dma_free_coherent(priv->device,
+-                                DMA_RX_SIZE * sizeof(struct dma_desc),
+-                                priv->dma_rx, priv->dma_rx_phy);
+-      } else {
+-              dma_free_coherent(priv->device, DMA_TX_SIZE *
+-                                sizeof(struct dma_extended_desc),
+-                                priv->dma_etx, priv->dma_tx_phy);
+-              dma_free_coherent(priv->device, DMA_RX_SIZE *
+-                                sizeof(struct dma_extended_desc),
+-                                priv->dma_erx, priv->dma_rx_phy);
+-      }
+-      kfree(priv->rx_skbuff_dma);
+-      kfree(priv->rx_skbuff);
+-      kfree(priv->tx_skbuff_dma);
+-      kfree(priv->tx_skbuff);
 +      u32 rx_channels_count = priv->plat->rx_queues_to_use;
 +      u32 tx_channels_count = priv->plat->tx_queues_to_use;
 +      u32 chan = 0;
@@ -3800,23 +3807,38 @@
 +
 +      for (chan = 0; chan < tx_channels_count; chan++)
 +              stmmac_start_tx_dma(priv, chan);
-+}
-+
-+/**
+ }
+ 
+ /**
+- *  stmmac_mac_enable_rx_queues - Enable MAC rx queues
+- *  @priv: driver private structure
+- *  Description: It is used for enabling the rx queues in the MAC
 + * stmmac_stop_all_dma - stop all RX and TX DMA channels
 + * @priv: driver private structure
 + * Description:
 + * This stops the RX and TX DMA channels
-+ */
+  */
+-static void stmmac_mac_enable_rx_queues(struct stmmac_priv *priv)
 +static void stmmac_stop_all_dma(struct stmmac_priv *priv)
-+{
+ {
+-      int rx_count = priv->dma_cap.number_rx_queues;
+-      int queue = 0;
 +      u32 rx_channels_count = priv->plat->rx_queues_to_use;
 +      u32 tx_channels_count = priv->plat->tx_queues_to_use;
 +      u32 chan = 0;
-+
+ 
+-      /* If GMAC does not have multiple queues, then this is not necessary*/
+-      if (rx_count == 1)
+-              return;
 +      for (chan = 0; chan < rx_channels_count; chan++)
 +              stmmac_stop_rx_dma(priv, chan);
-+
+ 
+-      /**
+-       *  If the core is synthesized with multiple rx queues / multiple
+-       *  dma channels, then rx queues will be disabled by default.
+-       *  For now only rx queue 0 is enabled.
+-       */
+-      priv->hw->mac->rx_queue_enable(priv->hw, queue);
 +      for (chan = 0; chan < tx_channels_count; chan++)
 +              stmmac_stop_tx_dma(priv, chan);
  }
-- 
2.7.4


_______________________________________________
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Reply via email to