netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v1 1/2] net: phy: dp83tg720: wake up PHYs in managed mode
@ 2024-06-13 18:30 Oleksij Rempel
  2024-06-13 18:30 ` [PATCH net v1 2/2] net: phy: dp83tg720: get initial master/slave configuration Oleksij Rempel
  0 siblings, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2024-06-13 18:30 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, stable, kernel, linux-kernel, netdev

In case this PHY is bootstrapped for managed mode, we need to manually
wake it. Otherwise no link will be detected.

Cc: stable@vger.kernel.org
Fixes: cb80ee2f9bee1 ("net: phy: Add support for the DP83TG720S Ethernet PHY")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/dp83tg720.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/dp83tg720.c b/drivers/net/phy/dp83tg720.c
index 326c9770a6dcc..1186dfc70fb3c 100644
--- a/drivers/net/phy/dp83tg720.c
+++ b/drivers/net/phy/dp83tg720.c
@@ -17,6 +17,11 @@
 #define DP83TG720S_PHY_RESET			0x1f
 #define DP83TG720S_HW_RESET			BIT(15)
 
+#define DP83TG720S_LPS_CFG3			0x18c
+/* Power modes are documented as bit fields but used as values */
+/* Power Mode 0 is Normal mode */
+#define DP83TG720S_LPS_CFG3_PWR_MODE_0		BIT(0)
+
 #define DP83TG720S_RGMII_DELAY_CTRL		0x602
 /* In RGMII mode, Enable or disable the internal delay for RXD */
 #define DP83TG720S_RGMII_RX_CLK_SEL		BIT(1)
@@ -154,10 +159,17 @@ static int dp83tg720_config_init(struct phy_device *phydev)
 	 */
 	usleep_range(1000, 2000);
 
-	if (phy_interface_is_rgmii(phydev))
-		return dp83tg720_config_rgmii_delay(phydev);
+	if (phy_interface_is_rgmii(phydev)) {
+		ret = dp83tg720_config_rgmii_delay(phydev);
+		if (ret)
+			return ret;
+	}
 
-	return 0;
+	/* In case the PHY is bootstrapped in managed mode, we need to
+	 * wake it.
+	 */
+	return phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TG720S_LPS_CFG3,
+			     DP83TG720S_LPS_CFG3_PWR_MODE_0);
 }
 
 static struct phy_driver dp83tg720_driver[] = {
-- 
2.39.2


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

* [PATCH net v1 2/2] net: phy: dp83tg720: get initial master/slave configuration
  2024-06-13 18:30 [PATCH net v1 1/2] net: phy: dp83tg720: wake up PHYs in managed mode Oleksij Rempel
@ 2024-06-13 18:30 ` Oleksij Rempel
  2024-06-13 19:33   ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2024-06-13 18:30 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Oleksij Rempel, stable, kernel, linux-kernel, netdev

Get initial master/slave configuration, otherwise ethtool
wont be able to provide this information until link is
established. This makes troubleshooting harder, since wrong
role configuration would prevent the link start.

Fixes: cb80ee2f9bee1 ("net: phy: Add support for the DP83TG720S Ethernet PHY")
Cc: stable@vger.kernel.org
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/phy/dp83tg720.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/dp83tg720.c b/drivers/net/phy/dp83tg720.c
index 1186dfc70fb3c..84256827a03bf 100644
--- a/drivers/net/phy/dp83tg720.c
+++ b/drivers/net/phy/dp83tg720.c
@@ -168,8 +168,12 @@ static int dp83tg720_config_init(struct phy_device *phydev)
 	/* In case the PHY is bootstrapped in managed mode, we need to
 	 * wake it.
 	 */
-	return phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TG720S_LPS_CFG3,
-			     DP83TG720S_LPS_CFG3_PWR_MODE_0);
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, DP83TG720S_LPS_CFG3,
+			    DP83TG720S_LPS_CFG3_PWR_MODE_0);
+	if (ret)
+		return ret;
+
+	return genphy_c45_pma_baset1_read_master_slave(phydev);
 }
 
 static struct phy_driver dp83tg720_driver[] = {
-- 
2.39.2


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

* Re: [PATCH net v1 2/2] net: phy: dp83tg720: get initial master/slave configuration
  2024-06-13 18:30 ` [PATCH net v1 2/2] net: phy: dp83tg720: get initial master/slave configuration Oleksij Rempel
@ 2024-06-13 19:33   ` Andrew Lunn
  2024-06-14  5:21     ` Oleksij Rempel
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2024-06-13 19:33 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, stable, kernel, linux-kernel, netdev

On Thu, Jun 13, 2024 at 08:30:34PM +0200, Oleksij Rempel wrote:
> Get initial master/slave configuration, otherwise ethtool
> wont be able to provide this information until link is
> established. This makes troubleshooting harder, since wrong
> role configuration would prevent the link start.

I looked at how genphy_c45_read_status() works. If we have
phydev->autoneg == AUTONEG_ENABLE then genphy_c45_baset1_read_status()
is called which sets phydev->master_slave_get. If not AUTONEG_ENABLE
it calls genphy_c45_read_pma() which ends up calling
genphy_c45_pma_baset1_read_master_slave().

So it seems like the .read_status op should be setting master/slave
each time it is called, and not one time during .config_init.

What do you think?

    Andrew

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

* Re: [PATCH net v1 2/2] net: phy: dp83tg720: get initial master/slave configuration
  2024-06-13 19:33   ` Andrew Lunn
@ 2024-06-14  5:21     ` Oleksij Rempel
  2024-06-14  7:01       ` Oleksij Rempel
  0 siblings, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2024-06-14  5:21 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, stable, kernel, linux-kernel, netdev

On Thu, Jun 13, 2024 at 09:33:01PM +0200, Andrew Lunn wrote:
> On Thu, Jun 13, 2024 at 08:30:34PM +0200, Oleksij Rempel wrote:
> > Get initial master/slave configuration, otherwise ethtool
> > wont be able to provide this information until link is
> > established. This makes troubleshooting harder, since wrong
> > role configuration would prevent the link start.
> 
> I looked at how genphy_c45_read_status() works. If we have
> phydev->autoneg == AUTONEG_ENABLE then genphy_c45_baset1_read_status()
> is called which sets phydev->master_slave_get. If not AUTONEG_ENABLE
> it calls genphy_c45_read_pma() which ends up calling
> genphy_c45_pma_baset1_read_master_slave().
> 
> So it seems like the .read_status op should be setting master/slave
> each time it is called, and not one time during .config_init.
> 
> What do you think?

Yes, you are right. I verified it:
In case of this driver, .config_init will be executed every time no link
is detected over phy_init_hw() call. If link is detected
genphy_c45_pma_baset1_read_master_slave() is called directly.
It is not directly visible but read_master_slave() will be executed on
every  .read_status.

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

* Re: [PATCH net v1 2/2] net: phy: dp83tg720: get initial master/slave configuration
  2024-06-14  5:21     ` Oleksij Rempel
@ 2024-06-14  7:01       ` Oleksij Rempel
  0 siblings, 0 replies; 5+ messages in thread
From: Oleksij Rempel @ 2024-06-14  7:01 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, stable, kernel, linux-kernel, netdev

On Fri, Jun 14, 2024 at 07:21:15AM +0200, Oleksij Rempel wrote:
> On Thu, Jun 13, 2024 at 09:33:01PM +0200, Andrew Lunn wrote:
> > On Thu, Jun 13, 2024 at 08:30:34PM +0200, Oleksij Rempel wrote:
> > > Get initial master/slave configuration, otherwise ethtool
> > > wont be able to provide this information until link is
> > > established. This makes troubleshooting harder, since wrong
> > > role configuration would prevent the link start.
> > 
> > I looked at how genphy_c45_read_status() works. If we have
> > phydev->autoneg == AUTONEG_ENABLE then genphy_c45_baset1_read_status()
> > is called which sets phydev->master_slave_get. If not AUTONEG_ENABLE
> > it calls genphy_c45_read_pma() which ends up calling
> > genphy_c45_pma_baset1_read_master_slave().
> > 
> > So it seems like the .read_status op should be setting master/slave
> > each time it is called, and not one time during .config_init.
> > 
> > What do you think?
> 
> Yes, you are right. I verified it:
> In case of this driver, .config_init will be executed every time no link
> is detected over phy_init_hw() call. If link is detected
> genphy_c45_pma_baset1_read_master_slave() is called directly.
> It is not directly visible but read_master_slave() will be executed on
> every  .read_status.

Hm.. on other hand. Since the configuration state is readed only on
init and reset, we will see on user space side only default state not updated
after config_aneg().

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

end of thread, other threads:[~2024-06-14  7:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-13 18:30 [PATCH net v1 1/2] net: phy: dp83tg720: wake up PHYs in managed mode Oleksij Rempel
2024-06-13 18:30 ` [PATCH net v1 2/2] net: phy: dp83tg720: get initial master/slave configuration Oleksij Rempel
2024-06-13 19:33   ` Andrew Lunn
2024-06-14  5:21     ` Oleksij Rempel
2024-06-14  7:01       ` Oleksij Rempel

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