diff mbox series

[net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL

Message ID 20210407104404.5781-1-qiangqing.zhang@nxp.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers warning 4 maintainers not CCed: mcoquelin.stm32@gmail.com linux-arm-kernel@lists.infradead.org linux-stm32@st-md-mailman.stormreply.com linux@armlinux.org.uk
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes fail Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Joakim Zhang April 7, 2021, 10:44 a.m. UTC
Both get and set WoL will check device_can_wakeup(), if MAC supports
PMT, it will set device wakeup capability. After commit 1d8e5b0f3f2c ("net:
stmmac: Support WOL with phy"), device wakeup capability will be
overwrite in stmmac_init_phy() according to phy's Wol feature. If phy
doesn't support WoL, then MAC will lose wakeup capability. To fix this
issue, only overwrite device wakeup capability when MAC doesn't support
PMT.

Fixes: commit 1d8e5b0f3f2c ("net: stmmac: Support WOL with phy")
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andrew Lunn April 7, 2021, 12:35 p.m. UTC | #1
On Wed, Apr 07, 2021 at 06:44:04PM +0800, Joakim Zhang wrote:
> Both get and set WoL will check device_can_wakeup(), if MAC supports
> PMT, it will set device wakeup capability. After commit 1d8e5b0f3f2c ("net:
> stmmac: Support WOL with phy"), device wakeup capability will be
> overwrite in stmmac_init_phy() according to phy's Wol feature. If phy
> doesn't support WoL, then MAC will lose wakeup capability. To fix this
> issue, only overwrite device wakeup capability when MAC doesn't support
> PMT.
> 
> Fixes: commit 1d8e5b0f3f2c ("net: stmmac: Support WOL with phy")
> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 208cae344ffa..f46d9c69168f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -1103,7 +1103,9 @@ static int stmmac_init_phy(struct net_device *dev)
>  	}
>  
>  	phylink_ethtool_get_wol(priv->phylink, &wol);
> -	device_set_wakeup_capable(priv->device, !!wol.supported);
> +
> +	if (!priv->plat->pmt)
> +		device_set_wakeup_capable(priv->device, !!wol.supported);
  
It seems like a better fix would be to call stmmac_get_wol(), That
should set wol taking into account both pmt and phy.  But i would also
say stmmac_get_wol() and stmmac_set_wol() are broken. They should
combine capabilities, not be either pmt or phy.

       Andrew
Joakim Zhang April 9, 2021, 8:19 a.m. UTC | #2
Hi Andrew,

> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: 2021年4月7日 20:35
> To: Joakim Zhang <qiangqing.zhang@nxp.com>
> Cc: peppe.cavallaro@st.com; alexandre.torgue@st.com;
> joabreu@synopsys.com; davem@davemloft.net; kuba@kernel.org;
> f.fainelli@gmail.com; netdev@vger.kernel.org; dl-linux-imx
> <linux-imx@nxp.com>; Jisheng.Zhang@synaptics.com
> Subject: Re: [PATCH net] net: stmmac: fix MAC WoL unwork if PHY doesn't
> support WoL
> 
> On Wed, Apr 07, 2021 at 06:44:04PM +0800, Joakim Zhang wrote:
> > Both get and set WoL will check device_can_wakeup(), if MAC supports
> > PMT, it will set device wakeup capability. After commit 1d8e5b0f3f2c ("net:
> > stmmac: Support WOL with phy"), device wakeup capability will be
> > overwrite in stmmac_init_phy() according to phy's Wol feature. If phy
> > doesn't support WoL, then MAC will lose wakeup capability. To fix this
> > issue, only overwrite device wakeup capability when MAC doesn't
> > support PMT.
> >
> > Fixes: commit 1d8e5b0f3f2c ("net: stmmac: Support WOL with phy")
> > Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> > ---
> >  drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > index 208cae344ffa..f46d9c69168f 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> > @@ -1103,7 +1103,9 @@ static int stmmac_init_phy(struct net_device
> *dev)
> >  	}
> >
> >  	phylink_ethtool_get_wol(priv->phylink, &wol);
> > -	device_set_wakeup_capable(priv->device, !!wol.supported);
> > +
> > +	if (!priv->plat->pmt)
> > +		device_set_wakeup_capable(priv->device, !!wol.supported);
> 
> It seems like a better fix would be to call stmmac_get_wol(), That should set
> wol taking into account both pmt and phy.  But i would also say
> stmmac_get_wol() and stmmac_set_wol() are broken. They should combine
> capabilities, not be either pmt or phy.

Yes, they should combine MAC and PHY WoL capabilities, rather than check pmt or phy. I will improve and repost it.

Best Regards,
Joakim Zhang
>        Andrew
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 208cae344ffa..f46d9c69168f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1103,7 +1103,9 @@  static int stmmac_init_phy(struct net_device *dev)
 	}
 
 	phylink_ethtool_get_wol(priv->phylink, &wol);
-	device_set_wakeup_capable(priv->device, !!wol.supported);
+
+	if (!priv->plat->pmt)
+		device_set_wakeup_capable(priv->device, !!wol.supported);
 
 	return ret;
 }