kernel: Mediatek: set default EEE Tx LPI timer
authorQingfang Deng <dqfext@gmail.com>
Fri, 7 Mar 2025 12:33:06 +0000 (20:33 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Fri, 7 Mar 2025 12:39:13 +0000 (20:39 +0800)
Due to API changes during the backport, the default value of Tx LPI
timer is accidentally left unset, breaking the network if EEE is on.
Set the default timer to 1ms on init, and fix an incorrect condition.

Fixes: d8315d5358d5 ("kernel: backport Mediatek SoC EEE support")
Signed-off-by: Qingfang Deng <dqfext@gmail.com>
target/linux/generic/backport-6.6/753-v6.15-net-ethernet-mediatek-add-EEE-support.patch
target/linux/generic/hack-6.6/730-net-ethernet-mtk_eth_soc-add-hw-dump-for-forced-rese.patch
target/linux/generic/pending-6.6/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch
target/linux/generic/pending-6.6/737-net-ethernet-mtk_eth_soc-add-paths-and-SerDes-modes-.patch
target/linux/generic/pending-6.6/738-01-net-ethernet-mtk_eth_soc-reduce-rx-ring-size-for-older.patch
target/linux/generic/pending-6.6/738-02-net-ethernet-mtk_eth_soc-do-not-enable-page-pool-sta.patch

index 321fbf5f9c4b157714fad82164f598301b135205..d9b86ae36e26027f0d39dc4eedaa67ab3fa4dc6b 100644 (file)
@@ -42,7 +42,15 @@ Signed-off-by: Qingfang Deng <dqfext@gmail.com>
        mcr |= MAC_MCR_TX_EN | MAC_MCR_RX_EN | MAC_MCR_FORCE_LINK;
        mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
  }
-@@ -4476,6 +4489,55 @@ static int mtk_set_pauseparam(struct net
+@@ -3956,6 +3969,7 @@ static int mtk_hw_init(struct mtk_eth *e
+                       continue;
+               mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i));
++              mtk_w32(eth, FIELD_PREP(MAC_EEE_LPI_TXIDLE_THD, 1), MTK_MAC_EEECR(i));
+               mtk_set_mcr_max_rx(netdev_priv(dev),
+                                  dev->mtu + MTK_RX_ETH_HLEN);
+       }
+@@ -4476,6 +4490,55 @@ static int mtk_set_pauseparam(struct net
        return phylink_ethtool_set_pauseparam(mac->phylink, pause);
  }
  
@@ -82,7 +90,7 @@ Signed-off-by: Qingfang Deng <dqfext@gmail.com>
 +      reg |= FIELD_PREP(MAC_EEE_WAKEUP_TIME_1000, 17) |
 +             FIELD_PREP(MAC_EEE_WAKEUP_TIME_100, 36);
 +
-+      if (!eee->tx_lpi_enabled)
++      if (!txidle_thd_ms)
 +              /* Force LPI Mode without a delay */
 +              reg |= MAC_EEE_LPI_MODE;
 +
@@ -98,7 +106,7 @@ Signed-off-by: Qingfang Deng <dqfext@gmail.com>
  static u16 mtk_select_queue(struct net_device *dev, struct sk_buff *skb,
                            struct net_device *sb_dev)
  {
-@@ -4508,6 +4570,8 @@ static const struct ethtool_ops mtk_etht
+@@ -4508,6 +4571,8 @@ static const struct ethtool_ops mtk_etht
        .set_pauseparam         = mtk_set_pauseparam,
        .get_rxnfc              = mtk_get_rxnfc,
        .set_rxnfc              = mtk_set_rxnfc,
index 5e0aa924daeee62001a4c3cedea0df5a393a5cd8..c25629e8302dc8c86a81d8c36af635f15fc3970c 100644 (file)
@@ -94,7 +94,7 @@ Signed-off-by: Bo-Cun Chen <bc-bocun.chen@mediatek.com>
  static void mtk_hw_reset(struct mtk_eth *eth)
  {
        u32 val;
-@@ -4357,6 +4410,8 @@ static void mtk_pending_work(struct work
+@@ -4358,6 +4411,8 @@ static void mtk_pending_work(struct work
        rtnl_lock();
        set_bit(MTK_RESETTING, &eth->state);
  
index ff98a986e4efd854f20276a64da936e0e6fe0086..021ed9fa73173a087c7e6e4afc965eae702e4f0a 100644 (file)
@@ -10,7 +10,7 @@ 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
-@@ -5100,6 +5100,8 @@ static int mtk_probe(struct platform_dev
+@@ -5101,6 +5101,8 @@ static int mtk_probe(struct platform_dev
         * for NAPI to work
         */
        init_dummy_netdev(&eth->dummy_dev);
index 0601fe545ffb8e64fec3b73364f2845896c4dbc2..09067c47122a8b2bb2a218f25a2cf5652479ad79 100644 (file)
@@ -510,7 +510,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
        return 0;
  }
  
-@@ -4644,6 +4791,7 @@ static const struct net_device_ops mtk_n
+@@ -4645,6 +4792,7 @@ static const struct net_device_ops mtk_n
  static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
  {
        const __be32 *_id = of_get_property(np, "reg", NULL);
@@ -518,7 +518,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
        phy_interface_t phy_mode;
        struct phylink *phylink;
        struct mtk_mac *mac;
-@@ -4680,16 +4828,41 @@ static int mtk_add_mac(struct mtk_eth *e
+@@ -4681,16 +4829,41 @@ static int mtk_add_mac(struct mtk_eth *e
        mac->id = id;
        mac->hw = eth;
        mac->of_node = np;
@@ -568,7 +568,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
        }
  
        memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip));
-@@ -4772,8 +4945,21 @@ static int mtk_add_mac(struct mtk_eth *e
+@@ -4773,8 +4946,21 @@ static int mtk_add_mac(struct mtk_eth *e
                phy_interface_zero(mac->phylink_config.supported_interfaces);
                __set_bit(PHY_INTERFACE_MODE_INTERNAL,
                          mac->phylink_config.supported_interfaces);
@@ -590,7 +590,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
        phylink = phylink_create(&mac->phylink_config,
                                 of_fwnode_handle(mac->of_node),
                                 phy_mode, &mtk_phylink_ops);
-@@ -4824,6 +5010,26 @@ free_netdev:
+@@ -4825,6 +5011,26 @@ free_netdev:
        return err;
  }
  
@@ -617,7 +617,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  void mtk_eth_set_dma_device(struct mtk_eth *eth, struct device *dma_dev)
  {
        struct net_device *dev, *tmp;
-@@ -4970,7 +5176,8 @@ static int mtk_probe(struct platform_dev
+@@ -4971,7 +5177,8 @@ static int mtk_probe(struct platform_dev
                        regmap_write(cci, 0, 3);
        }
  
@@ -627,7 +627,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
                err = mtk_sgmii_init(eth);
  
                if (err)
-@@ -5081,6 +5288,24 @@ static int mtk_probe(struct platform_dev
+@@ -5082,6 +5289,24 @@ static int mtk_probe(struct platform_dev
                }
        }
  
@@ -652,7 +652,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
        if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) {
                err = devm_request_irq(eth->dev, eth->irq[0],
                                       mtk_handle_irq, 0,
-@@ -5184,6 +5409,11 @@ static int mtk_remove(struct platform_de
+@@ -5185,6 +5410,11 @@ static int mtk_remove(struct platform_de
                mtk_stop(eth->netdev[i]);
                mac = netdev_priv(eth->netdev[i]);
                phylink_disconnect_phy(mac->phylink);
index f7c5d02c371c64947bab2188e7af52ace5b4520d..03e610e8c2c9b4a8cb2b6ccbd1fc92344a51101f 100644 (file)
@@ -30,7 +30,7 @@ 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
-@@ -5445,7 +5445,7 @@ static const struct mtk_soc_data mt2701_
+@@ -5446,7 +5446,7 @@ static const struct mtk_soc_data mt2701_
                .desc_size = sizeof(struct mtk_rx_dma),
                .irq_done_mask = MTK_RX_DONE_INT,
                .dma_l4_valid = RX_DMA_L4_VALID,
@@ -39,7 +39,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
                .dma_max_len = MTK_TX_DMA_BUF_LEN,
                .dma_len_offset = 16,
        },
-@@ -5473,7 +5473,7 @@ static const struct mtk_soc_data mt7621_
+@@ -5474,7 +5474,7 @@ static const struct mtk_soc_data mt7621_
                .desc_size = sizeof(struct mtk_rx_dma),
                .irq_done_mask = MTK_RX_DONE_INT,
                .dma_l4_valid = RX_DMA_L4_VALID,
@@ -48,7 +48,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
                .dma_max_len = MTK_TX_DMA_BUF_LEN,
                .dma_len_offset = 16,
        },
-@@ -5503,7 +5503,7 @@ static const struct mtk_soc_data mt7622_
+@@ -5504,7 +5504,7 @@ static const struct mtk_soc_data mt7622_
                .desc_size = sizeof(struct mtk_rx_dma),
                .irq_done_mask = MTK_RX_DONE_INT,
                .dma_l4_valid = RX_DMA_L4_VALID,
@@ -57,7 +57,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
                .dma_max_len = MTK_TX_DMA_BUF_LEN,
                .dma_len_offset = 16,
        },
-@@ -5532,7 +5532,7 @@ static const struct mtk_soc_data mt7623_
+@@ -5533,7 +5533,7 @@ static const struct mtk_soc_data mt7623_
                .desc_size = sizeof(struct mtk_rx_dma),
                .irq_done_mask = MTK_RX_DONE_INT,
                .dma_l4_valid = RX_DMA_L4_VALID,
@@ -66,7 +66,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
                .dma_max_len = MTK_TX_DMA_BUF_LEN,
                .dma_len_offset = 16,
        },
-@@ -5558,7 +5558,7 @@ static const struct mtk_soc_data mt7629_
+@@ -5559,7 +5559,7 @@ static const struct mtk_soc_data mt7629_
                .desc_size = sizeof(struct mtk_rx_dma),
                .irq_done_mask = MTK_RX_DONE_INT,
                .dma_l4_valid = RX_DMA_L4_VALID,
@@ -75,7 +75,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
                .dma_max_len = MTK_TX_DMA_BUF_LEN,
                .dma_len_offset = 16,
        },
-@@ -5590,7 +5590,7 @@ static const struct mtk_soc_data mt7981_
+@@ -5591,7 +5591,7 @@ static const struct mtk_soc_data mt7981_
                .dma_l4_valid = RX_DMA_L4_VALID_V2,
                .dma_max_len = MTK_TX_DMA_BUF_LEN,
                .dma_len_offset = 16,
@@ -84,7 +84,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        },
  };
  
-@@ -5620,7 +5620,7 @@ static const struct mtk_soc_data mt7986_
+@@ -5621,7 +5621,7 @@ static const struct mtk_soc_data mt7986_
                .dma_l4_valid = RX_DMA_L4_VALID_V2,
                .dma_max_len = MTK_TX_DMA_BUF_LEN,
                .dma_len_offset = 16,
@@ -93,7 +93,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        },
  };
  
-@@ -5673,7 +5673,7 @@ static const struct mtk_soc_data rt5350_
+@@ -5674,7 +5674,7 @@ static const struct mtk_soc_data rt5350_
                .dma_l4_valid = RX_DMA_L4_VALID_PDMA,
                .dma_max_len = MTK_TX_DMA_BUF_LEN,
                .dma_len_offset = 16,
index 3164641376c7dd6df68c318dfe5ebaccb4e659dd..c74c9e888fb81f64d4f6cf629bdec104974582f1 100644 (file)
@@ -25,7 +25,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        help
 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
-@@ -4565,6 +4565,7 @@ static int mtk_get_sset_count(struct net
+@@ -4566,6 +4566,7 @@ static int mtk_get_sset_count(struct net
  
  static void mtk_ethtool_pp_stats(struct mtk_eth *eth, u64 *data)
  {
@@ -33,7 +33,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        struct page_pool_stats stats = {};
        int i;
  
-@@ -4577,6 +4578,7 @@ static void mtk_ethtool_pp_stats(struct
+@@ -4578,6 +4579,7 @@ static void mtk_ethtool_pp_stats(struct
                page_pool_get_stats(ring->page_pool, &stats);
        }
        page_pool_ethtool_stats_get(data, &stats);