+++ /dev/null
-From: Felix Fietkau <nbd@nbd.name>
-Date: Wed, 26 Aug 2020 17:48:14 +0200
-Subject: [PATCH] net: ethernet: mtk_eth_soc: drop descriptor cpu-own bit check
- in qdma tx cleanup
-
-mtk_poll_tx_qdma already checks the MTK_QTX_DRX_PTR register, which points
-at the last completed descriptor.
-To slightly improve performance, also remove the register bit which forces
-the hardware to write back this bit earlier.
-
-Signed-off-by: Felix Fietkau <nbd@nbd.name>
----
-
---- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -1368,9 +1368,6 @@ static int mtk_poll_tx_qdma(struct mtk_e
- int mac = 0;
-
- desc = mtk_qdma_phys_to_virt(ring, desc->txd2);
-- if ((desc->txd3 & TX_DMA_OWNER_CPU) == 0)
-- break;
--
- tx_buf = mtk_desc_to_tx_buf(ring, desc);
- if (tx_buf->flags & MTK_TX_FLAGS_FPORT1)
- mac = 1;
-@@ -2203,7 +2200,7 @@ static int mtk_start_dma(struct mtk_eth
-
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) {
- mtk_w32(eth,
-- MTK_TX_WB_DDONE | MTK_TX_DMA_EN |
-+ MTK_TX_DMA_EN |
- MTK_TX_BT_32DWORDS | MTK_NDP_CO_PRO |
- MTK_RX_DMA_EN | MTK_RX_2B_OFFSET |
- MTK_RX_BT_32DWORDS,
dma = mtk_r32(eth, MTK_QTX_DRX_PTR);
desc = mtk_qdma_phys_to_virt(ring, cpu);
-@@ -1389,6 +1389,7 @@ static int mtk_poll_tx_qdma(struct mtk_e
+@@ -1392,6 +1392,7 @@ static int mtk_poll_tx_qdma(struct mtk_e
cpu = next_cpu;
}
mtk_w32(eth, cpu, MTK_QTX_CRX_PTR);
return budget;
-@@ -1589,6 +1590,7 @@ static int mtk_tx_alloc(struct mtk_eth *
+@@ -1592,6 +1593,7 @@ static int mtk_tx_alloc(struct mtk_eth *
atomic_set(&ring->free_count, MTK_DMA_SIZE - 2);
ring->next_free = &ring->dma[0];
ring->last_free = &ring->dma[MTK_DMA_SIZE - 1];
ring->thresh = MAX_SKB_FRAGS;
/* make sure that all changes to the dma ring are flushed before we
-@@ -1602,9 +1604,7 @@ static int mtk_tx_alloc(struct mtk_eth *
+@@ -1605,9 +1607,7 @@ static int mtk_tx_alloc(struct mtk_eth *
mtk_w32(eth,
ring->phys + ((MTK_DMA_SIZE - 1) * sz),
MTK_QTX_CRX_PTR);
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -1512,8 +1512,8 @@ static int mtk_napi_tx(struct napi_struc
+@@ -1515,8 +1515,8 @@ static int mtk_napi_tx(struct napi_struc
if (status & MTK_TX_DONE_INT)
return budget;
return tx_done;
}
-@@ -1546,8 +1546,9 @@ poll_again:
+@@ -1549,8 +1549,9 @@ poll_again:
remain_budget -= rx_done;
goto poll_again;
}
#include "mtk_eth_soc.h"
-@@ -1319,8 +1321,16 @@ static int mtk_poll_rx(struct napi_struc
+@@ -1320,8 +1322,16 @@ static int mtk_poll_rx(struct napi_struc
(trxd.rxd2 & RX_DMA_VTAG))
__vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
RX_DMA_VID(trxd.rxd3));
skip_rx:
ring->data[idx] = new_data;
-@@ -2251,6 +2261,9 @@ static int mtk_open(struct net_device *d
+@@ -2255,6 +2265,9 @@ static int mtk_open(struct net_device *d
mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
mtk_rx_irq_enable(eth, MTK_RX_DONE_INT);
refcount_set(ð->dma_refcnt, 1);
}
else
refcount_inc(ð->dma_refcnt);
-@@ -2312,6 +2325,9 @@ static int mtk_stop(struct net_device *d
+@@ -2316,6 +2329,9 @@ static int mtk_stop(struct net_device *d
mtk_dma_free(eth);
return 0;
}
-@@ -2825,6 +2841,27 @@ static int mtk_set_rxnfc(struct net_devi
+@@ -2829,6 +2845,27 @@ static int mtk_set_rxnfc(struct net_devi
return ret;
}
static const struct ethtool_ops mtk_ethtool_ops = {
.get_link_ksettings = mtk_get_link_ksettings,
.set_link_ksettings = mtk_set_link_ksettings,
-@@ -2856,6 +2893,9 @@ static const struct net_device_ops mtk_n
+@@ -2860,6 +2897,9 @@ static const struct net_device_ops mtk_n
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = mtk_poll_controller,
#endif
};
static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
-@@ -3198,6 +3238,7 @@ static const struct mtk_soc_data mt7622_
+@@ -3202,6 +3242,7 @@ static const struct mtk_soc_data mt7622_
.hw_features = MTK_HW_FEATURES,
.required_clks = MT7622_CLKS_BITMAP,
.required_pctl = false,
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -2236,6 +2236,31 @@ static int mtk_start_dma(struct mtk_eth
+@@ -2240,6 +2240,31 @@ static int mtk_start_dma(struct mtk_eth
return 0;
}
static int mtk_open(struct net_device *dev)
{
struct mtk_mac *mac = netdev_priv(dev);
-@@ -2256,6 +2281,8 @@ static int mtk_open(struct net_device *d
+@@ -2260,6 +2285,8 @@ static int mtk_open(struct net_device *d
if (err)
return err;
napi_enable(ð->tx_napi);
napi_enable(ð->rx_napi);
mtk_tx_irq_enable(eth, MTK_TX_DONE_INT);
-@@ -2311,6 +2338,8 @@ static int mtk_stop(struct net_device *d
+@@ -2315,6 +2342,8 @@ static int mtk_stop(struct net_device *d
if (!refcount_dec_and_test(ð->dma_refcnt))
return 0;
mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
mtk_rx_irq_disable(eth, MTK_RX_DONE_INT);
napi_disable(ð->tx_napi);
-@@ -2494,8 +2523,6 @@ static int mtk_hw_init(struct mtk_eth *e
+@@ -2498,8 +2527,6 @@ static int mtk_hw_init(struct mtk_eth *e
/* disable delay and normal interrupt */
mtk_tx_irq_disable(eth, ~0);
mtk_rx_irq_disable(eth, ~0);
/* FE int grouping */
mtk_w32(eth, MTK_TX_DONE_INT, MTK_PDMA_INT_GRP1);
-@@ -2504,19 +2531,6 @@ static int mtk_hw_init(struct mtk_eth *e
+@@ -2508,19 +2535,6 @@ static int mtk_hw_init(struct mtk_eth *e
mtk_w32(eth, MTK_RX_DONE_INT, MTK_QDMA_INT_GRP2);
mtk_w32(eth, 0x21021000, MTK_FE_INT_GRP);
#include <linux/mfd/syscon.h>
#include <linux/regmap.h>
#include <linux/clk.h>
-@@ -2472,6 +2473,12 @@ static int mtk_hw_init(struct mtk_eth *e
+@@ -2476,6 +2477,12 @@ static int mtk_hw_init(struct mtk_eth *e
if (ret)
goto err_disable_pm;
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
ret = device_reset(eth->dev);
if (ret) {
-@@ -3074,6 +3081,16 @@ static int mtk_probe(struct platform_dev
+@@ -3078,6 +3085,16 @@ static int mtk_probe(struct platform_dev
}
}