Skip to contentSkip to conversation

net: phy: smaller phylib improvements

PATCH In review Heiner Kallweit 2 participants 5 messages Apr 23, 2020 – Apr 24, 2020

Subsystems (4)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

cover net: phy: smaller phylib improvements

Series with smaller improvements for suspend and soft-reset handling.

Heiner Kallweit (3):
net: phy: make phy_suspend a no-op if PHY is suspended already
net: phy: remove genphy_no_soft_reset
net: phy: reset phydev->suspended if soft reset is triggered in
power-down state

 drivers/net/phy/cortina.c    |  1 -
 drivers/net/phy/marvell10g.c |  2 --
 drivers/net/phy/phy-c45.c    |  1 -
 drivers/net/phy/phy_device.c | 16 ++++++++++++++--
 drivers/net/phy/teranetics.c |  1 -
 include/linux/phy.h          |  4 ----
 6 files changed, 14 insertions(+), 11 deletions(-)
Signature · 1 line
2.26.2
author maintainer
#1 lore raw

PATCH 1/3 net: phy: make phy_suspend a no-op if PHY is suspended already

Gently handle the case that phy_suspend() is called whilst PHY is in power-down.

---
 drivers/net/phy/phy_device.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/phy/phy_device.c +3 -0
index ac2784192..206d98502 100644
@@ -1524,6 +1524,9 @@ int phy_suspend(struct phy_device *phydev)
 	struct phy_driver *phydrv = phydev->drv;
 	int ret;
 
+	if (phydev->suspended)
+		return 0;
+
 	/* If the device has WOL enabled, we cannot suspend the PHY */
 	phy_ethtool_get_wol(phydev, &wol);
 	if (wol.wolopts || (netdev && netdev->wol_enabled))
Signature · 1 line
2.26.2
author maintainer
#2 lore raw

PATCH 2/3 net: phy: remove genphy_no_soft_reset

In reply to Heiner Kallweit

Since 6e2d85ec0559 ("net: phy: Stop with excessive soft reset") we don't need genphy_no_soft_reset() any longer. Not setting callback soft_reset results in a no-op now.

---
 drivers/net/phy/cortina.c    | 1 -
 drivers/net/phy/marvell10g.c | 2 --
 drivers/net/phy/phy-c45.c    | 1 -
 drivers/net/phy/phy_device.c | 1 -
 drivers/net/phy/teranetics.c | 1 -
 include/linux/phy.h          | 4 ----
 6 files changed, 10 deletions(-)
drivers/net/phy/cortina.c +0 -1
index 856cdc36a..aac51362c 100644
@@ -82,7 +82,6 @@ static struct phy_driver cortina_driver[] = {
 	.features       = PHY_10GBIT_FEATURES,
 	.config_aneg	= gen10g_config_aneg,
 	.read_status	= cortina_read_status,
-	.soft_reset	= genphy_no_soft_reset,
 	.probe		= cortina_probe,
 },
 };
drivers/net/phy/marvell10g.c +0 -2
index 95e3f4644..80cbc77ff 100644
@@ -727,7 +727,6 @@ static struct phy_driver mv3310_drivers[] = {
 		.phy_id_mask	= MARVELL_PHY_ID_MASK,
 		.name		= "mv88x3310",
 		.get_features	= mv3310_get_features,
-		.soft_reset	= genphy_no_soft_reset,
 		.config_init	= mv3310_config_init,
 		.probe		= mv3310_probe,
 		.suspend	= mv3310_suspend,
@@ -745,7 +744,6 @@ static struct phy_driver mv3310_drivers[] = {
 		.probe		= mv3310_probe,
 		.suspend	= mv3310_suspend,
 		.resume		= mv3310_resume,
-		.soft_reset	= genphy_no_soft_reset,
 		.config_init	= mv3310_config_init,
 		.config_aneg	= mv3310_config_aneg,
 		.aneg_done	= mv3310_aneg_done,
drivers/net/phy/phy-c45.c +0 -1
index 67ba47ae5..defe09d94 100644
@@ -564,6 +564,5 @@ struct phy_driver genphy_c45_driver = {
 	.phy_id         = 0xffffffff,
 	.phy_id_mask    = 0xffffffff,
 	.name           = "Generic Clause 45 PHY",
-	.soft_reset	= genphy_no_soft_reset,
 	.read_status    = genphy_c45_read_status,
 };
drivers/net/phy/phy_device.c +0 -1
index 206d98502..c8f8fd990 100644
@@ -2630,7 +2630,6 @@ static struct phy_driver genphy_driver = {
 	.phy_id		= 0xffffffff,
 	.phy_id_mask	= 0xffffffff,
 	.name		= "Generic PHY",
-	.soft_reset	= genphy_no_soft_reset,
 	.get_features	= genphy_read_abilities,
 	.suspend	= genphy_suspend,
 	.resume		= genphy_resume,
drivers/net/phy/teranetics.c +0 -1
index beb054b93..8057ea8db 100644
@@ -78,7 +78,6 @@ static struct phy_driver teranetics_driver[] = {
 	.phy_id_mask	= 0xffffffff,
 	.name		= "Teranetics TN2020",
 	.features       = PHY_10GBIT_FEATURES,
-	.soft_reset	= genphy_no_soft_reset,
 	.aneg_done	= teranetics_aneg_done,
 	.config_aneg    = gen10g_config_aneg,
 	.read_status	= teranetics_read_status,
include/linux/phy.h +0 -4
index 3941a6bcb..e2bfb9240 100644
@@ -1251,10 +1251,6 @@ static inline int genphy_config_aneg(struct phy_device *phydev)
 	return __genphy_config_aneg(phydev, false);
 }
 
-static inline int genphy_no_soft_reset(struct phy_device *phydev)
-{
-	return 0;
-}
 static inline int genphy_no_ack_interrupt(struct phy_device *phydev)
 {
 	return 0;
Signature · 1 line
2.26.2
author maintainer
#3 lore raw

PATCH 3/3 net: phy: clear phydev->suspended after soft reset

In reply to Heiner Kallweit

If a soft reset is triggered whilst PHY is in power-down, then phydev->suspended will remain set. Seems we didn't face any issue yet caused by this, but better reset the suspended flag after soft reset.

See also the following from 22.2.4.1.1
Resetting a PHY is accomplished by setting bit 0.15 to a logic one. This action shall set the status and control registers to their default states.

---
 drivers/net/phy/phy_device.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/net/phy/phy_device.c +11 -1
index c8f8fd990..7e1ddd574 100644
@@ -1082,8 +1082,12 @@ int phy_init_hw(struct phy_device *phydev)
 	if (!phydev->drv)
 		return 0;
 
-	if (phydev->drv->soft_reset)
+	if (phydev->drv->soft_reset) {
 		ret = phydev->drv->soft_reset(phydev);
+		/* see comment in genphy_soft_reset for an explanation */
+		if (!ret)
+			phydev->suspended = 0;
+	}
 
 	if (ret < 0)
 		return ret;
@@ -2157,6 +2161,12 @@ int genphy_soft_reset(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
+	/* Clause 22 states that setting bit BMCR_RESET sets control registers
+	 * to their default value. Therefore the POWER DOWN bit is supposed to
+	 * be cleared after soft reset.
+	 */
+	phydev->suspended = 0;
+
 	ret = phy_poll_reset(phydev);
 	if (ret)
 		return ret;
Signature · 1 line
2.26.2