Skip to content

Commit 762c299

Browse files
vladimirolteandavem330
authored andcommitted
Revert "net: dsa: setup master before ports"
This reverts commit 11fd667. dsa_slave_change_mtu() updates the MTU of the DSA master and of the associated CPU port, but only if it detects a change to the master MTU. The blamed commit in the Fixes: tag below addressed a regression where dsa_slave_change_mtu() would return early and not do anything due to ds->ops->port_change_mtu() not being implemented. However, that commit also had the effect that the master MTU got set up to the correct value by dsa_master_setup(), but the associated CPU port's MTU did not get updated. This causes breakage for drivers that rely on the ->port_change_mtu() DSA call to account for the tagging overhead on the CPU port, and don't set up the initial MTU during the setup phase. Things actually worked before because they were in a fragile equilibrium where dsa_slave_change_mtu() was called before dsa_master_setup() was. So dsa_slave_change_mtu() could actually detect a change and update the CPU port MTU too. Restore the code to the way things used to work by reverting the reorder of dsa_tree_setup_master() and dsa_tree_setup_ports(). That change did not have a concrete motivation going for it anyway, it just looked better. Fixes: 066dfc4 ("Revert "net: dsa: stop updating master MTU from master.c"") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e16b859 commit 762c299

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

net/dsa/dsa2.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ static void dsa_port_teardown(struct dsa_port *dp)
562562
{
563563
struct devlink_port *dlp = &dp->devlink_port;
564564
struct dsa_switch *ds = dp->ds;
565-
struct net_device *slave;
566565

567566
if (!dp->setup)
568567
return;
@@ -584,11 +583,9 @@ static void dsa_port_teardown(struct dsa_port *dp)
584583
dsa_port_link_unregister_of(dp);
585584
break;
586585
case DSA_PORT_TYPE_USER:
587-
slave = dp->slave;
588-
589-
if (slave) {
586+
if (dp->slave) {
587+
dsa_slave_destroy(dp->slave);
590588
dp->slave = NULL;
591-
dsa_slave_destroy(slave);
592589
}
593590
break;
594591
}
@@ -1147,28 +1144,28 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst)
11471144
if (err)
11481145
goto teardown_cpu_ports;
11491146

1150-
err = dsa_tree_setup_master(dst);
1147+
err = dsa_tree_setup_ports(dst);
11511148
if (err)
11521149
goto teardown_switches;
11531150

1154-
err = dsa_tree_setup_ports(dst);
1151+
err = dsa_tree_setup_master(dst);
11551152
if (err)
1156-
goto teardown_master;
1153+
goto teardown_ports;
11571154

11581155
err = dsa_tree_setup_lags(dst);
11591156
if (err)
1160-
goto teardown_ports;
1157+
goto teardown_master;
11611158

11621159
dst->setup = true;
11631160

11641161
pr_info("DSA: tree %d setup\n", dst->index);
11651162

11661163
return 0;
11671164

1168-
teardown_ports:
1169-
dsa_tree_teardown_ports(dst);
11701165
teardown_master:
11711166
dsa_tree_teardown_master(dst);
1167+
teardown_ports:
1168+
dsa_tree_teardown_ports(dst);
11721169
teardown_switches:
11731170
dsa_tree_teardown_switches(dst);
11741171
teardown_cpu_ports:
@@ -1186,10 +1183,10 @@ static void dsa_tree_teardown(struct dsa_switch_tree *dst)
11861183

11871184
dsa_tree_teardown_lags(dst);
11881185

1189-
dsa_tree_teardown_ports(dst);
1190-
11911186
dsa_tree_teardown_master(dst);
11921187

1188+
dsa_tree_teardown_ports(dst);
1189+
11931190
dsa_tree_teardown_switches(dst);
11941191

11951192
dsa_tree_teardown_cpu_ports(dst);

0 commit comments

Comments
 (0)