net: stmmac: work around sporadic tx issue on link-up
Subsystems (4)
PATCH v2 1/1 net: stmmac: work around sporadic tx issue on link-up
This is a follow-up to the discussion in [0]. It seems to me that at least the IP version used on Amlogic SoC's sometimes has a problem if register MAC_CTRL_REG is written whilst the chip is still processing a previous write. But that's just a guess.
Adding a delay between two writes to this register helps, but we can also simply omit the offending second write. This patch uses the second approach and is based on a suggestion from Qi Duan.
Benefit of this approach is that we can save few register writes, also on not affected chip versions.
[0] https://www.spinics.net/lists/netdev/msg831526.html
v2:
- change Fixes tag to the commmit that added stmmac_set_mac() 11yrs ago
--- drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c | 8 ++++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 9 +++++---- 2 files changed, 11 insertions(+), 6 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c +6 -2
@@ -258,14 +258,18 @@ EXPORT_SYMBOL_GPL(stmmac_set_mac_addr);/* Enable disable MAC RX/TX */ void stmmac_set_mac (void __iomem *ioaddr,bool enable) { -u32 value =readl (ioaddr +MAC_CTRL_REG ); +u32 old_val, value; + + old_val =readl (ioaddr +MAC_CTRL_REG ); + value = old_val;if (enable) value |=MAC_ENABLE_RX |MAC_ENABLE_TX ;else value &= ~(MAC_ENABLE_TX |MAC_ENABLE_RX ); -writel (value, ioaddr +MAC_CTRL_REG ); +if (value != old_val) +writel (value, ioaddr +MAC_CTRL_REG ); } void stmmac_get_mac_addr(void __iomem *ioaddr, unsigned char *addr,
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +5 -4
@@ -986,10 +986,10 @@ static void stmmac_mac_link_up(struct phylink_config *config, bool tx_pause, bool rx_pause) {struct stmmac_priv *priv =netdev_priv (to_net_dev (config->dev)); -u32 ctrl; +u32 old_ctrl, ctrl; - ctrl =readl (priv->ioaddr +MAC_CTRL_REG ); - ctrl &= ~priv->hw->link.speed_mask; + old_ctrl =readl (priv->ioaddr +MAC_CTRL_REG ); + ctrl = old_ctrl & ~priv->hw->link.speed_mask;if (interface ==PHY_INTERFACE_MODE_USXGMII ) {switch (speed) {
@@ -1064,7 +1064,8 @@ static void stmmac_mac_link_up(struct phylink_config *config,if (tx_pause && rx_pause)stmmac_mac_flow_ctrl (priv, duplex); -writel (ctrl, priv->ioaddr +MAC_CTRL_REG ); +if (ctrl != old_ctrl) +writel (ctrl, priv->ioaddr +MAC_CTRL_REG );stmmac_mac_set (priv, priv->ioaddr, true);if (phy && priv->dma_cap.eee) {
Signature · 1 line
2.37.2
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Wed, 24 Aug 2022 22:34:49 +0200 you wrote:
This is a follow-up to the discussion in [0]. It seems to me that at least the IP version used on Amlogic SoC's sometimes has a problem if register
MAC_CTRL_REGis written whilst the chip is still processing a previous write. But that's just a guess.
Adding a delay between two writes to this register helps, but we can also simply omit the offending second write. This patch uses the second approach and is based on a suggestion from Qi Duan.
Benefit of this approach is that we can save few register writes, also on not affected chip versions.[...]
Here is the summary with links:
- [v2,net] net: stmmac: work around sporadic tx issue on link-up
https://git.kernel.org/netdev/net/c/a3a57bf07de2
You are awesome, thank you!
Signature · 9 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel