Skip to contentSkip to conversation

Further SJA1105 phylink link replay fixups

PATCH Applied Vladimir Oltean 2 participants 4 messages Mar 4 – Mar 7

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Further SJA1105 phylink link replay fixups

While I was playing around with the subsystem knowledge in Chris Mason's review-prompts to see what LLMs would have needed to catch the bug behind commit bfd264fbbbca ("net: dsa: sja1105: protect link replay helpers against NULL phylink instance"), it flagged another issue instead, which IMO is valid. This is being fixed in patch 2/2. Patch 1/2 is preparatory reordering for that.

I haven't noticed any physical issues, it only has to do with the soundness of the new call path introduced in January in commit 0b2edc531e0b ("net: dsa: sja1105: let phylink help with the replay of link callbacks").

Vladimir Oltean (2):
net: dsa: sja1105: reorder sja1105_reload_cbs() and
phylink_replay_link_end()
net: dsa: sja1105: ensure phylink_replay_link_end() will not be missed

 drivers/net/dsa/sja1105/sja1105_main.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 net: dsa: sja1105: reorder sja1105_reload_cbs() and phylink_replay_link_end()

Move phylink_replay_link_end() as the last locked operation under sja1105_static_config_reload(). The purpose is to be able to goto this step from the error path of intermediate steps (we must call phylink_replay_link_end()).

sja1105_reload_cbs() notably does not depend on port states or link speeds. See commit 954ad9bf13c4 ("net: dsa: sja1105: fix bandwidth discrepancy between tc-cbs software and offload") which has discussed this issue specifically.

---
 drivers/net/dsa/sja1105/sja1105_main.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/dsa/sja1105/sja1105_main.c +2 -4
index 94d17b06da40..bf720d96bad8 100644
@@ -2339,13 +2339,11 @@ int sja1105_static_config_reload(struct sja1105_private *priv,
 			goto out;
 	}
 
+	rc = sja1105_reload_cbs(priv);
+
 	dsa_switch_for_each_available_port(dp, ds)
 		if (dp->pl)
 			phylink_replay_link_end(dp->pl);
-
-	rc = sja1105_reload_cbs(priv);
-	if (rc < 0)
-		goto out;
 out:
 	mutex_unlock(&priv->mgmt_lock);
 	mutex_unlock(&priv->fdb_lock);
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/2 net: dsa: sja1105: ensure phylink_replay_link_end() will not be missed

In reply to Vladimir Oltean

Most errors that can occur in sja1105_static_config_reload() are fatal (example: fail to communicate with hardware), but not all are.

For example, sja1105_static_config_upload() -> kcalloc() may fail, and if that happens, we have called phylink_replay_link_begin() but never phylink_replay_link_end().

Under that circumstance, all port phylink instances are left in a state where the resolver is stopped with the PHYLINK_DISABLE_REPLAY bit set. We have effectively disabled link management with no way to recover from this condition.

Avoid that situation by ensuring phylink_replay_link_begin() is always paired with phylink_replay_link_end(), regardless of whether we faced any errors during switch reset, configuration reload and general state reload.

Fixes 0b2edc531e0b ("net: dsa: sja1105: let phylink help with the replay of link callbacks")
---
 drivers/net/dsa/sja1105/sja1105_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/sja1105/sja1105_main.c +2 -1
index bf720d96bad8..c72c2bfdcffb 100644
@@ -2341,10 +2341,11 @@ int sja1105_static_config_reload(struct sja1105_private *priv,
 
 	rc = sja1105_reload_cbs(priv);
 
+out:
 	dsa_switch_for_each_available_port(dp, ds)
 		if (dp->pl)
 			phylink_replay_link_end(dp->pl);
-out:
+
 	mutex_unlock(&priv->mgmt_lock);
 	mutex_unlock(&priv->fdb_lock);
 
Signature · 1 line
2.43.0
#3 lore raw
In reply to Vladimir Oltean
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 5 Mar 2026 00:08:58 +0200 you wrote:

While I was playing around with the subsystem knowledge in Chris Mason's review-prompts to see what LLMs would have needed to catch the bug behind commit bfd264fbbbca ("net: dsa: sja1105: protect link replay helpers against NULL phylink instance"), it flagged another issue instead, which IMO is valid. This is being fixed in patch 2/2. Patch 1/2 is preparatory reordering for that.

[...]

Here is the summary with links:
- [net,1/2] net: dsa: sja1105: reorder sja1105_reload_cbs() and phylink_replay_link_end()

    https://git.kernel.org/netdev/net/c/976703cae737
  - [net,2/2] net: dsa: sja1105: ensure phylink_replay_link_end() will not be missed
    https://git.kernel.org/netdev/net/c/ce2da643f00a

You are awesome, thank you!

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