All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL
@ 2021-04-07 10:44 Joakim Zhang
  2021-04-07 12:35 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Joakim Zhang @ 2021-04-07 10:44 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	f.fainelli, andrew
  Cc: netdev, linux-imx, Jisheng.Zhang

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);
 
 	return ret;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL
  2021-04-07 10:44 [PATCH net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL Joakim Zhang
@ 2021-04-07 12:35 ` Andrew Lunn
  2021-04-09  8:19   ` Joakim Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2021-04-07 12:35 UTC (permalink / raw)
  To: Joakim Zhang
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	f.fainelli, netdev, linux-imx, Jisheng.Zhang

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL
  2021-04-07 12:35 ` Andrew Lunn
@ 2021-04-09  8:19   ` Joakim Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Joakim Zhang @ 2021-04-09  8:19 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	f.fainelli, netdev, dl-linux-imx, Jisheng.Zhang


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-09  8:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-07 10:44 [PATCH net] net: stmmac: fix MAC WoL unwork if PHY doesn't support WoL Joakim Zhang
2021-04-07 12:35 ` Andrew Lunn
2021-04-09  8:19   ` Joakim Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.