From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AFD3357706; Wed, 11 Feb 2026 09:40:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770802803; cv=none; b=U27W4a2TqR3JFjuRipbnK1IFXvBGfFciQmjF4LHWWs46foJe0DoIjG6mhPBiST+oYmfluvnUszl1Dp31SfnX/Gw4WZ6C9YvP1EtZnxKRfaxwBpaSlGOIZVJZ0NVoquOH9hed6u4Ixh4/+ucKR0HAU0TAYS/TaGhcYtRy4rV+IIY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770802803; c=relaxed/simple; bh=Q4waBNpupqyQVBWTyFJufE9FHYc2T+I4CNoB9b8FVqQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=S7PbubdxQ0sOD0sOoM3qcgCZ6FkxGtmxDYV3103UlOXTNoOSku8eOLx39PHPgkAqMQFl1prhqogWAji6b01QZfUI+mg6ENpvpEHgQJhA64hOSo8ZLeYFWGSkXEGIXD8WMZy3smzL9MsYBb844ERCeFuOSxZrdEjhYUbYpqQRIcg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jVoi48re; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jVoi48re" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAEDBC19423; Wed, 11 Feb 2026 09:39:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770802803; bh=Q4waBNpupqyQVBWTyFJufE9FHYc2T+I4CNoB9b8FVqQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=jVoi48re5zM0FvlYMZcK83+SdFfPd1I6heREhZf2l1hKHAsk+WkOOX9VmCEqkwDxI q4Af1s/Xdff7jaAim48Bky2FKZuJuQ5tT2ArVpbloVmQ2/0yqgVGyyS/YdQcnXXt78 SsppZAPE2pNq2Gy3C4ce+qvgzNe3PmoAwIjZrd9KAWWmQO96B0B70SrsMXBjhP+6Qd NAf/K9bf35jTHUU0ROWzEixuv7NzpUc4tKikvBPqdF2fHfoXDsONSE71MvQ22vesac 5NbARIkg2dlJcQLMe64sF/kjY6bQrQg4lrXhkIxycigziv+TMYL4ynGg1BO54cUmjp 10mXXiaLiCBNQ== Message-ID: <31bde1a4-adaf-4a1d-8b88-6075189a6af4@kernel.org> Date: Wed, 11 Feb 2026 10:39:54 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v5 03/13] net: phy: phy_port: Correctly recompute the port's linkmodes To: Maxime Chevallier , davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Heiner Kallweit Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Herve Codina , Florian Fainelli , Vladimir Oltean , =?UTF-8?Q?K=C3=B6ry_Maincent?= , =?UTF-8?Q?Marek_Beh=C3=BAn?= , Oleksij Rempel , =?UTF-8?Q?Nicol=C3=B2_Veronese?= , Simon Horman , mwojtas@chromium.org, Romain Gantois , Daniel Golle , Dimitri Fedrau References: <20260205092317.755906-1-maxime.chevallier@bootlin.com> <20260205092317.755906-4-maxime.chevallier@bootlin.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <20260205092317.755906-4-maxime.chevallier@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 05/02/2026 à 10:23, Maxime Chevallier a écrit : > 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 Reviewed-by: Christophe Leroy (CS GROUP) > --- > drivers/net/phy/phy_port.c | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/phy/phy_port.c b/drivers/net/phy/phy_port.c > index a269e9ea12c4..63d1bb154dc7 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,22 @@ 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) { > + __ETHTOOL_DECLARE_LINK_MODE_MASK(med_supported) = {0}; > + > + phy_caps_medium_get_supported(med_supported, i, port->pairs); > + linkmode_or(supported, supported, med_supported); > + } > + > + /* If port->supported is already populated, filter it out with the > + * medium/pair support. Otherwise, let's just use this medium-based > + * support as the port's supported list. > + */ > + if (linkmode_empty(port->supported)) > + linkmode_copy(port->supported, supported); > + else > + linkmode_and(port->supported, supported, port->supported); > + > /* Serdes ports supported through SFP may not have any medium set, > * as they will output PHY_INTERFACE_MODE_XXX modes. In that case, derive > * the supported list based on these interfaces