]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
stmmac: add length field to dma data
authorGiuseppe Cavallaro <peppe.cavallaro@st.com>
Mon, 29 Feb 2016 13:27:31 +0000 (14:27 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Mar 2016 19:21:31 +0000 (14:21 -0500)
Currently, the code pulls out the length field when
unmapping a buffer directly from the descriptor. This will result
in an uncached read to a dma_alloc_coherent() region. There is no
need to do this, so this patch simply puts the value directly into
a data structure which will hit the cache.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: Alexandre TORGUE <alexandre.torgue@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/chain_mode.c
drivers/net/ethernet/stmicro/stmmac/ring_mode.c
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 2763772ef1d481b28e37a1a73c0fd9974506a3c7..7fa7ab0d90bc54695781621eb5c07675019e0e7f 100644 (file)
@@ -49,6 +49,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
        if (dma_mapping_error(priv->device, desc->des2))
                return -1;
        priv->tx_skbuff_dma[entry].buf = desc->des2;
+       priv->tx_skbuff_dma[entry].len = bmax;
        priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE);
 
        while (len != 0) {
@@ -63,6 +64,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                        if (dma_mapping_error(priv->device, desc->des2))
                                return -1;
                        priv->tx_skbuff_dma[entry].buf = desc->des2;
+                       priv->tx_skbuff_dma[entry].len = bmax;
                        priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum,
                                                        STMMAC_CHAIN_MODE);
                        priv->hw->desc->set_tx_owner(desc);
@@ -75,6 +77,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                        if (dma_mapping_error(priv->device, desc->des2))
                                return -1;
                        priv->tx_skbuff_dma[entry].buf = desc->des2;
+                       priv->tx_skbuff_dma[entry].len = len;
                        priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
                                                        STMMAC_CHAIN_MODE);
                        priv->hw->desc->set_tx_owner(desc);
index 4358a87fbc6e9190cabd2db09d2eb7789b5a775e..cfc2f24ba08b8e9443daa0e885d170b0c4071949 100644 (file)
@@ -56,6 +56,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                        return -1;
 
                priv->tx_skbuff_dma[entry].buf = desc->des2;
+               priv->tx_skbuff_dma[entry].len = bmax;
+
                desc->des3 = desc->des2 + BUF_SIZE_4KiB;
                priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum,
                                                STMMAC_RING_MODE);
@@ -73,6 +75,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                if (dma_mapping_error(priv->device, desc->des2))
                        return -1;
                priv->tx_skbuff_dma[entry].buf = desc->des2;
+               priv->tx_skbuff_dma[entry].len = len;
+
                desc->des3 = desc->des2 + BUF_SIZE_4KiB;
                priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
                                                STMMAC_RING_MODE);
@@ -84,6 +88,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
                if (dma_mapping_error(priv->device, desc->des2))
                        return -1;
                priv->tx_skbuff_dma[entry].buf = desc->des2;
+               priv->tx_skbuff_dma[entry].len = nopaged_len;
                desc->des3 = desc->des2 + BUF_SIZE_4KiB;
                priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len, csum,
                                                STMMAC_RING_MODE);
index 7ae7c6430a3fe9054a821012df95b683cc848289..c497460c90614916e5b0c580940672652159ec7d 100644 (file)
@@ -45,6 +45,7 @@ struct stmmac_resources {
 struct stmmac_tx_info {
        dma_addr_t buf;
        bool map_as_page;
+       unsigned len;
 };
 
 struct stmmac_priv {
index eb555f0fe81585d107c1a445a432175869e68d4c..90a946f3f7838e6a1c3cc366226e5c0b0e962d71 100644 (file)
@@ -1093,6 +1093,7 @@ static int init_dma_desc_rings(struct net_device *dev, gfp_t flags)
                p->des2 = 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[i] = NULL;
        }
 
@@ -1136,12 +1137,12 @@ static void dma_free_tx_skbufs(struct stmmac_priv *priv)
                        if (priv->tx_skbuff_dma[i].map_as_page)
                                dma_unmap_page(priv->device,
                                               priv->tx_skbuff_dma[i].buf,
-                                              priv->hw->desc->get_tx_len(p),
+                                              priv->tx_skbuff_dma[i].len,
                                               DMA_TO_DEVICE);
                        else
                                dma_unmap_single(priv->device,
                                                 priv->tx_skbuff_dma[i].buf,
-                                                priv->hw->desc->get_tx_len(p),
+                                                priv->tx_skbuff_dma[i].len,
                                                 DMA_TO_DEVICE);
                }
 
@@ -1347,12 +1348,12 @@ static void stmmac_tx_clean(struct stmmac_priv *priv)
                        if (priv->tx_skbuff_dma[entry].map_as_page)
                                dma_unmap_page(priv->device,
                                               priv->tx_skbuff_dma[entry].buf,
-                                              priv->hw->desc->get_tx_len(p),
+                                              priv->tx_skbuff_dma[entry].len,
                                               DMA_TO_DEVICE);
                        else
                                dma_unmap_single(priv->device,
                                                 priv->tx_skbuff_dma[entry].buf,
-                                                priv->hw->desc->get_tx_len(p),
+                                                priv->tx_skbuff_dma[entry].len,
                                                 DMA_TO_DEVICE);
                        priv->tx_skbuff_dma[entry].buf = 0;
                        priv->tx_skbuff_dma[entry].map_as_page = false;
@@ -1986,6 +1987,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
                if (dma_mapping_error(priv->device, desc->des2))
                        goto dma_map_err;
                priv->tx_skbuff_dma[entry].buf = desc->des2;
+               priv->tx_skbuff_dma[entry].len = nopaged_len;
                priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len,
                                                csum_insertion, priv->mode);
        } else {
@@ -2014,6 +2016,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
                priv->tx_skbuff_dma[entry].buf = desc->des2;
                priv->tx_skbuff_dma[entry].map_as_page = true;
+               priv->tx_skbuff_dma[entry].len = len;
                priv->hw->desc->prepare_tx_desc(desc, 0, len, csum_insertion,
                                                priv->mode);
                wmb();