RE: [PATCH] net: stmmac: fix MAC not working when system resume back with WoL enabled
From: Joakim Zhang <hidden>
Date: 2021-09-02 11:15:51
Hi Russell,
-----Original Message----- From: Russell King <linux@armlinux.org.uk> Sent: 2021年9月2日 18:50 To: Joakim Zhang <redacted> Cc: Vladimir Oltean <olteanv@gmail.com>; peppe.cavallaro@st.com; alexandre.torgue@foss.st.com; joabreu@synopsys.com; davem@davemloft.net; kuba@kernel.org; mcoquelin.stm32@gmail.com; netdev@vger.kernel.org; andrew@lunn.ch; f.fainelli@gmail.com; hkallweit1@gmail.com; dl-linux-imx [off-list ref] Subject: Re: [PATCH] net: stmmac: fix MAC not working when system resume back with WoL enabled On Thu, Sep 02, 2021 at 10:26:13AM +0000, Joakim Zhang wrote:quoted
Hi Russell, Thanks a lot!quoted
-----Original Message----- From: Russell King <linux@armlinux.org.uk> Sent: 2021年9月2日 16:32 To: Joakim Zhang <redacted> Cc: Vladimir Oltean <olteanv@gmail.com>; peppe.cavallaro@st.com; alexandre.torgue@foss.st.com; joabreu@synopsys.com; davem@davemloft.net; kuba@kernel.org; mcoquelin.stm32@gmail.com; netdev@vger.kernel.org; andrew@lunn.ch; f.fainelli@gmail.com; hkallweit1@gmail.com; dl-linux-imx [off-list ref] Subject: Re: [PATCH] net: stmmac: fix MAC not working when system resume back with WoL enabled On Thu, Sep 02, 2021 at 07:28:44AM +0000, Joakim Zhang wrote:quoted
Hi Russell,quoted
-----Original Message----- From: Russell King <linux@armlinux.org.uk> Sent: 2021年9月1日 21:26 To: Joakim Zhang <redacted> Cc: Vladimir Oltean <olteanv@gmail.com>; peppe.cavallaro@st.com; alexandre.torgue@foss.st.com; joabreu@synopsys.com; davem@davemloft.net; kuba@kernel.org;mcoquelin.stm32@gmail.com;quoted
quoted
quoted
quoted
netdev@vger.kernel.org; andrew@lunn.ch; f.fainelli@gmail.com; hkallweit1@gmail.com; dl-linux-imx [off-list ref] Subject: Re: [PATCH] net: stmmac: fix MAC not working when system resume back with WoL enabled This means you need to have the phy <-> mac link up during suspend, and in that case, yes, you do not want to call phylink_stop() or phylink_start().I have a question here, why need to have the phy<->mac link up duringsuspend? You need the link up because I think from reading the code, it is _not_ the PHY that is triggering the wakeup in the configuration you areusing, but the MAC.quoted
quoted
If the link is down, the PHY can't pass the received packet to the MAC, and the MAC can't recognise the magic packet.Per my understanding, if use PHY-based wakeup, PHY should be active, and MAC can be totally suspended. When PHY receive the magic packets, it will generate a signal via wakeup PIN (PHY seems all have such PIN) toinform SoC, we can use this to wake up the system.quoted
Please correct me if I misunderstand.Correct.quoted
quoted
FEC doesn't have this. FEC relies purely on the PHY detecting the magic packet, which is much more power efficient, because it means the MAC doesn't need to be powered up and operational while the rest ofthe system is suspended.quoted
AFAIK, FEC also use the MAC-based wakeup, when enable FEC WoL feature, it will keep MAC receive logic active, PHY pass the received packets to MAC, if MAC detects the magic packets, it will generate an interrupt towake up the system. You're right. However, as the PHY is not configured for WoL with FEC, and fec_suspend() unconditionally calls phy_stop() which will place the PHY into suspend mode.
No, phylib has much logic to avoid putting PHY into suspended state if either MAC or PHY WoL active. Such as in phy_suspend(), if (wol.wolopts || (netdev && netdev->wol_enabled)) return -EBUSY; Or in mdio_bus_phy_may_suspend()...
Maybe the PHY driver there has a NULL phydrv->suspend method? However, I see that at803x has suspend methods (which I believe is the PHY that gets used with i.MX products) which will power down the PHY.
Yes, we have many boards use AR8031 PHY, and all support MAC-based wakeup feature.
So, how does this work with FEC - because right now I can't see it working, but you say it does. I think we need to understand how FEC is working here, and we need a deeper understanding why stmmac isn't working.
Emm, @andrew@lunn.ch, Andrew is much familiar with FEC, and PHY maintainers, Could you please help put insights here if possible?
I don't have any iMX systems that support WoL, so this isn't something I can test. (SolidRun's i.MX platforms do not support any kind of system power down, so suspend isn't supported.)
Understood, thanks. Best Regards, Joakim Zhang