From: Vladimir Oltean Date: Wed, 5 Jan 2022 23:11:12 +0000 (+0200) Subject: net: dsa: reorder PHY initialization with MTU setup in slave.c X-Git-Tag: perf_urgent_for_v5.17_rc2~90^2~50^2~5 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=904e112ad431492b34f235f59738e8312802bbf9;p=users%2Fdwmw2%2Flinux.git net: dsa: reorder PHY initialization with MTU setup in slave.c 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 Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller --- diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 88f7b8686dac0..88bcdba92fa72 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -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); @@ -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);