netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: phy: smaller phylib improvements
@ 2020-04-23 19:33 Heiner Kallweit
  2020-04-23 19:34 ` [PATCH net-next 1/3] net: phy: make phy_suspend a no-op if PHY is suspended already Heiner Kallweit
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Heiner Kallweit @ 2020-04-23 19:33 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Russell King - ARM Linux,
	David Miller
  Cc: netdev@vger.kernel.org

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(-)

-- 
2.26.2


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

* [PATCH net-next 1/3] net: phy: make phy_suspend a no-op if PHY is suspended already
  2020-04-23 19:33 [PATCH net-next 0/3] net: phy: smaller phylib improvements Heiner Kallweit
@ 2020-04-23 19:34 ` Heiner Kallweit
  2020-04-23 19:35 ` [PATCH net-next 2/3] net: phy: remove genphy_no_soft_reset Heiner Kallweit
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2020-04-23 19:34 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Russell King - ARM Linux,
	David Miller
  Cc: netdev@vger.kernel.org

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

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy_device.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index ac2784192..206d98502 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -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))
-- 
2.26.2



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

* [PATCH net-next 2/3] net: phy: remove genphy_no_soft_reset
  2020-04-23 19:33 [PATCH net-next 0/3] net: phy: smaller phylib improvements Heiner Kallweit
  2020-04-23 19:34 ` [PATCH net-next 1/3] net: phy: make phy_suspend a no-op if PHY is suspended already Heiner Kallweit
@ 2020-04-23 19:35 ` Heiner Kallweit
  2020-04-23 19:38 ` [PATCH net-next 3/3] net: phy: clear phydev->suspended after soft reset Heiner Kallweit
  2020-04-24 23:48 ` [PATCH net-next 0/3] net: phy: smaller phylib improvements David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2020-04-23 19:35 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Russell King - ARM Linux,
	David Miller
  Cc: netdev@vger.kernel.org

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.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 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(-)

diff --git a/drivers/net/phy/cortina.c b/drivers/net/phy/cortina.c
index 856cdc36a..aac51362c 100644
--- a/drivers/net/phy/cortina.c
+++ b/drivers/net/phy/cortina.c
@@ -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,
 },
 };
diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 95e3f4644..80cbc77ff 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -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,
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index 67ba47ae5..defe09d94 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -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,
 };
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 206d98502..c8f8fd990 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -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,
diff --git a/drivers/net/phy/teranetics.c b/drivers/net/phy/teranetics.c
index beb054b93..8057ea8db 100644
--- a/drivers/net/phy/teranetics.c
+++ b/drivers/net/phy/teranetics.c
@@ -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,
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 3941a6bcb..e2bfb9240 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -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;
-- 
2.26.2



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

* [PATCH net-next 3/3] net: phy: clear phydev->suspended after soft reset
  2020-04-23 19:33 [PATCH net-next 0/3] net: phy: smaller phylib improvements Heiner Kallweit
  2020-04-23 19:34 ` [PATCH net-next 1/3] net: phy: make phy_suspend a no-op if PHY is suspended already Heiner Kallweit
  2020-04-23 19:35 ` [PATCH net-next 2/3] net: phy: remove genphy_no_soft_reset Heiner Kallweit
@ 2020-04-23 19:38 ` Heiner Kallweit
  2020-04-24 23:48 ` [PATCH net-next 0/3] net: phy: smaller phylib improvements David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2020-04-23 19:38 UTC (permalink / raw)
  To: Andrew Lunn, Florian Fainelli, Russell King - ARM Linux,
	David Miller
  Cc: netdev@vger.kernel.org

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.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/phy_device.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c8f8fd990..7e1ddd574 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -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;
-- 
2.26.2



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

* Re: [PATCH net-next 0/3] net: phy: smaller phylib improvements
  2020-04-23 19:33 [PATCH net-next 0/3] net: phy: smaller phylib improvements Heiner Kallweit
                   ` (2 preceding siblings ...)
  2020-04-23 19:38 ` [PATCH net-next 3/3] net: phy: clear phydev->suspended after soft reset Heiner Kallweit
@ 2020-04-24 23:48 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2020-04-24 23:48 UTC (permalink / raw)
  To: hkallweit1; +Cc: andrew, f.fainelli, linux, netdev

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Thu, 23 Apr 2020 21:33:52 +0200

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

Series applied, thanks Heiner.

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

end of thread, other threads:[~2020-04-24 23:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-23 19:33 [PATCH net-next 0/3] net: phy: smaller phylib improvements Heiner Kallweit
2020-04-23 19:34 ` [PATCH net-next 1/3] net: phy: make phy_suspend a no-op if PHY is suspended already Heiner Kallweit
2020-04-23 19:35 ` [PATCH net-next 2/3] net: phy: remove genphy_no_soft_reset Heiner Kallweit
2020-04-23 19:38 ` [PATCH net-next 3/3] net: phy: clear phydev->suspended after soft reset Heiner Kallweit
2020-04-24 23:48 ` [PATCH net-next 0/3] net: phy: smaller phylib improvements David Miller

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).