Skip to contentSkip to conversation

net: phylink: initialize carrier state at creation

PATCH Applied Klaus Kudielka 2 participants 2 messages Nov 7, 2023

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

PATCH v2 1/1 net: phylink: initialize carrier state at creation

Background: Turris Omnia (Armada 385); eth2 (mvneta) connected to SFP bus; SFP module is present, but no fiber connected, so definitely no carrier.

After booting, eth2 is down, but netdev LED trigger surprisingly reports link active. Then, after "ip link set eth2 up", the link indicator goes away - as I would have expected it from the beginning.

It turns out, that the default carrier state after netdev creation is "carrier ok". Some ethernet drivers explicitly call netif_carrier_off during probing, others (like mvneta) don't - which explains the current
behaviour: only when the device is brought up, phylink_start calls netif_carrier_off.

Fix this for all drivers using phylink, by calling netif_carrier_off in phylink_create.

Fixes 089381b27abe ("leds: initial support for Turris Omnia LEDs")

---
v2: clarified fixed drivers; added fixes tag & cc stable

 drivers/net/phy/phylink.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/phy/phylink.c +1 -0
index 6712883498..a28da80bde 100644
@@ -1616,6 +1616,7 @@ struct phylink *phylink_create(struct phylink_config *config,
 	pl->config = config;
 	if (config->type == PHYLINK_NETDEV) {
 		pl->netdev = to_net_dev(config->dev);
+		netif_carrier_off(pl->netdev);
 	} else if (config->type == PHYLINK_DEV) {
 		pl->dev = config->dev;
 	} else {
Signature · 1 line
2.42.0
#1 lore raw
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

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

Quoted 8 lines · On Tue, 7 Nov 2023 18:44:02 +0100 you wrote:

Background: Turris Omnia (Armada 385); eth2 (mvneta) connected to SFP bus; SFP module is present, but no fiber connected, so definitely no carrier.

After booting, eth2 is down, but netdev LED trigger surprisingly reports link active. Then, after "ip link set eth2 up", the link indicator goes away - as I would have expected it from the beginning.

[...]

Here is the summary with links:
- [net,v2] net: phylink: initialize carrier state at creation

    https://git.kernel.org/netdev/net/c/02d5fdbf4f2b

You are awesome, thank you!

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