25c6ac2e8f692b1f86bc46f6346e766fc6926b6a
[openwrt/staging/dedeckeh.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 diff --git a/net/dsa/slave.c b/net/dsa/slave.c
24 index 88f7b8686dac..88bcdba92fa7 100644
25 --- a/net/dsa/slave.c
26 +++ b/net/dsa/slave.c
27 @@ -2011,13 +2011,6 @@ int dsa_slave_create(struct dsa_port *port)
28 port->slave = slave_dev;
29 dsa_slave_setup_tagger(slave_dev);
30
31 - rtnl_lock();
32 - ret = dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN);
33 - rtnl_unlock();
34 - if (ret && ret != -EOPNOTSUPP)
35 - dev_warn(ds->dev, "nonfatal error %d setting MTU to %d on port %d\n",
36 - ret, ETH_DATA_LEN, port->index);
37 -
38 netif_carrier_off(slave_dev);
39
40 ret = dsa_slave_phy_setup(slave_dev);
41 @@ -2028,6 +2021,13 @@ int dsa_slave_create(struct dsa_port *port)
42 goto out_gcells;
43 }
44
45 + rtnl_lock();
46 + ret = dsa_slave_change_mtu(slave_dev, ETH_DATA_LEN);
47 + rtnl_unlock();
48 + if (ret && ret != -EOPNOTSUPP)
49 + dev_warn(ds->dev, "nonfatal error %d setting MTU to %d on port %d\n",
50 + ret, ETH_DATA_LEN, port->index);
51 +
52 rtnl_lock();
53
54 ret = register_netdevice(slave_dev);
55 --
56 2.34.1
57