Skip to contentSkip to conversation

Minor fixes for pcs_get_state() implementations

PATCH Applied Russell King (Oracle) 4 participants 8 messages Mar 15, 2023 – Mar 17, 2023

Subsystems (5)
lore
Share & tools
lore

Russell King (Oracle)

author reviewer
#0 lore raw

cover Minor fixes for pcs_get_state() implementations

Hi,

This series contains a number fixes for minor issues with some pcs_get_state() implementations, particualrly for the phylink state->an_enabled member. As they are minor, I'm suggesting we queue them in net-next as there is follow-on work for these, and there is no urgency for them to be in -rc.

Just like phylib, state->advertising's Autoneg bit is a copy of state->an_enabled, and thus it is my intention to remove state->an_enabled from phylink to simplify things.

This series gets rid of state->an_enabled assignments or reporting that should never have been there.

 drivers/net/pcs/pcs-lynx.c |  4 ++--
 drivers/net/pcs/pcs-xpcs.c | 13 ++-----------
 2 files changed, 4 insertions(+), 13 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#1 lore raw

PATCH 1/2 net: pcs: xpcs: remove double-read of link state when using AN

Phylink does not want the current state of the link when reading the PCS link state - it wants the latched state. Don't double-read the MII status register. Phylink will re-read as necessary to capture transient link-down events as of dbae3388ea9c ("net: phylink: Force retrigger in case of latched link-fail indicator").

The above referenced commit is a dependency for this change, and thus this change should not be backported to any kernel that does not contain the above referenced commit.

Fixes fcb26bd2b6ca ("net: phy: Add Synopsys DesignWare XPCS MDIO module")
---
 drivers/net/pcs/pcs-xpcs.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/pcs/pcs-xpcs.c +2 -11
index bc428a816719..04a685353041 100644
@@ -321,7 +321,7 @@ static int xpcs_read_fault_c73(struct dw_xpcs *xpcs,
 	return 0;
 }
 
-static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
+static int xpcs_read_link_c73(struct dw_xpcs *xpcs)
 {
 	bool link = true;
 	int ret;
@@ -333,15 +333,6 @@ static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
 	if (!(ret & MDIO_STAT1_LSTATUS))
 		link = false;
 
-	if (an) {
-		ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1);
-		if (ret < 0)
-			return ret;
-
-		if (!(ret & MDIO_STAT1_LSTATUS))
-			link = false;
-	}
-
 	return link;
 }
 
@@ -935,7 +926,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
 	int ret;
 
 	/* Link needs to be read first ... */
-	state->link = xpcs_read_link_c73(xpcs, state->an_enabled) > 0 ? 1 : 0;
+	state->link = xpcs_read_link_c73(xpcs) > 0 ? 1 : 0;
 
 	/* ... and then we check the faults. */
 	ret = xpcs_read_fault_c73(xpcs, state);
Signature · 1 line
2.30.2
#5 lore raw

PATCH 2/2 net: pcs: lynx: don't print an_enabled in pcs_get_state()

In reply to Russell King (Oracle)

an_enabled will be going away, and in any case, pcs_get_state() should not be updating this member. Remove the print.

---
 drivers/net/pcs/pcs-lynx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/pcs/pcs-lynx.c +2 -2
index 3903f3baba2b..622c3de3f3a8 100644
@@ -112,11 +112,11 @@ static void lynx_pcs_get_state(struct phylink_pcs *pcs,
 	}
 
 	dev_dbg(&lynx->mdio->dev,
-		"mode=%s/%s/%s link=%u an_enabled=%u an_complete=%u\n",
+		"mode=%s/%s/%s link=%u an_complete=%u\n",
 		phy_modes(state->interface),
 		phy_speed_to_str(state->speed),
 		phy_duplex_to_str(state->duplex),
-		state->link, state->an_enabled, state->an_complete);
+		state->link, state->an_complete);
 }
 
 static int lynx_pcs_config_giga(struct mdio_device *pcs, unsigned int mode,
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH net-next 1/2] net: pcs: xpcs: remove double-read of link state when using AN

In reply to Russell King (Oracle)

Hi Russell,

Quoted 48 lines · Russell King (Oracle)

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Phylink does not want the current state of the link when reading the PCS link state - it wants the latched state. Don't double-read the MII status register. Phylink will re-read as necessary to capture transient link-down events as of dbae3388ea9c ("net: phylink: Force retrigger in case of latched link-fail indicator").

The above referenced commit is a dependency for this change, and thus this change should not be backported to any kernel that does not contain the above referenced commit.

Fixes fcb26bd2b6ca ("net: phy: Add Synopsys DesignWare XPCS MDIO module")
---
 drivers/net/pcs/pcs-xpcs.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/pcs/pcs-xpcs.c +1 -10
index bc428a816719..04a685353041 100644
@@ -321,7 +321,7 @@ static int xpcs_read_fault_c73(struct dw_xpcs *xpcs,
        return 0;
 }
 
-static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
+static int xpcs_read_link_c73(struct dw_xpcs *xpcs)
 {
        bool link = true;
        int ret;
@@ -333,15 +333,6 @@ static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
        if (!(ret & MDIO_STAT1_LSTATUS))
                link = false;
 
-       if (an) {
-               ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1);
-               if (ret < 0)
-                       return ret;
-
-               if (!(ret & MDIO_STAT1_LSTATUS))
-                       link = false;
-       }
-
        return link;
 }
 

drivers/net/pcs/pcs-xpcs.c static int xpcs_get_state_c73(struct dw_xpcs *xpcs, · line 929

Quoted 5 lines
drivers/net/pcs/pcs-xpcs.c +1 -1
@@ -935,7 +926,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
        int ret;
 
        /* Link needs to be read first ... */
-       state->link = xpcs_read_link_c73(xpcs, state->an_enabled) > 0 ? 1 : 0;
+       state->link = xpcs_read_link_c73(xpcs) > 0 ? 1 : 0;

Couldn't you just say:

	state->link = xpcs_read_link_c73(xpcs) > 0;

That should be a boolean, right?

Quoted 6 lines
drivers/net/pcs/pcs-xpcs.c +0 -1
        /* ... and then we check the faults. */
        ret = xpcs_read_fault_c73(xpcs, state);
--

2.30.2

BR
Steen

Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH net-next 2/2] net: pcs: lynx: don't print an_enabled in pcs_get_state()

In reply to Russell King (Oracle)

Hi Russell,

Quoted 29 lines · Russell King (Oracle)

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

an_enabled will be going away, and in any case, pcs_get_state() should not be updating this member. Remove the print.

---
 drivers/net/pcs/pcs-lynx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/pcs/pcs-lynx.c +2 -3
index 3903f3baba2b..622c3de3f3a8 100644
@@ -112,11 +112,11 @@ static void lynx_pcs_get_state(struct phylink_pcs *pcs,
        }
 
        dev_dbg(&lynx->mdio->dev,
-               "mode=%s/%s/%s link=%u an_enabled=%u an_complete=%u\n",
+               "mode=%s/%s/%s link=%u an_complete=%u\n",
                phy_modes(state->interface),
                phy_speed_to_str(state->speed),
                phy_duplex_to_str(state->duplex),
-               state->link, state->an_enabled, state->an_complete);
+               state->link, state->an_complete);
 }
 
 static int lynx_pcs_config_giga(struct mdio_device *pcs, unsigned int mode,
--
Quoted 2 lines

2.30.2

BR
Steen

author reviewer
#3 lore raw

Re: [PATCH net-next 1/2] net: pcs: xpcs: remove double-read of link state when using AN

In reply to Steen Hegelund
Quoted 60 lines · Steen Hegelund

Hi Russell,

Quoted 48 lines · Russell King (Oracle)

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Phylink does not want the current state of the link when reading the PCS link state - it wants the latched state. Don't double-read the MII status register. Phylink will re-read as necessary to capture transient link-down events as of dbae3388ea9c ("net: phylink: Force retrigger in case of latched link-fail indicator").

The above referenced commit is a dependency for this change, and thus this change should not be backported to any kernel that does not contain the above referenced commit.

Fixes fcb26bd2b6ca ("net: phy: Add Synopsys DesignWare XPCS MDIO module")
---
 drivers/net/pcs/pcs-xpcs.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/pcs/pcs-xpcs.c +1 -10
index bc428a816719..04a685353041 100644
@@ -321,7 +321,7 @@ static int xpcs_read_fault_c73(struct dw_xpcs *xpcs,
        return 0;
 }
 
-static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
+static int xpcs_read_link_c73(struct dw_xpcs *xpcs)
 {
        bool link = true;
        int ret;
@@ -333,15 +333,6 @@ static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
        if (!(ret & MDIO_STAT1_LSTATUS))
                link = false;
 
-       if (an) {
-               ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1);
-               if (ret < 0)
-                       return ret;
-
-               if (!(ret & MDIO_STAT1_LSTATUS))
-                       link = false;
-       }
-
        return link;
 }
 

drivers/net/pcs/pcs-xpcs.c static int xpcs_get_state_c73(struct dw_xpcs *xpcs, · line 929

Quoted 5 lines
drivers/net/pcs/pcs-xpcs.c +1 -1
@@ -935,7 +926,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
        int ret;
 
        /* Link needs to be read first ... */
-       state->link = xpcs_read_link_c73(xpcs, state->an_enabled) > 0 ? 1 : 0;
+       state->link = xpcs_read_link_c73(xpcs) > 0 ? 1 : 0;

Couldn't you just say:

Quoted 3 lines
	state->link = xpcs_read_link_c73(xpcs) > 0;

That should be a boolean, right?

That would be another change to the code - and consider how such a change would fit in this series given its description and also this patch.

IMHO such a change should be a separate patch - and there's plenty of scope for cleanups like the one you suggest in this driver.

Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#7 lore raw
In reply to Russell King (Oracle)
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 9 lines · On Wed, 15 Mar 2023 14:46:24 +0000 you wrote:

Hi,

This series contains a number fixes for minor issues with some pcs_get_state() implementations, particualrly for the phylink state->an_enabled member. As they are minor, I'm suggesting we queue them in net-next as there is follow-on work for these, and there is no urgency for them to be in -rc.

[...]

Here is the summary with links:
- [net-next,1/2] net: pcs: xpcs: remove double-read of link state when using AN

    https://git.kernel.org/netdev/net-next/c/ef63461caf42
  - [net-next,2/2] net: pcs: lynx: don't print an_enabled in pcs_get_state()
    https://git.kernel.org/netdev/net-next/c/ecec0ebbc638

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Reviewed-by
#4 lore raw

Re: [PATCH net-next 1/2] net: pcs: xpcs: remove double-read of link state when using AN

In reply to Russell King (Oracle)

Hi Russell,

Quoted 71 lines · Russell King (Oracle)

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 63 lines · Steen Hegelund

Hi Russell,

Quoted 50 lines · Russell King (Oracle)

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Phylink does not want the current state of the link when reading the PCS link state - it wants the latched state. Don't double-read the MII status register. Phylink will re-read as necessary to capture transient link-down events as of dbae3388ea9c ("net: phylink: Force retrigger in case of latched link-fail indicator").

The above referenced commit is a dependency for this change, and thus this change should not be backported to any kernel that does not contain the above referenced commit.

Fixes fcb26bd2b6ca ("net: phy: Add Synopsys DesignWare XPCS MDIO module")

---
 drivers/net/pcs/pcs-xpcs.c | 13 ++-----------

 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/net/pcs/pcs-xpcs.c +1 -10
index bc428a816719..04a685353041 100644
@@ -321,7 +321,7 @@ static int xpcs_read_fault_c73(struct dw_xpcs *xpcs,
         return 0;
  }
 
-static int xpcs_read_link_c73(struct dw_xpcs *xpcs, bool an)
+static int xpcs_read_link_c73(struct dw_xpcs *xpcs)
  {
         bool link = true;
         int ret;
@@ -333,15 +333,6 @@ static int xpcs_read_link_c73(struct dw_xpcs *xpcs,
 bool an)
         if (!(ret & MDIO_STAT1_LSTATUS))
                 link = false;
 
-       if (an) {
-               ret = xpcs_read(xpcs, MDIO_MMD_AN, MDIO_STAT1);
-               if (ret < 0)
-                       return ret;
-
-               if (!(ret & MDIO_STAT1_LSTATUS))
-                       link = false;
-       }
-
         return link;
  }

drivers/net/pcs/pcs-xpcs.c static int xpcs_get_state_c73(struct dw_xpcs *xpcs, · line 930

Quoted 6 lines
drivers/net/pcs/pcs-xpcs.c +1 -1
@@ -935,7 +926,7 @@ static int xpcs_get_state_c73(struct dw_xpcs *xpcs,
         int ret;
 
         /* Link needs to be read first ... */
-       state->link = xpcs_read_link_c73(xpcs, state->an_enabled) > 0 ? 1
 : 0;
+       state->link = xpcs_read_link_c73(xpcs) > 0 ? 1 : 0;

Couldn't you just say:

Quoted 3 lines

      state->link = xpcs_read_link_c73(xpcs) > 0;

That should be a boolean, right?

Quoted 8 lines

That would be another change to the code - and consider how such a change would fit in this series given its description and also this patch.

IMHO such a change should be a separate patch - and there's plenty of scope for cleanups like the one you suggest in this driver.

Thanks.

OK - got that!

Quoted 3 lines

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

BR
Steen