[][kernel][mt7988][eth][Fix DMA init timeout in network-restart stress test]
[Description]
Fix DMA init timeout in network-restart stress test :
1. Turn on the gmac forwarding when mkt_open is only halfway initialized
or start deinit in mtk_close without forbid forwarding in gmac, this
can lead to unknown exceptions.
2. Update the init/deinit order in mtk_open/mtk_close.
3. Move the configure of gdm from mtk_mac_config to mtk_hw_init, avoid
asynchronous operations on gdm config.
4. Update related patches.
[Release-log]
N/A
Change-Id: I80f594948b0c0ddc7eb34bb47e78e2ff74229f6a
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6728789
diff --git a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 89f1150..889b7fd 100755
--- a/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/target/linux/mediatek/files-5.4/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -283,11 +283,6 @@
val |= (GSW_IPG_11 << GSWTX_IPG_SHIFT) |
(GSW_IPG_11 << GSWRX_IPG_SHIFT);
mtk_w32(eth, val, MTK_GSW_CFG);
-
- /* Disable GDM1 RX CRC stripping */
- val = mtk_r32(eth, MTK_GDMA_FWD_CFG(0));
- val &= ~MTK_GDMA_STRP_CRC;
- mtk_w32(eth, val, MTK_GDMA_FWD_CFG(0));
}
static void mtk_mac_config(struct phylink_config *config, unsigned int mode,
@@ -3045,29 +3040,27 @@
return 0;
}
-void mtk_gdm_config(struct mtk_eth *eth, u32 config)
+void mtk_gdm_config(struct mtk_eth *eth, u32 id, u32 config)
{
- int i;
+ u32 val;
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
return;
- for (i = 0; i < MTK_MAC_COUNT; i++) {
- u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i));
+ val = mtk_r32(eth, MTK_GDMA_FWD_CFG(id));
- /* default setup the forward port to send frame to PDMA */
- val &= ~0xffff;
+ /* default setup the forward port to send frame to PDMA */
+ val &= ~0xffff;
- /* Enable RX checksum */
- val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;
+ /* Enable RX checksum */
+ val |= MTK_GDMA_ICS_EN | MTK_GDMA_TCS_EN | MTK_GDMA_UCS_EN;
- val |= config;
+ val |= config;
- if (eth->netdev[i] && netdev_uses_dsa(eth->netdev[i]))
- val |= MTK_GDMA_SPECIAL_TAG;
+ if (eth->netdev[id] && netdev_uses_dsa(eth->netdev[id]))
+ val |= MTK_GDMA_SPECIAL_TAG;
- mtk_w32(eth, val, MTK_GDMA_FWD_CFG(i));
- }
+ mtk_w32(eth, val, MTK_GDMA_FWD_CFG(id));
}
void mtk_set_pse_drop(u32 config)
@@ -3101,7 +3094,6 @@
if (err)
return err;
- mtk_gdm_config(eth, MTK_GDMA_TO_PDMA);
/* Indicates CDM to parse the MTK special tag from CPU */
if (netdev_uses_dsa(dev)) {
@@ -3163,6 +3155,8 @@
if (!phy_node && eth->xgmii->regmap_sgmii[mac->id])
regmap_write(eth->xgmii->regmap_sgmii[mac->id], SGMSYS_QPHY_PWR_STATE_CTRL, 0);
+ mtk_gdm_config(eth, mac->id, MTK_GDMA_TO_PDMA);
+
return 0;
}
@@ -3197,6 +3191,7 @@
u32 val = 0;
struct device_node *phy_node;
+ mtk_gdm_config(eth, mac->id, MTK_GDMA_DROP_ALL);
netif_tx_disable(dev);
phy_node = of_parse_phandle(mac->of_node, "phy-handle", 0);
@@ -3222,7 +3217,6 @@
if (!refcount_dec_and_test(ð->dma_refcnt))
return 0;
- mtk_gdm_config(eth, MTK_GDMA_DROP_ALL);
mtk_tx_irq_disable(eth, MTK_TX_DONE_INT);
mtk_rx_irq_disable(eth, MTK_RX_DONE_INT(0));
@@ -3318,6 +3312,7 @@
static int mtk_hw_init(struct mtk_eth *eth, u32 type)
{
int i, ret = 0;
+ u32 val;
pr_info("[%s] reset_lock:%d, force:%d\n", __func__,
atomic_read(&reset_lock), atomic_read(&force));
@@ -3420,6 +3415,11 @@
mtk_w32(eth, 0x00000707, MTK_CDMW0_THRES);
mtk_w32(eth, 0x00000077, MTK_CDMW1_THRES);
+ /* Disable GDM1 RX CRC stripping */
+ val = mtk_r32(eth, MTK_GDMA_FWD_CFG(0));
+ val &= ~MTK_GDMA_STRP_CRC;
+ mtk_w32(eth, val, MTK_GDMA_FWD_CFG(0));
+
/* PSE GDM3 MIB counter has incorrect hw default values,
* so the driver ought to read clear the values beforehand
* in case ethtool retrieve wrong mib values.