1 From e0ea63162cb5f1ca7f844d6ef5fc4079448ee2d5 Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Tue, 29 Nov 2022 16:12:18 +0200
4 Subject: [PATCH 11/14] net: dpaa2-eth: connect to MAC before requesting the
7 dpaa2_eth_connect_mac() is called both from dpaa2_eth_probe() and from
8 dpni_irq0_handler_thread().
10 It could happen that the DPNI gets connected to a DPMAC on the fsl-mc
11 bus exactly during probe, as soon as the "endpoint change" interrupt is
12 requested in dpaa2_eth_setup_irqs(). This will cause the
13 dpni_irq0_handler_thread() to register a phylink instance for that DPMAC.
15 Then, the probing function will also try to register a phylink instance
16 for the same DPMAC, operation which should fail (and this will fail the
17 probing of the driver).
19 Reorder dpaa2_eth_setup_irqs() and dpaa2_eth_connect_mac(), such that
20 dpni_irq0_handler_thread() never races with the DPMAC-related portion of
23 Also reorder dpaa2_eth_disconnect_mac() to be in the mirror position of
24 dpaa2_eth_connect_mac() in the teardown path.
26 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
27 Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
28 Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com>
29 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
31 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 18 +++++++++---------
32 1 file changed, 9 insertions(+), 9 deletions(-)
34 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
35 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
36 @@ -4710,6 +4710,10 @@ static int dpaa2_eth_probe(struct fsl_mc
40 + err = dpaa2_eth_connect_mac(priv);
42 + goto err_connect_mac;
44 err = dpaa2_eth_setup_irqs(dpni_dev);
46 netdev_warn(net_dev, "Failed to set link interrupt, fall back to polling\n");
47 @@ -4722,10 +4726,6 @@ static int dpaa2_eth_probe(struct fsl_mc
48 priv->do_link_poll = true;
51 - err = dpaa2_eth_connect_mac(priv);
53 - goto err_connect_mac;
55 err = dpaa2_eth_dl_alloc(priv);
58 @@ -4759,13 +4759,13 @@ err_dl_port_add:
60 dpaa2_eth_dl_free(priv);
62 - dpaa2_eth_disconnect_mac(priv);
64 if (priv->do_link_poll)
65 kthread_stop(priv->poll_thread);
67 fsl_mc_free_irqs(dpni_dev);
69 + dpaa2_eth_disconnect_mac(priv);
71 dpaa2_eth_free_rings(priv);
74 @@ -4813,9 +4813,6 @@ static int dpaa2_eth_remove(struct fsl_m
77 unregister_netdev(net_dev);
79 - dpaa2_eth_disconnect_mac(priv);
82 dpaa2_eth_dl_port_del(priv);
83 dpaa2_eth_dl_traps_unregister(priv);
84 @@ -4826,6 +4823,9 @@ static int dpaa2_eth_remove(struct fsl_m
86 fsl_mc_free_irqs(ls_dev);
89 + dpaa2_eth_disconnect_mac(priv);
91 dpaa2_eth_free_rings(priv);
92 free_percpu(priv->fd);
93 free_percpu(priv->sgt_cache);