Subject: Re: [PATCH] net: stmmac: fix MAC not working when system resume back with WoL enabled

From: "Russell King (Oracle)" <[email-masked]>
Date: Thu, 2 Sep 2021 11:49:43 +0100

On Thu, Sep 02, 2021 at 10:26:13AM +0000, Joakim Zhang wrote:
> 
> Hi Russell,
> 
> Thanks a lot!
> 
> > -----Original Message-----
> > From: Russell King <[email-masked]>
> > Sent: 2021年9月2日 16:32
> > To: Joakim Zhang <[email-masked]>
> > Cc: Vladimir Oltean <[email-masked]>; [email-masked];
> > [email-masked]; [email-masked];
> > [email-masked]; [email-masked]; [email-masked];
> > [email-masked]; [email-masked]; [email-masked];
> > [email-masked]; dl-linux-imx <[email-masked]>
> > 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:
> > >
> > > Hi Russell,
> > >
> > > > -----Original Message-----
> > > > From: Russell King <[email-masked]>
> > > > Sent: 2021年9月1日 21:26
> > > > To: Joakim Zhang <[email-masked]>
> > > > Cc: Vladimir Oltean <[email-masked]>; [email-masked];
> > > > [email-masked]; [email-masked];
> > > > [email-masked]; [email-masked]; [email-masked];
> > > > [email-masked]; [email-masked]; [email-masked];
> > > > [email-masked]; dl-linux-imx <[email-masked]>
> > > > 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 during
> > suspend?
> > 
> > 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 are using, but the MAC.
> > 
> > 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) to inform SoC, we can use this to wake up the system.
> Please correct me if I misunderstand.

Correct.

> > 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 of the system is suspended.
> 
> 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 to wake 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. 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.

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.

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.)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!