Skip to contentSkip to conversation

net: phy: at803x: fix the wol setting functions

PATCH RESEND Superseded Li Yang 2 participants 5 messages Mar 1, 2023 – Mar 22, 2023

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Li Yang

author
#0 lore raw

PATCH RESEND v2 1/2 net: phy: at803x: fix the wol setting functions

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")
---
 drivers/net/phy/at803x.c | 40 ++++++++++++++++------------------------
 1 file changed, 16 insertions(+), 24 deletions(-)
drivers/net/phy/at803x.c +16 -24
index 22f4458274aa..2102279b3964 100644
@@ -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;
Signature · 1 line
2.38.0
author
#1 lore raw

PATCH RESEND v2 2/2 net: phy: at803x: remove set/get wol callbacks for AR8032

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

Fixes 5800091a2061 ("net: phy: at803x: add support for AR8032 PHY")
Cc David Bauer <[email protected]>
---
 drivers/net/phy/at803x.c | 2 --
 1 file changed, 2 deletions(-)
drivers/net/phy/at803x.c +0 -2
index 2102279b3964..ac47a1d681b2 100644
@@ -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 */
Signature · 1 line
2.38.0
maintainer
#2 lore raw
In reply to Li Yang
Quoted 11 lines · 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 <[email protected]> should be CCed.

Quoted 13 lines
---
 drivers/net/phy/at803x.c | 40 ++++++++++++++++------------------------
 1 file changed, 16 insertions(+), 24 deletions(-)
drivers/net/phy/at803x.c +0 -0
index 22f4458274aa..2102279b3964 100644
@@ -461,21 +461,25 @@ static int at803x_set_wol(struct phy_device *phydev,
 			phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i],

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev, · line 466

Quoted 10 lines
drivers/net/phy/at803x.c +3 -5
 				      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.

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev, · line 467

Quoted 1 line
drivers/net/phy/at803x.c +1 -0
+					0, AT803X_WOL_EN);

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

Quoted 7 lines
drivers/net/phy/at803x.c +3 -0
+			if (ret)
+				return ret;
+		}
 		/* Enable WOL interrupt */
 		ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL);
 		if (ret)
 			return ret;

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev, · line 479

Quoted 10 lines
drivers/net/phy/at803x.c +4 -5
 	} 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

Quoted 7 lines
drivers/net/phy/at803x.c +3 -0
+			if (ret)
+				return ret;
+		}
 		/* Disable WOL interrupt */
 		ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0);
 		if (ret)

drivers/net/phy/at803x.c static void at803x_get_wol(struct phy_device *phydev, · line 517

Quoted 9 lines
drivers/net/phy/at803x.c +1 -5
@@ -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?

Quoted 4 lines
drivers/net/phy/at803x.c +1 -0
+	if (value & AT803X_INTR_ENABLE_WOL)
 		wol->wolopts |= WAKE_MAGIC;
 }
 
author
#3 lore raw
Quoted 25 lines

-----Original Message-----
From: Jakub Kicinski <[email protected]>
Sent: Friday, March 3, 2023 7:29 PM
To: Leo Li <[email protected]>
Cc: Andrew Lunn <[email protected]>; Heiner Kallweit <[email protected]>; Russell King <[email protected]>; David S . Miller <[email protected]>; David Bauer <[email protected]>; [email protected]; [email protected]; Viorel Suman <[email protected]>; Wei Fang <[email protected]>
Subject: Re: [PATCH RESEND v2 1/2] net: phy: at803x: fix the wol setting functions

Quoted 10 lines · 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.

Quoted 3 lines
Quoted 1 line
Fixes 7beecaf7d507b ("net: phy: at803x: improve the WOL feature")

Given the fixes tag Luo Jie <[email protected]> should be CCed.

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

Quoted 87 lines

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device

Quoted 14 lines
---
 drivers/net/phy/at803x.c | 40
++++++++++++++++------------------------
 1 file changed, 16 insertions(+), 24 deletions(-)
drivers/net/phy/at803x.c index renamed from drivers/net/phy/at803x.c +0 -0

22f4458274aa..2102279b3964 100644

drivers/net/phy/at803x.c +0 -0
@@ -461,21 +461,25 @@ static int at803x_set_wol(struct phy_device

*phydev,

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device · line 461

Quoted 1 line
drivers/net/phy/at803x.c +0 -0
 			phy_write_mmd(phydev, MDIO_MMD_PCS,

offsets[i],

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev,

Quoted 4 lines
drivers/net/phy/at803x.c +0 -2
 				      mac[(i * 2) + 1] | (mac[(i * 2)] << 8));
 
-		/* Enable WOL function */
-		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,

AT803X_PHY_MMD3_WOL_CTRL,

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev,

Quoted 7 lines
drivers/net/phy/at803x.c +4 -3
-				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.

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev, · line 467

Quoted 1 line
drivers/net/phy/at803x.c +1 -0
+					0, AT803X_WOL_EN);

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

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev,

Quoted 5 lines
drivers/net/phy/at803x.c +3 -0
+			if (ret)
+				return ret;
+		}
 		/* Enable WOL interrupt */
 		ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0,

AT803X_INTR_ENABLE_WOL);

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev,

Quoted 5 lines
drivers/net/phy/at803x.c +0 -2
 		if (ret)
 			return ret;
 	} else {
-		/* Disable WoL function */
-		ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,

AT803X_PHY_MMD3_WOL_CTRL,

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev,

Quoted 6 lines
drivers/net/phy/at803x.c +3 -3
-				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,

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev, · line 479

Quoted 1 line
drivers/net/phy/at803x.c +1 -0
+					AT803X_WOL_EN, 0);

same comments as above

drivers/net/phy/at803x.c static int at803x_set_wol(struct phy_device *phydev,

Quoted 5 lines
drivers/net/phy/at803x.c +3 -0
+			if (ret)
+				return ret;
+		}
 		/* Disable WOL interrupt */
 		ret = phy_modify(phydev, AT803X_INTR_ENABLE,

AT803X_INTR_ENABLE_WOL, 0);

drivers/net/phy/at803x.c static void at803x_get_wol(struct phy_device

Quoted 2 lines
drivers/net/phy/at803x.c +0 -0
 		if (ret)
@@ -510,11 +514,8 @@ static void at803x_get_wol(struct phy_device

*phydev,

drivers/net/phy/at803x.c static void at803x_get_wol(struct phy_device *phydev,

Quoted 4 lines
drivers/net/phy/at803x.c +0 -1
 	wol->supported = WAKE_MAGIC;
 	wol->wolopts = 0;
 
-	value = phy_read_mmd(phydev, MDIO_MMD_PCS,

AT803X_PHY_MMD3_WOL_CTRL);

drivers/net/phy/at803x.c static void at803x_get_wol(struct phy_device *phydev, · line 517

Quoted 5 lines
drivers/net/phy/at803x.c +1 -4
-	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?

Quoted 4 lines
drivers/net/phy/at803x.c +1 -0
+	if (value & AT803X_INTR_ENABLE_WOL)
 		wol->wolopts |= WAKE_MAGIC;
 }
 
maintainer
#4 lore raw
Quoted 4 lines · On Wed, 22 Mar 2023 19:55:56 +0000 Leo Li wrote:
Quoted 1 line

Given the fixes tag Luo Jie <[email protected]> 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.