From nobody Mon Feb 9 02:13:29 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 4BA8939527F for ; Thu, 5 Feb 2026 09:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770283424; cv=none; b=gQK+fc17Aeb36I0bCenXfUaeDD4J2U7tP5B/q+8fSGroEAcU8ZKgISAxjDHrScGtSjVCI2ggp38Jp5mVU67gi2kyPYH3cGlIjwepg6u3E1fQ7iedICnwm0RvSz9b1H64ko0V09DcdBicXDpISGtC9BOmrBzASvcZtvS7zAMcAy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770283424; c=relaxed/simple; bh=LFvctfWgGDlyczRK7oifPRuAEGPn7n5lZy3/kGYSiKU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kr0H6zJMnw2XwxEOyMZAy0IkpgY3Zyk+pAI9/WWUE2uJFOfEnxnajt3ZHFIzF9tMUKapVetmrwvv2EmWuqvgGPFeOgkGS6koYLZtex0uEToL+H02Ebk6DZSqdU9FNMqApRzxFWBLiJAeKiSVa3HfdJhax1PLOBbYL9+QgGi6pRY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=WoT/CkD7; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="WoT/CkD7" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 7DE09C243AD; Thu, 5 Feb 2026 09:23:48 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7776B606FD; Thu, 5 Feb 2026 09:23:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 46D03119A88F7; Thu, 5 Feb 2026 10:23:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1770283421; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=sY2+AxUBkLgjy+wpLlal4YkUPnAJq7bIl6kx5ZfcjKQ=; b=WoT/CkD7ZriWKnU3yM2eQ1je1sYkhx1Yxs7r/elV3dbyRQTxLaGGt2buOPzuw8Q1RjGdF2 kyGCXvGtDd0+U//o9wT5HpT60OiIr8LjqKnpHRMJj1lJ3TDaA7ximgNQJfE6+NoTN+hbud MQ228cA3ZG0v6YB7tiwSSnlFc6Do3LSGB1XZ5t4eRCqkRjUh3WVV4raXCOBa0IiCJMkF3s uRPRH0reiQqV1+7936LYYa56w76hvqbpg6DFfcnMYb6fpHZXf2WfyQ8MDMf+JWXnJCmbct wHnuH0ayTFiGRPahqc8gAv1fQE70Ghm2Souwaaikr1wzTrelABVOxeVvcYWJMw== From: Maxime Chevallier To: davem@davemloft.net, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , Heiner Kallweit Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Christophe Leroy , Herve Codina , Florian Fainelli , Vladimir Oltean , =?UTF-8?q?K=C3=B6ry=20Maincent?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Oleksij Rempel , =?UTF-8?q?Nicol=C3=B2=20Veronese?= , Simon Horman , mwojtas@chromium.org, Romain Gantois , Daniel Golle , Dimitri Fedrau Subject: [PATCH net-next v5 03/13] net: phy: phy_port: Correctly recompute the port's linkmodes Date: Thu, 5 Feb 2026 10:23:06 +0100 Message-ID: <20260205092317.755906-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20260205092317.755906-1-maxime.chevallier@bootlin.com> References: <20260205092317.755906-1-maxime.chevallier@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" 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 --- 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) =3D { 0 }; + __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) =3D {0}; unsigned long mode; int i; =20 - 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 =3D max_t(int, port->pairs, ethtool_linkmode_n_pairs(mode)); =20 + for_each_set_bit(i, &port->mediums, __ETHTOOL_LINK_MEDIUM_LAST) { + __ETHTOOL_DECLARE_LINK_MODE_MASK(med_supported) =3D {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 --=20 2.49.0