Skip to content

Commit a20f997

Browse files
lunndavem330
authored andcommitted
net: dsa: Don't instantiate phylink for CPU/DSA ports unless needed
By default, DSA drivers should configure CPU and DSA ports to their maximum speed. In many configurations this is sufficient to make the link work. In some cases it is necessary to configure the link to run slower, e.g. because of limitations of the SoC it is connected to. Or back to back PHYs are used and the PHY needs to be driven in order to establish link. In this case, phylink is used. Only instantiate phylink if it is required. If there is no PHY, or no fixed link properties, phylink can upset a link which works in the default configuration. Fixes: 0e27921 ("net: dsa: Use PHYLINK for the CPU/DSA ports") Signed-off-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 46e4c42 commit a20f997

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

net/dsa/port.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,14 @@ static int dsa_port_phylink_register(struct dsa_port *dp)
648648
int dsa_port_link_register_of(struct dsa_port *dp)
649649
{
650650
struct dsa_switch *ds = dp->ds;
651+
struct device_node *phy_np;
651652

652-
if (!ds->ops->adjust_link)
653-
return dsa_port_phylink_register(dp);
653+
if (!ds->ops->adjust_link) {
654+
phy_np = of_parse_phandle(dp->dn, "phy-handle", 0);
655+
if (of_phy_is_fixed_link(dp->dn) || phy_np)
656+
return dsa_port_phylink_register(dp);
657+
return 0;
658+
}
654659

655660
dev_warn(ds->dev,
656661
"Using legacy PHYLIB callbacks. Please migrate to PHYLINK!\n");
@@ -665,11 +670,12 @@ void dsa_port_link_unregister_of(struct dsa_port *dp)
665670
{
666671
struct dsa_switch *ds = dp->ds;
667672

668-
if (!ds->ops->adjust_link) {
673+
if (!ds->ops->adjust_link && dp->pl) {
669674
rtnl_lock();
670675
phylink_disconnect_phy(dp->pl);
671676
rtnl_unlock();
672677
phylink_destroy(dp->pl);
678+
dp->pl = NULL;
673679
return;
674680
}
675681

0 commit comments

Comments
 (0)