netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions
@ 2023-03-01  3:01 Li Yang
  2023-03-01  3:01 ` [PATCH RESEND v2 2/2] net: phy: at803x: remove set/get wol callbacks for AR8032 Li Yang
  2023-03-04  1:28 ` [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions Jakub Kicinski
  0 siblings, 2 replies; 5+ messages in thread
From: Li Yang @ 2023-03-01  3:01 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	Jakub Kicinski, David Bauer
  Cc: netdev, linux-kernel, Li Yang, Viorel Suman, Wei Fang

In 7beecaf7d507 ("net: phy: at803x: improve the WOL feature"), it seems
not correct to use a wol_en bit in a 1588 Control Register which is only
available on AR8031/AR8033(share the same phy_id) to determine if WoL is
enabled.  Change it back to use AT803X_INTR_ENABLE_WOL for determining
the WoL status which is applicable on all chips supporting wol. Also
update the at803x_set_wol() function to only update the 1588 register on
chips having it.  After this change, disabling wol at probe from
d7cd5e06c9dd ("net: phy: at803x: disable WOL at probe") is no longer
needed.  So that part is removed.

Fixes: 7beecaf7d507b ("net: phy: at803x: improve the WOL feature")
Signed-off-by: Li Yang <leoyang.li@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
Reviewed-by: Wei Fang <wei.fang@nxp.com>
---
 drivers/net/phy/at803x.c | 40 ++++++++++++++++------------------------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 22f4458274aa..2102279b3964 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -461,21 +461,25 @@ static int at803x_set_wol(struct phy_device *phydev,
 			phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i],
 				      mac[(i * 2) + 1] | (mac[(i * 2)] << 8));
 
-		/* Enable WOL function */
-		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL,
-				0, AT803X_WOL_EN);
-		if (ret)
-			return ret;
+		/* Enable WOL function for 1588 */
+		if (phydev->drv->phy_id == ATH8031_PHY_ID) {
+			ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL,
+					0, AT803X_WOL_EN);
+			if (ret)
+				return ret;
+		}
 		/* Enable WOL interrupt */
 		ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL);
 		if (ret)
 			return ret;
 	} else {
-		/* Disable WoL function */
-		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL,
-				AT803X_WOL_EN, 0);
-		if (ret)
-			return ret;
+		/* Disable WoL function for 1588 */
+		if (phydev->drv->phy_id == ATH8031_PHY_ID) {
+			ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL,
+					AT803X_WOL_EN, 0);
+			if (ret)
+				return ret;
+		}
 		/* Disable WOL interrupt */
 		ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0);
 		if (ret)
@@ -510,11 +514,8 @@ static void at803x_get_wol(struct phy_device *phydev,
 	wol->supported = WAKE_MAGIC;
 	wol->wolopts = 0;
 
-	value = phy_read_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL);
-	if (value < 0)
-		return;
-
-	if (value & AT803X_WOL_EN)
+	value = phy_read(phydev, AT803X_INTR_ENABLE);
+	if (value & AT803X_INTR_ENABLE_WOL)
 		wol->wolopts |= WAKE_MAGIC;
 }
 
@@ -866,9 +867,6 @@ static int at803x_probe(struct phy_device *phydev)
 	if (phydev->drv->phy_id == ATH8031_PHY_ID) {
 		int ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG);
 		int mode_cfg;
-		struct ethtool_wolinfo wol = {
-			.wolopts = 0,
-		};
 
 		if (ccr < 0) {
 			ret = ccr;
@@ -887,12 +885,6 @@ static int at803x_probe(struct phy_device *phydev)
 			break;
 		}
 
-		/* Disable WOL by default */
-		ret = at803x_set_wol(phydev, &wol);
-		if (ret < 0) {
-			phydev_err(phydev, "failed to disable WOL on probe: %d\n", ret);
-			goto err;
-		}
 	}
 
 	return 0;
-- 
2.38.0


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

* [PATCH RESEND v2 2/2] net: phy: at803x: remove set/get wol callbacks for AR8032
  2023-03-01  3:01 [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions Li Yang
@ 2023-03-01  3:01 ` Li Yang
  2023-03-04  1:28 ` [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions Jakub Kicinski
  1 sibling, 0 replies; 5+ messages in thread
From: Li Yang @ 2023-03-01  3:01 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	Jakub Kicinski, David Bauer
  Cc: netdev, linux-kernel, Li Yang

Since the AR8032 part does not support wol, remove related callbacks
from it.

Fixes: 5800091a2061 ("net: phy: at803x: add support for AR8032 PHY")
Signed-off-by: Li Yang <leoyang.li@nxp.com>
Cc: David Bauer <mail@david-bauer.net>
---
 drivers/net/phy/at803x.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index 2102279b3964..ac47a1d681b2 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -2079,8 +2079,6 @@ static struct phy_driver at803x_driver[] = {
 	.flags			= PHY_POLL_CABLE_TEST,
 	.config_init		= at803x_config_init,
 	.link_change_notify	= at803x_link_change_notify,
-	.set_wol		= at803x_set_wol,
-	.get_wol		= at803x_get_wol,
 	.suspend		= at803x_suspend,
 	.resume			= at803x_resume,
 	/* PHY_BASIC_FEATURES */
-- 
2.38.0


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

* Re: [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions
  2023-03-01  3:01 [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions Li Yang
  2023-03-01  3:01 ` [PATCH RESEND v2 2/2] net: phy: at803x: remove set/get wol callbacks for AR8032 Li Yang
@ 2023-03-04  1:28 ` Jakub Kicinski
  2023-03-22 19:55   ` Leo Li
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2023-03-04  1:28 UTC (permalink / raw)
  To: Li Yang
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	David Bauer, netdev, linux-kernel, Viorel Suman, Wei Fang

On Tue, 28 Feb 2023 21:01:25 -0600 Li Yang wrote:
> In 7beecaf7d507 ("net: phy: at803x: improve the WOL feature"), it seems
> not correct to use a wol_en bit in a 1588 Control Register which is only
> available on AR8031/AR8033(share the same phy_id) to determine if WoL is
> enabled.  Change it back to use AT803X_INTR_ENABLE_WOL for determining
> the WoL status which is applicable on all chips supporting wol. Also
> update the at803x_set_wol() function to only update the 1588 register on
> chips having it.  After this change, disabling wol at probe from
> d7cd5e06c9dd ("net: phy: at803x: disable WOL at probe") is no longer
> needed.  So that part is removed.
> 
> Fixes: 7beecaf7d507b ("net: phy: at803x: improve the WOL feature")

Given the fixes tag Luo Jie <luoj@codeaurora.org> should be CCed.

> Signed-off-by: Li Yang <leoyang.li@nxp.com>
> Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
> Reviewed-by: Wei Fang <wei.fang@nxp.com>
> ---
>  drivers/net/phy/at803x.c | 40 ++++++++++++++++------------------------
>  1 file changed, 16 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index 22f4458274aa..2102279b3964 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -461,21 +461,25 @@ static int at803x_set_wol(struct phy_device *phydev,
>  			phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i],
>  				      mac[(i * 2) + 1] | (mac[(i * 2)] << 8));
>  
> -		/* Enable WOL function */
> -		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL,
> -				0, AT803X_WOL_EN);
> -		if (ret)
> -			return ret;
> +		/* Enable WOL function for 1588 */
> +		if (phydev->drv->phy_id == ATH8031_PHY_ID) {
> +			ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL,

This line is now too long, unless there is a good reason please stick
to the 80 char maximum.

> +					0, AT803X_WOL_EN);

while at it please fix the alignment, the continuation line should start
under phydev (checkpatch will tell you)

> +			if (ret)
> +				return ret;
> +		}
>  		/* Enable WOL interrupt */
>  		ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL);
>  		if (ret)
>  			return ret;
>  	} else {
> -		/* Disable WoL function */
> -		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL,
> -				AT803X_WOL_EN, 0);
> -		if (ret)
> -			return ret;
> +		/* Disable WoL function for 1588 */
> +		if (phydev->drv->phy_id == ATH8031_PHY_ID) {
> +			ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL,
> +					AT803X_WOL_EN, 0);

same comments as above

> +			if (ret)
> +				return ret;
> +		}
>  		/* Disable WOL interrupt */
>  		ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0);
>  		if (ret)
> @@ -510,11 +514,8 @@ static void at803x_get_wol(struct phy_device *phydev,
>  	wol->supported = WAKE_MAGIC;
>  	wol->wolopts = 0;
>  
> -	value = phy_read_mmd(phydev, MDIO_MMD_PCS, AT803X_PHY_MMD3_WOL_CTRL);
> -	if (value < 0)
> -		return;
> -
> -	if (value & AT803X_WOL_EN)
> +	value = phy_read(phydev, AT803X_INTR_ENABLE);

Does phy_read() never fail? Why remove the error checking?

> +	if (value & AT803X_INTR_ENABLE_WOL)
>  		wol->wolopts |= WAKE_MAGIC;
>  }
>  


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

* RE: [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions
  2023-03-04  1:28 ` [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions Jakub Kicinski
@ 2023-03-22 19:55   ` Leo Li
  2023-03-22 20:15     ` Jakub Kicinski
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Li @ 2023-03-22 19:55 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	David Bauer, netdev, linux-kernel, Viorel Suman, Wei Fang



> -----Original Message-----
> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Friday, March 3, 2023 7:29 PM
> To: Leo Li <leoyang.li@nxp.com>
> Cc: Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit
> <hkallweit1@gmail.com>; Russell King <linux@armlinux.org.uk>; David S .
> Miller <davem@davemloft.net>; David Bauer <mail@david-bauer.net>;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Viorel Suman
> <viorel.suman@nxp.com>; Wei Fang <wei.fang@nxp.com>
> Subject: Re: [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting
> functions
> 
> On Tue, 28 Feb 2023 21:01:25 -0600 Li Yang wrote:
> > In 7beecaf7d507 ("net: phy: at803x: improve the WOL feature"), it
> > seems not correct to use a wol_en bit in a 1588 Control Register which
> > is only available on AR8031/AR8033(share the same phy_id) to determine
> > if WoL is enabled.  Change it back to use AT803X_INTR_ENABLE_WOL for
> > determining the WoL status which is applicable on all chips supporting
> > wol. Also update the at803x_set_wol() function to only update the 1588
> > register on chips having it.  After this change, disabling wol at
> > probe from d7cd5e06c9dd ("net: phy: at803x: disable WOL at probe") is
> > no longer needed.  So that part is removed.
> >
> > Fixes: 7beecaf7d507b ("net: phy: at803x: improve the WOL feature")
> 
> Given the fixes tag Luo Jie <luoj@codeaurora.org> should be CCed.

Sorry for the late response, I missed this email.  I tried to cc him, but the email bounced.

> 
> > Signed-off-by: Li Yang <leoyang.li@nxp.com>
> > Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
> > Reviewed-by: Wei Fang <wei.fang@nxp.com>
> > ---
> >  drivers/net/phy/at803x.c | 40
> > ++++++++++++++++------------------------
> >  1 file changed, 16 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index
> > 22f4458274aa..2102279b3964 100644
> > --- a/drivers/net/phy/at803x.c
> > +++ b/drivers/net/phy/at803x.c
> > @@ -461,21 +461,25 @@ static int at803x_set_wol(struct phy_device
> *phydev,
> >  			phy_write_mmd(phydev, MDIO_MMD_PCS,
> offsets[i],
> >  				      mac[(i * 2) + 1] | (mac[(i * 2)] << 8));
> >
> > -		/* Enable WOL function */
> > -		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
> AT803X_PHY_MMD3_WOL_CTRL,
> > -				0, AT803X_WOL_EN);
> > -		if (ret)
> > -			return ret;
> > +		/* Enable WOL function for 1588 */
> > +		if (phydev->drv->phy_id == ATH8031_PHY_ID) {
> > +			ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
> > +AT803X_PHY_MMD3_WOL_CTRL,
> 
> This line is now too long, unless there is a good reason please stick to the 80
> char maximum.
> 
> > +					0, AT803X_WOL_EN);
> 
> while at it please fix the alignment, the continuation line should start under
> phydev (checkpatch will tell you)
> 
> > +			if (ret)
> > +				return ret;
> > +		}
> >  		/* Enable WOL interrupt */
> >  		ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0,
> AT803X_INTR_ENABLE_WOL);
> >  		if (ret)
> >  			return ret;
> >  	} else {
> > -		/* Disable WoL function */
> > -		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
> AT803X_PHY_MMD3_WOL_CTRL,
> > -				AT803X_WOL_EN, 0);
> > -		if (ret)
> > -			return ret;
> > +		/* Disable WoL function for 1588 */
> > +		if (phydev->drv->phy_id == ATH8031_PHY_ID) {
> > +			ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
> AT803X_PHY_MMD3_WOL_CTRL,
> > +					AT803X_WOL_EN, 0);
> 
> same comments as above
> 
> > +			if (ret)
> > +				return ret;
> > +		}
> >  		/* Disable WOL interrupt */
> >  		ret = phy_modify(phydev, AT803X_INTR_ENABLE,
> AT803X_INTR_ENABLE_WOL, 0);
> >  		if (ret)
> > @@ -510,11 +514,8 @@ static void at803x_get_wol(struct phy_device
> *phydev,
> >  	wol->supported = WAKE_MAGIC;
> >  	wol->wolopts = 0;
> >
> > -	value = phy_read_mmd(phydev, MDIO_MMD_PCS,
> AT803X_PHY_MMD3_WOL_CTRL);
> > -	if (value < 0)
> > -		return;
> > -
> > -	if (value & AT803X_WOL_EN)
> > +	value = phy_read(phydev, AT803X_INTR_ENABLE);
> 
> Does phy_read() never fail? Why remove the error checking?
> 
> > +	if (value & AT803X_INTR_ENABLE_WOL)
> >  		wol->wolopts |= WAKE_MAGIC;
> >  }
> >


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

* Re: [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions
  2023-03-22 19:55   ` Leo Li
@ 2023-03-22 20:15     ` Jakub Kicinski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2023-03-22 20:15 UTC (permalink / raw)
  To: Leo Li
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	David Bauer, netdev, linux-kernel, Viorel Suman, Wei Fang

On Wed, 22 Mar 2023 19:55:56 +0000 Leo Li wrote:
> > Given the fixes tag Luo Jie <luoj@codeaurora.org> should be CCed.  
> 
> Sorry for the late response, I missed this email.  I tried to cc him,
> but the email bounced.

I see, let me add them to the ignored addresses list.

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

end of thread, other threads:[~2023-03-22 20:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-01  3:01 [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions Li Yang
2023-03-01  3:01 ` [PATCH RESEND v2 2/2] net: phy: at803x: remove set/get wol callbacks for AR8032 Li Yang
2023-03-04  1:28 ` [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions Jakub Kicinski
2023-03-22 19:55   ` Leo Li
2023-03-22 20:15     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).