[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8d6a8d0a-77e1-47cd-8562-ae852e22a62a@bootlin.com>
Date: Wed, 4 Feb 2026 08:39:28 +0100
From: Maxime Chevallier <maxime.chevallier@...tlin.com>
To: davem@...emloft.net, Andrew Lunn <andrew@...n.ch>,
Jakub Kicinski <kuba@...nel.org>, Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>, Russell King <linux@...linux.org.uk>,
Heiner Kallweit <hkallweit1@...il.com>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
thomas.petazzoni@...tlin.com, Christophe Leroy
<christophe.leroy@...roup.eu>, Herve Codina <herve.codina@...tlin.com>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <vladimir.oltean@....com>,
Köry Maincent <kory.maincent@...tlin.com>,
Marek Behún <kabel@...nel.org>,
Oleksij Rempel <o.rempel@...gutronix.de>,
Nicolò Veronese <nicveronese@...il.com>,
Simon Horman <horms@...nel.org>, mwojtas@...omium.org,
Romain Gantois <romain.gantois@...tlin.com>,
Daniel Golle <daniel@...rotopia.org>,
Dimitri Fedrau <dimitri.fedrau@...bherr.com>
Subject: Re: [PATCH net-next v4 03/13] net: phy: phy_port: Correctly recompute
the port's linkmodes
On 03/02/2026 18:28, Maxime Chevallier wrote:
> a PHY-driven phy_port contains a 'supported' field containing the
> linkmodes available on this port. This is populated based on :
> - The PHY's reported features
> - The DT representation of the connector
> - The PHY's attach_mdi() callback
>
> As these different attrbution methods work in conjunction, the helper
> phy_port_update_supported() recomputes the final 'supported' value based
> on the populated mediums, linkmodes and pairs.
>
> However this recompute wasn't correctly implemented, and added more
> modes than necessary by or'ing the medium-specific modes to the existing
> support. Let's fix this and properly filter the modes.
>
> Fixes: 589e934d2735 ("net: phy: Introduce PHY ports representation")
> Signed-off-by: Maxime Chevallier <maxime.chevallier@...tlin.com>
> ---
> drivers/net/phy/phy_port.c | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/phy/phy_port.c b/drivers/net/phy/phy_port.c
> index a269e9ea12c4..ad2580529842 100644
> --- a/drivers/net/phy/phy_port.c
> +++ b/drivers/net/phy/phy_port.c
> @@ -108,16 +108,10 @@ EXPORT_SYMBOL_GPL(phy_of_parse_port);
> */
> void phy_port_update_supported(struct phy_port *port)
> {
> - __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0 };
> + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = {0};
> unsigned long mode;
> int i;
>
> - for_each_set_bit(i, &port->mediums, __ETHTOOL_LINK_MEDIUM_LAST) {
> - linkmode_zero(supported);
> - phy_caps_medium_get_supported(supported, i, port->pairs);
> - linkmode_or(port->supported, port->supported, supported);
> - }
> -
> /* If there's no pairs specified, we grab the default number of
> * pairs as the max of the default pairs for each linkmode
> */
> @@ -127,6 +121,23 @@ void phy_port_update_supported(struct phy_port *port)
> port->pairs = max_t(int, port->pairs,
> ethtool_linkmode_n_pairs(mode));
>
> + for_each_set_bit(i, &port->mediums, __ETHTOOL_LINK_MEDIUM_LAST) {
> + pr_info("Adding mode for medium %d pairs %d\n", i, port->pairs);
Bah. That print statement doesn't belong here...
Maxime
Powered by blists - more mailing lists