Skip to content

net: phylink: wait for a PHY that probes after the MAC

Aleksei Sviridkin linux-arm-kernel linux-devicetree linux-mediatek lkml netdev 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest3 patches 6 repliesIn review
  2. v53 patches 1 replySuperseded
  3. v42 patches 1 replySuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v3 RFC2 patches0 repliesSuperseded
v2 RFC2 patches0 repliesSuperseded
v1 RFC2 patches3 repliesSuperseded

Changes in v6 from the cover letter

https://lore.kernel.org/r/[email protected]/
- Defer only in PHY mode and without an SFP cage. In-band, the PCS could bring the carrier up with no PHY attached. An SFP PHY could take the port while the wait is armed, and its removal dropped the wait.
- Poll only while phylink is started. A port that is down attaches at its next up, and nothing touches the PHY after a switch shutdown.
- A failed attach after the PHY driver went away no longer counts as a failed connect.
- The patch 2 message no longer says that MACs connecting from ndo_open recover on the next open. They do not when the PHY driver loads while the generic one holds the PHY.
- The dsa.h comment states the rule: .port_enable must not use its phy argument.

[1] https://lore.kernel.org/r/[email protected]/

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3dt-bindings: net: ethernet-phy: add needs-host-firmwareDocumentation/devicetree/bindings/net/ethernet-phy.yaml+6 -00 replies
2/3net: phylink: wait for PHYs that are known to probe latedrivers/net/phy/phylink.c include/linux/phylink.h+229 -81 reply
3/3net: dsa: let user ports wait for a PHY that probes latedrivers/net/dsa/mt7530.c include/net/dsa.h net/dsa/user.c+7 -00 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchConor Dooley
1/3A-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [PATCH net-next v6 0/3] net: phylink: wait for a PHY that probes after the MAC

On the Keenetic KN-1012 (MT7981B with an MT7531 switch), the Airoha EN8811H behind lan4 has its PHY driver built as a module on the root filesystem. The switch sets up its ports before that filesystem is mounted, so the port is validated against the generic driver, fails its phy-mode and stays dead for the uptime. DSA does not retry it.

Patch 1 lets the PHY node say so with needs-host-firmware. Patch 2 makes phylink poll for such a PHY instead of giving up, for a MAC that opts in. Patch 3 opts in DSA user ports of switch drivers that set a flag, and sets it in mt7530.

The poller can still lose a race against an unbind of the PHY driver, between its readiness check and the attach. That window is phylib's:
any phy_attach_direct() caller racing an unbind has it. The attach guard series [1] closes it.

Tested on that board with the series backported to its OpenWrt 6.18 kernel, together with a940003f44e7 and 07d995873960 (the mt7530 .get_stats64 atomic-context fix). The kernel had lockdep and DEBUG_ATOMIC_SLEEP on. Local debug parameters, not part of the series, drove the error paths. They fail the connect after a successful attach, ignore the opt-in, fail the generic attach of a PHY with no driver, and add a sleep after the switch shutdown.

- boot: the PHY driver loaded its firmware at 8.7 s. lan4 attached at 26.3 s, when the port was brought up. Link up at 1 Gb/s.
- port kept down for 10 s with the PHY driver bound: no poll and no attach. "ip link set lan4 up" attached it a second later.
- opt-in ignored: the old behaviour, the generic driver took the PHY.
- two injected failures: "failed to connect late PHY: -EIO" twice, a second apart, and the third attempt attached. Link up at 1 Gb/s.
- failures that do not stop: four attempts and one "giving up". No poll after that, also not after a down/up.
- four failed generic attaches with no driver bound: nothing logged as a failure and no retry spent. The port attached once the driver bound.
- switch unbound while the poller waited: nothing oopsed.
- reboot with a 3 s sleep after the switch shutdown: the poll ran every second up to the shutdown and not once in the sleep. On v5 the same test polled 3 times in the sleep.

No in-tree device tree sets needs-host-firmware yet. The board is supported out of tree, in OpenWrt.

Changes in v6 (since v5):
https://lore.kernel.org/r/[email protected]/
- Defer only in PHY mode and without an SFP cage. In-band, the PCS could bring the carrier up with no PHY attached. An SFP PHY could take the port while the wait is armed, and its removal dropped the wait.
- Poll only while phylink is started. A port that is down attaches at its next up, and nothing touches the PHY after a switch shutdown.
- A failed attach after the PHY driver went away no longer counts as a failed connect.
- The patch 2 message no longer says that MACs connecting from ndo_open recover on the next open. They do not when the PHY driver loads while the generic one holds the PHY.
- The dsa.h comment states the rule: .port_enable must not use its phy argument.

[1] https://lore.kernel.org/r/[email protected]/

Aleksei Sviridkin (3):
dt-bindings: net: ethernet-phy: add needs-host-firmware
net: phylink: wait for PHYs that are known to probe late
net: dsa: let user ports wait for a PHY that probes late

 .../devicetree/bindings/net/ethernet-phy.yaml |   6 +
 drivers/net/dsa/mt7530.c                      |   1 +
 drivers/net/phy/phylink.c                     | 232 +++++++++++++++++-
 include/linux/phylink.h                       |   5 +
 include/net/dsa.h                             |   5 +
 net/dsa/user.c                                |   1 +
 6 files changed, 242 insertions(+), 8 deletions(-)

base-commit: 47a1446725732cd3996edf607e8739334bbf4d78

Signature · 1 line
2.53.0