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