Skip to content

Commit

Permalink
net: dsa: reorder PHY initialization with MTU setup in slave.c
Browse files Browse the repository at this point in the history
In dsa_slave_create() there are 2 sections that take rtnl_lock():
MTU change and netdev registration. They are separated by PHY
initialization.

There isn't any strict ordering requirement except for the fact that
netdev registration should be last. Therefore, we can perform the MTU
change a bit later, after the PHY setup. A future change will then be
able to merge the two rtnl_lock sections into one.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vladimir Oltean authored and David S. Miller committed Jan 6, 2022
1 parent d093d17 commit 904e112
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -2011,13 +2011,6 @@ int dsa_slave_create(struct dsa_port *port)
port->slave = slave_dev;
dsa_slave_setup_tagger(slave_dev);

rtnl_lock();
ret = dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN);
rtnl_unlock();
if (ret && ret != -EOPNOTSUPP)
dev_warn(ds->dev, "nonfatal error %d setting MTU to %d on port %d\n",
ret, ETH_DATA_LEN, port->index);

netif_carrier_off(slave_dev);

ret = dsa_slave_phy_setup(slave_dev);
Expand All @@ -2028,6 +2021,13 @@ int dsa_slave_create(struct dsa_port *port)
goto out_gcells;
}

rtnl_lock();
ret = dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN);
rtnl_unlock();
if (ret && ret != -EOPNOTSUPP)
dev_warn(ds->dev, "nonfatal error %d setting MTU to %d on port %d\n",
ret, ETH_DATA_LEN, port->index);

rtnl_lock();

ret = register_netdevice(slave_dev);
Expand Down

0 comments on commit 904e112

Please sign in to comment.