Re: [PATCH RESEND net-next v17 07/10] net: phy: phy_link_topology: Add a helper to retrieve ports

From: Aleksei Sviridkin

Date: Thu Sep 24 2026 - 18:10:28 EST


On Thu, 10 Sep 2026 19:00:59 +0200, Maxime Chevallier wrote:
> --- a/drivers/net/phy/phy_link_topology.c
> +++ b/drivers/net/phy/phy_link_topology.c
> [...]
> @@ -65,6 +65,14 @@ int phy_link_topo_add_port(struct net_device *dev, struct phy_port *port)
> struct phy_link_topology *topo;
> int ret;
>
> + /* Ports can now be queried without rtnl for ops-locked devices, which
> + * we don't support now as port retrieval is done under rtnl.
> + * We don't have phy_port enabled devices yet, let's make sure
> + * we are loudly warned about that when it happens.
> + */
> + if (WARN_ON_ONCE(netdev_need_ops_lock(dev)))
> + return -EOPNOTSUPP;

With CONFIG_NET_SHAPER=y this dereferences dev->netdev_ops, and
mtk_eth_soc calls phylink_create() before it sets netdev_ops
(mtk_add_mac()). On a board with an SFP cage on a GMAC, such as the
BPI-R3, the cage port is created from phylink_create(), so probe hits a
NULL netdev_ops. This is not only theoretical for OpenWrt:
NET_SHAPER is selected by IAVF, and the filogic snapshot builds
kmod-iavf, so the stock kernel for these boards has it enabled.

I found this by reading the code, not on hardware: on my board the
cage sits on a DSA user port, and DSA sets netdev_ops before it
creates phylink.

Aleksei