765-1-net-next-net-dsa-reorder-PHY-initialization-with-MTU-setup-in.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From 904e112ad431492b34f235f59738e8312802bbf9 Mon Sep 17 00:00:00 2001
  2. From: Vladimir Oltean <[email protected]>
  3. Date: Thu, 6 Jan 2022 01:11:12 +0200
  4. Subject: [PATCH 1/6] net: dsa: reorder PHY initialization with MTU setup in
  5. slave.c
  6. In dsa_slave_create() there are 2 sections that take rtnl_lock():
  7. MTU change and netdev registration. They are separated by PHY
  8. initialization.
  9. There isn't any strict ordering requirement except for the fact that
  10. netdev registration should be last. Therefore, we can perform the MTU
  11. change a bit later, after the PHY setup. A future change will then be
  12. able to merge the two rtnl_lock sections into one.
  13. Signed-off-by: Vladimir Oltean <[email protected]>
  14. Reviewed-by: Florian Fainelli <[email protected]>
  15. Signed-off-by: David S. Miller <[email protected]>
  16. ---
  17. net/dsa/slave.c | 14 +++++++-------
  18. 1 file changed, 7 insertions(+), 7 deletions(-)
  19. --- a/net/dsa/slave.c
  20. +++ b/net/dsa/slave.c
  21. @@ -1977,13 +1977,6 @@ int dsa_slave_create(struct dsa_port *po
  22. port->slave = slave_dev;
  23. dsa_slave_setup_tagger(slave_dev);
  24. - rtnl_lock();
  25. - ret = dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN);
  26. - rtnl_unlock();
  27. - if (ret && ret != -EOPNOTSUPP)
  28. - dev_warn(ds->dev, "nonfatal error %d setting MTU to %d on port %d\n",
  29. - ret, ETH_DATA_LEN, port->index);
  30. -
  31. netif_carrier_off(slave_dev);
  32. ret = dsa_slave_phy_setup(slave_dev);
  33. @@ -1995,6 +1988,13 @@ int dsa_slave_create(struct dsa_port *po
  34. }
  35. rtnl_lock();
  36. + ret = dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN);
  37. + rtnl_unlock();
  38. + if (ret && ret != -EOPNOTSUPP)
  39. + dev_warn(ds->dev, "nonfatal error %d setting MTU to %d on port %d\n",
  40. + ret, ETH_DATA_LEN, port->index);
  41. +
  42. + rtnl_lock();
  43. ret = register_netdevice(slave_dev);
  44. if (ret) {