diff mbox series

[net,v1,2/2] net: phy: dp83tg720: get initial master/slave configuration

Message ID 20240613183034.2407798-2-o.rempel@pengutronix.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net,v1,1/2] net: phy: dp83tg720: wake up PHYs in managed mode | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 864 this patch: 864
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 868 this patch: 868
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 868 this patch: 868
netdev/checkpatch warning WARNING: 'wont' may be misspelled - perhaps 'won't'? WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: cb80ee2f9bee ("net: phy: Add support for the DP83TG720S Ethernet PHY")'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-14--06-00 (tests: 647)

Commit Message

Oleksij Rempel June 13, 2024, 6:30 p.m. UTC
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(-)

Comments

Andrew Lunn June 13, 2024, 7:33 p.m. UTC | #1
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
Oleksij Rempel June 14, 2024, 5:21 a.m. UTC | #2
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.
Oleksij Rempel June 14, 2024, 7:01 a.m. UTC | #3
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().
diff mbox series

Patch

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[] = {