[PATCH net-next 01/13] net: phy: phy_port: Correctly recompute the port's linkmodes

Maxime Chevallier posted 13 patches 1 week, 5 days ago
There is a newer version of this series
[PATCH net-next 01/13] net: phy: phy_port: Correctly recompute the port's linkmodes
Posted by Maxime Chevallier 1 week, 5 days ago
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 attrbutin 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@bootlin.com>
---
 drivers/net/phy/phy_port.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy_port.c b/drivers/net/phy/phy_port.c
index ec93c8ca051e..68a0068220ed 100644
--- a/drivers/net/phy/phy_port.c
+++ b/drivers/net/phy/phy_port.c
@@ -118,11 +118,14 @@ void phy_port_update_supported(struct phy_port *port)
 	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);
+		__ETHTOOL_DECLARE_LINK_MODE_MASK(med_supported) = {0};
+
+		phy_caps_medium_get_supported(med_supported, i, port->pairs);
+		linkmode_or(supported, supported, med_supported);
 	}
 
+	linkmode_and(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
 	 */
-- 
2.49.0
Re: [PATCH net-next 01/13] net: phy: phy_port: Correctly recompute the port's linkmodes
Posted by Kory Maincent 1 week, 5 days ago
On Tue, 27 Jan 2026 14:41:49 +0100
Maxime Chevallier <maxime.chevallier@bootlin.com> 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 attrbutin methods work in conjunction, the helper

Typo here:           ^^^^^^^^^

> 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@bootlin.com>

It is the only fix of the series, maybe you should send it standalone?
Else this seems ok to me.

-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
Re: [PATCH net-next 01/13] net: phy: phy_port: Correctly recompute the port's linkmodes
Posted by Maxime Chevallier 1 week, 5 days ago

On 27/01/2026 15:00, Kory Maincent wrote:
> On Tue, 27 Jan 2026 14:41:49 +0100
> Maxime Chevallier <maxime.chevallier@bootlin.com> 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 attrbutin methods work in conjunction, the helper
> 
> Typo here:           ^^^^^^^^^

Erf, thanks :)

> 
>> 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@bootlin.com>
> 
> It is the only fix of the series, maybe you should send it standalone?
> Else this seems ok to me.
> 

I considered that yeah, however without the rest of this series, this
bug has no impact. I'll probably split it out anyways, depending on how
review goes for the whole series.

Maxime