diff mbox series

[net-next,v5,6/7] net: phy: qcom: at803x: Avoid hibernating if MAC requires RX clock

Message ID 20240301-rxc_bugfix-v5-6-8dac30230050@bootlin.com (mailing list archive)
State New, archived
Headers show
Series Fix missing PHY-to-MAC RX clock | expand

Commit Message

Romain Gantois March 1, 2024, 3:35 p.m. UTC
From: Russell King <linux@armlinux.org.uk>

Stmmac controllers connected to an at803x PHY cannot resume properly after
suspend when WoL is enabled. This happens because the MAC requires an RX
clock generated by the PHY to initialize its hardware properly. But the RX
clock is cut when the PHY suspends and isn't brought up until the MAC
driver resumes the phylink.

Prevent the at803x PHY driver from going into suspend if the attached MAC
driver always requires an RX clock signal.

Reported-by: Clark Wang <xiaoning.wang@nxp.com>
Link: https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/
Signed-off-by: Russell King <linux@armlinux.org.uk>
[rgantois: commit log]
Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>
---
 drivers/net/phy/qcom/at803x.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrew Lunn March 4, 2024, 1:44 p.m. UTC | #1
On Fri, Mar 01, 2024 at 04:35:03PM +0100, Romain Gantois wrote:
> From: Russell King <linux@armlinux.org.uk>
> 
> Stmmac controllers connected to an at803x PHY cannot resume properly after
> suspend when WoL is enabled. This happens because the MAC requires an RX
> clock generated by the PHY to initialize its hardware properly. But the RX
> clock is cut when the PHY suspends and isn't brought up until the MAC
> driver resumes the phylink.
> 
> Prevent the at803x PHY driver from going into suspend if the attached MAC
> driver always requires an RX clock signal.
> 
> Reported-by: Clark Wang <xiaoning.wang@nxp.com>
> Link: https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/
> Signed-off-by: Russell King <linux@armlinux.org.uk>
> [rgantois: commit log]
> Signed-off-by: Romain Gantois <romain.gantois@bootlin.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Russell King (Oracle) March 4, 2024, 2:34 p.m. UTC | #2
On Fri, Mar 01, 2024 at 04:35:03PM +0100, Romain Gantois wrote:
> From: Russell King <linux@armlinux.org.uk>
> 
> Stmmac controllers connected to an at803x PHY cannot resume properly after
> suspend when WoL is enabled. This happens because the MAC requires an RX
> clock generated by the PHY to initialize its hardware properly. But the RX
> clock is cut when the PHY suspends and isn't brought up until the MAC
> driver resumes the phylink.
> 
> Prevent the at803x PHY driver from going into suspend if the attached MAC
> driver always requires an RX clock signal.
> 
> Reported-by: Clark Wang <xiaoning.wang@nxp.com>
> Link: https://lore.kernel.org/all/20230202081559.3553637-1-xiaoning.wang@nxp.com/
> Signed-off-by: Russell King <linux@armlinux.org.uk>

Wrong wrong wrong wrong wrong.
diff mbox series

Patch

diff --git a/drivers/net/phy/qcom/at803x.c b/drivers/net/phy/qcom/at803x.c
index 4717c59d51d0..2a221b81cf37 100644
--- a/drivers/net/phy/qcom/at803x.c
+++ b/drivers/net/phy/qcom/at803x.c
@@ -426,7 +426,8 @@  static int at803x_hibernation_mode_config(struct phy_device *phydev)
 	/* The default after hardware reset is hibernation mode enabled. After
 	 * software reset, the value is retained.
 	 */
-	if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE))
+	if (!(priv->flags & AT803X_DISABLE_HIBERNATION_MODE) &&
+	    !(phydev->dev_flags & PHY_F_RXC_ALWAYS_ON))
 		return 0;
 
 	return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_HIB_CTRL,