Skip to contentSkip to conversation

mt753x DSA switch support - bug?

DISCUSSION Russell King (Oracle) 1 participant 1 message Nov 21, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

While updating drivers that use phylink, I came across this code in the mt7530 driver in mt753x_phylink_validate():

        if (state->interface != PHY_INTERFACE_MODE_TRGMII ||
            !phy_interface_mode_is_8023z(state->interface)) {
                phylink_set(mask, 10baseT_Half);
                phylink_set(mask, 10baseT_Full);
                phylink_set(mask, 100baseT_Half);
                phylink_set(mask, 100baseT_Full);
                phylink_set(mask, Autoneg);
        }

which looks wrong to me. The if() condition is always true, so all these modes are always set in the mask.

If state->interface is PHY_INTERFACE_MODE_TRGMII, then the first part of the condition is false. phy_interface_mode_is_8023z() is also false, so !phy_interface_mode_is_8023z() will be true. The logical-or results in the if() condition being true.

If state->interface is PHY_INTERFACE_MODE_1000BASEX, then the first part of the condition is true, and due to the logical-or not needing to be further evaluated, results in the if() condition being true.

If state->interface is PHY_INTERFACE_MODE_RGMII, then the first part of the condition is true, and this is exactly the same as the second case above.

I think that "||" should be "&&", since I believe you intend these modes not to be available in TRGMII nor 802.3z modes. Please confirm. Thanks.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!