From nobody Mon Feb 9 09:43:30 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 5426A2C235D; Tue, 3 Feb 2026 17:29:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770139741; cv=none; b=CSzHkN8idUStdSnxYL+A8XJcytNvbbI8LXk0bqs8MysdGZ7LIHOjXWeLo+XHhEVQuw5yJ71eyoIZRbJiHLHTfctf+5NEho/ceTaK8/3yoc7uyYp5JOpNJ28U7rPzzNv/XH+yl1w/ExkRwC3FIEWp+9L7s4S4vCoL5mrYriRcse8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770139741; c=relaxed/simple; bh=OXv41CaCxkIeKEa8hsRowKmYkbdiMm3q+IPpNww8qsQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gH9vzuajhJd95nr84wjGYZDH8JsSbIaUP+K1ncihhxuAMPkl1wnQ87wcjNXzNw1BzSZgwdtMRG5yp24i1qWuFH4zuDL441LnfEwbaekP1qUt4doxIL+d0kBUogZuEochrDa5JZnZt0zLCx8C+0HTWisI/evEv2ywAc1JTsEeQic= 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=he/m4SPG; arc=none smtp.client-ip=185.246.84.56 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="he/m4SPG" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 1B2141A2BC7; Tue, 3 Feb 2026 17:28:59 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E4C5B60728; Tue, 3 Feb 2026 17:28:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 48D4D119A88F9; Tue, 3 Feb 2026 18:28:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1770139737; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=/OC/buRnlLfFzn+BhWblbXGZm2j74ao97s8f0goP980=; b=he/m4SPG6SwfImkVhRBQpI7KhmaWYNu+FaVBgKdu05GezgzzAhw5gWHHOML8LzabWyFEpR i9wyO1wjW9NluRUU4gZaEzjbMMrHyvaLCe4RmIeRY43pPAM+1Wr68orKGf/1NPpnW+hk9a tejbH/GC0+flU8t/uPVbsYWon4r+N0/MNjWlxDFuBoXhsWB5OYCqBdfLb7jiB2+DhFJ+gk ozKEPDOaQCQrEBOTwQqvyOKtLt7WSDF6QgYweDEYG2J50CVE5Umcru/d4Bi3ybk5eLAnIX Nlg9FTf8iXgM1WkdNMi5yFxVfRu7MNWdsrQ1TyoDGzPRSiJAlCJSgQPy9Cbe0A== 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 v4 03/13] net: phy: phy_port: Correctly recompute the port's linkmodes Date: Tue, 3 Feb 2026 18:28:27 +0100 Message-ID: <20260203172839.548524-4-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20260203172839.548524-1-maxime.chevallier@bootlin.com> References: <20260203172839.548524-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 | 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) =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,23 @@ 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) { + pr_info("Adding mode for medium %d pairs %d\n", i, port->pairs); + __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