Skip to content

Commit 3506b2f

Browse files
Helmut Grohnedavem330
authored andcommitted
net: dsa: microchip: call phy_remove_link_mode during probe
When doing "ip link set dev ... up" for a ksz9477 backed link, ksz9477_phy_setup is called and it calls phy_remove_link_mode to remove 1000baseT HDX. During phy_remove_link_mode, phy_advertise_supported is called. Doing so reverts any previous change to advertised link modes e.g. using a udevd .link file. phy_remove_link_mode is not meant to be used while opening a link and should be called during phy probe when the link is not yet available to userspace. Therefore move the phy_remove_link_mode calls into ksz9477_switch_register. It indirectly calls dsa_register_switch, which creates the relevant struct phy_devices and we update the link modes right after that. At that time dev->features is already initialized by ksz9477_switch_detect. Remove phy_setup from ksz_dev_ops as no users remain. Link: https://lore.kernel.org/netdev/[email protected]/ Fixes: 42fc6a4 ("net: dsa: microchip: prepare PHY for proper advertisement") Signed-off-by: Helmut Grohne <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2dc3bd7 commit 3506b2f

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

drivers/net/dsa/microchip/ksz9477.c

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -974,23 +974,6 @@ static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port,
974974
PORT_MIRROR_SNIFFER, false);
975975
}
976976

977-
static void ksz9477_phy_setup(struct ksz_device *dev, int port,
978-
struct phy_device *phy)
979-
{
980-
/* Only apply to port with PHY. */
981-
if (port >= dev->phy_port_cnt)
982-
return;
983-
984-
/* The MAC actually cannot run in 1000 half-duplex mode. */
985-
phy_remove_link_mode(phy,
986-
ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
987-
988-
/* PHY does not support gigabit. */
989-
if (!(dev->features & GBIT_SUPPORT))
990-
phy_remove_link_mode(phy,
991-
ETHTOOL_LINK_MODE_1000baseT_Full_BIT);
992-
}
993-
994977
static bool ksz9477_get_gbit(struct ksz_device *dev, u8 data)
995978
{
996979
bool gbit;
@@ -1603,7 +1586,6 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
16031586
.get_port_addr = ksz9477_get_port_addr,
16041587
.cfg_port_member = ksz9477_cfg_port_member,
16051588
.flush_dyn_mac_table = ksz9477_flush_dyn_mac_table,
1606-
.phy_setup = ksz9477_phy_setup,
16071589
.port_setup = ksz9477_port_setup,
16081590
.r_mib_cnt = ksz9477_r_mib_cnt,
16091591
.r_mib_pkt = ksz9477_r_mib_pkt,
@@ -1617,7 +1599,29 @@ static const struct ksz_dev_ops ksz9477_dev_ops = {
16171599

16181600
int ksz9477_switch_register(struct ksz_device *dev)
16191601
{
1620-
return ksz_switch_register(dev, &ksz9477_dev_ops);
1602+
int ret, i;
1603+
struct phy_device *phydev;
1604+
1605+
ret = ksz_switch_register(dev, &ksz9477_dev_ops);
1606+
if (ret)
1607+
return ret;
1608+
1609+
for (i = 0; i < dev->phy_port_cnt; ++i) {
1610+
if (!dsa_is_user_port(dev->ds, i))
1611+
continue;
1612+
1613+
phydev = dsa_to_port(dev->ds, i)->slave->phydev;
1614+
1615+
/* The MAC actually cannot run in 1000 half-duplex mode. */
1616+
phy_remove_link_mode(phydev,
1617+
ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
1618+
1619+
/* PHY does not support gigabit. */
1620+
if (!(dev->features & GBIT_SUPPORT))
1621+
phy_remove_link_mode(phydev,
1622+
ETHTOOL_LINK_MODE_1000baseT_Full_BIT);
1623+
}
1624+
return ret;
16211625
}
16221626
EXPORT_SYMBOL(ksz9477_switch_register);
16231627

drivers/net/dsa/microchip/ksz_common.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
358358

359359
/* setup slave port */
360360
dev->dev_ops->port_setup(dev, port, false);
361-
if (dev->dev_ops->phy_setup)
362-
dev->dev_ops->phy_setup(dev, port, phy);
363361

364362
/* port_stp_state_set() will be called after to enable the port so
365363
* there is no need to do anything.

drivers/net/dsa/microchip/ksz_common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ struct ksz_dev_ops {
119119
u32 (*get_port_addr)(int port, int offset);
120120
void (*cfg_port_member)(struct ksz_device *dev, int port, u8 member);
121121
void (*flush_dyn_mac_table)(struct ksz_device *dev, int port);
122-
void (*phy_setup)(struct ksz_device *dev, int port,
123-
struct phy_device *phy);
124122
void (*port_cleanup)(struct ksz_device *dev, int port);
125123
void (*port_setup)(struct ksz_device *dev, int port, bool cpu_port);
126124
void (*r_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 *val);

0 commit comments

Comments
 (0)