net: stmmac: Signal to PHY/PCS drivers to keep RX clock on
authorRomain Gantois <romain.gantois@bootlin.com>
Tue, 26 Mar 2024 13:32:11 +0000 (14:32 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 29 Mar 2024 02:21:34 +0000 (19:21 -0700)
There is a reocurring issue with stmmac controllers where the MAC fails to
initialize its hardware if an RX clock signal isn't provided on the MAC/PHY
link.

This causes issues when PHY or PCS devices either go into suspend while
cutting the RX clock or do not bring the clock signal up early enough for
the MAC to initialize successfully.

Set the mac_requires_rxc flag in the stmmac phylink config so that PHY/PCS
drivers know to keep the RX clock up at all times.

Reported-by: Clark Wang <xiaoning.wang@nxp.com>
Link: https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/
Reported-by: Clément Léger <clement.leger@bootlin.com>
Link: https://lore.kernel.org/linux-arm-kernel/20230116103926.276869-4-clement.leger@bootlin.com/
Co-developed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20240326-rxc_bugfix-v6-5-24a74e5c761f@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 1ee06a6e5c22f9a3c35000725a49e9891504ee92..fe3498e86de9dd3e59ee0aecb3eb092489640d95 100644 (file)
@@ -1218,6 +1218,9 @@ static int stmmac_phy_setup(struct stmmac_priv *priv)
        priv->phylink_config.type = PHYLINK_NETDEV;
        priv->phylink_config.mac_managed_pm = true;
 
+       /* Stmmac always requires an RX clock for hardware initialization */
+       priv->phylink_config.mac_requires_rxc = true;
+
        mdio_bus_data = priv->plat->mdio_bus_data;
        if (mdio_bus_data)
                priv->phylink_config.ovr_an_inband =
@@ -3408,6 +3411,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
        u32 chan;
        int ret;
 
+       /* Make sure RX clock is enabled */
+       if (priv->hw->phylink_pcs)
+               phylink_pcs_pre_init(priv->phylink, priv->hw->phylink_pcs);
+
        /* DMA initialization and SW reset */
        ret = stmmac_init_dma_engine(priv);
        if (ret < 0) {