Skip to content

Commit cd0a719

Browse files
vladimirolteankuba-moo
authored andcommitted
net: dpaa2-switch: disable the control interface on error path
Currently dpaa2_switch_takedown has a funny name and does not do the opposite of dpaa2_switch_init, which makes probing fail when we need to handle an -EPROBE_DEFER. A sketch of what dpaa2_switch_init does: dpsw_open dpaa2_switch_detect_features dpsw_reset for (i = 0; i < ethsw->sw_attr.num_ifs; i++) { dpsw_if_disable dpsw_if_set_stp dpsw_vlan_remove_if_untagged dpsw_if_set_tci dpsw_vlan_remove_if } dpsw_vlan_remove alloc_ordered_workqueue dpsw_fdb_remove dpaa2_switch_ctrl_if_setup When dpaa2_switch_takedown is called from the error path of dpaa2_switch_probe(), the control interface, enabled by dpaa2_switch_ctrl_if_setup from dpaa2_switch_init, remains enabled, because dpaa2_switch_takedown does not call dpaa2_switch_ctrl_if_teardown. Since dpaa2_switch_probe might fail due to EPROBE_DEFER of a PHY, this means that a second probe of the driver will happen with the control interface directly enabled. This will trigger a second error: [ 93.273528] fsl_dpaa2_switch dpsw.0: dpsw_ctrl_if_set_pools() failed [ 93.281966] fsl_dpaa2_switch dpsw.0: fsl_mc_driver_probe failed: -13 [ 93.288323] fsl_dpaa2_switch: probe of dpsw.0 failed with error -13 Which if we investigate the /dev/dpaa2_mc_console log, we find out is caused by: [E, ctrl_if_set_pools:2211, DPMNG] ctrl_if must be disabled So make dpaa2_switch_takedown do the opposite of dpaa2_switch_init (in reasonable limits, no reason to change STP state, re-add VLANs etc), and rename it to something more conventional, like dpaa2_switch_teardown. Fixes: 613c0a5 ("staging: dpaa2-switch: enable the control interface") Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Ioana Ciornei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fa05bdb commit cd0a719

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,26 +3038,30 @@ static int dpaa2_switch_port_init(struct ethsw_port_priv *port_priv, u16 port)
30383038
return err;
30393039
}
30403040

3041-
static void dpaa2_switch_takedown(struct fsl_mc_device *sw_dev)
3041+
static void dpaa2_switch_ctrl_if_teardown(struct ethsw_core *ethsw)
3042+
{
3043+
dpsw_ctrl_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle);
3044+
dpaa2_switch_free_dpio(ethsw);
3045+
dpaa2_switch_destroy_rings(ethsw);
3046+
dpaa2_switch_drain_bp(ethsw);
3047+
dpaa2_switch_free_dpbp(ethsw);
3048+
}
3049+
3050+
static void dpaa2_switch_teardown(struct fsl_mc_device *sw_dev)
30423051
{
30433052
struct device *dev = &sw_dev->dev;
30443053
struct ethsw_core *ethsw = dev_get_drvdata(dev);
30453054
int err;
30463055

3056+
dpaa2_switch_ctrl_if_teardown(ethsw);
3057+
3058+
destroy_workqueue(ethsw->workqueue);
3059+
30473060
err = dpsw_close(ethsw->mc_io, 0, ethsw->dpsw_handle);
30483061
if (err)
30493062
dev_warn(dev, "dpsw_close err %d\n", err);
30503063
}
30513064

3052-
static void dpaa2_switch_ctrl_if_teardown(struct ethsw_core *ethsw)
3053-
{
3054-
dpsw_ctrl_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle);
3055-
dpaa2_switch_free_dpio(ethsw);
3056-
dpaa2_switch_destroy_rings(ethsw);
3057-
dpaa2_switch_drain_bp(ethsw);
3058-
dpaa2_switch_free_dpbp(ethsw);
3059-
}
3060-
30613065
static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
30623066
{
30633067
struct ethsw_port_priv *port_priv;
@@ -3068,8 +3072,6 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
30683072
dev = &sw_dev->dev;
30693073
ethsw = dev_get_drvdata(dev);
30703074

3071-
dpaa2_switch_ctrl_if_teardown(ethsw);
3072-
30733075
dpaa2_switch_teardown_irqs(sw_dev);
30743076

30753077
dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle);
@@ -3084,9 +3086,7 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
30843086
kfree(ethsw->acls);
30853087
kfree(ethsw->ports);
30863088

3087-
dpaa2_switch_takedown(sw_dev);
3088-
3089-
destroy_workqueue(ethsw->workqueue);
3089+
dpaa2_switch_teardown(sw_dev);
30903090

30913091
fsl_mc_portal_free(ethsw->mc_io);
30923092

@@ -3199,7 +3199,7 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev)
31993199
GFP_KERNEL);
32003200
if (!(ethsw->ports)) {
32013201
err = -ENOMEM;
3202-
goto err_takedown;
3202+
goto err_teardown;
32033203
}
32043204

32053205
ethsw->fdbs = kcalloc(ethsw->sw_attr.num_ifs, sizeof(*ethsw->fdbs),
@@ -3270,8 +3270,8 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev)
32703270
err_free_ports:
32713271
kfree(ethsw->ports);
32723272

3273-
err_takedown:
3274-
dpaa2_switch_takedown(sw_dev);
3273+
err_teardown:
3274+
dpaa2_switch_teardown(sw_dev);
32753275

32763276
err_free_cmdport:
32773277
fsl_mc_portal_free(ethsw->mc_io);

0 commit comments

Comments
 (0)