7c394c55db1f4a10194c545ff580076ca8b5e004
[openwrt/staging/robimarko.git] /
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
5 "endpoint changed" IRQ
6
7 dpaa2_eth_connect_mac() is called both from dpaa2_eth_probe() and from
8 dpni_irq0_handler_thread().
9
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.
14
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).
18
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
21 the probing path.
22
23 Also reorder dpaa2_eth_disconnect_mac() to be in the mirror position of
24 dpaa2_eth_connect_mac() in the teardown path.
25
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>
30 ---
31 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 18 +++++++++---------
32 1 file changed, 9 insertions(+), 9 deletions(-)
33
34 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
35 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
36 @@ -4708,6 +4708,10 @@ static int dpaa2_eth_probe(struct fsl_mc
37 }
38 #endif
39
40 + err = dpaa2_eth_connect_mac(priv);
41 + if (err)
42 + goto err_connect_mac;
43 +
44 err = dpaa2_eth_setup_irqs(dpni_dev);
45 if (err) {
46 netdev_warn(net_dev, "Failed to set link interrupt, fall back to polling\n");
47 @@ -4720,10 +4724,6 @@ static int dpaa2_eth_probe(struct fsl_mc
48 priv->do_link_poll = true;
49 }
50
51 - err = dpaa2_eth_connect_mac(priv);
52 - if (err)
53 - goto err_connect_mac;
54 -
55 err = dpaa2_eth_dl_alloc(priv);
56 if (err)
57 goto err_dl_register;
58 @@ -4759,13 +4759,13 @@ err_dl_port_add:
59 err_dl_trap_register:
60 dpaa2_eth_dl_free(priv);
61 err_dl_register:
62 - dpaa2_eth_disconnect_mac(priv);
63 -err_connect_mac:
64 if (priv->do_link_poll)
65 kthread_stop(priv->poll_thread);
66 else
67 fsl_mc_free_irqs(dpni_dev);
68 err_poll_thread:
69 + dpaa2_eth_disconnect_mac(priv);
70 +err_connect_mac:
71 dpaa2_eth_free_rings(priv);
72 err_alloc_rings:
73 err_csum:
74 @@ -4813,9 +4813,6 @@ static int dpaa2_eth_remove(struct fsl_m
75 #endif
76
77 unregister_netdev(net_dev);
78 - rtnl_lock();
79 - dpaa2_eth_disconnect_mac(priv);
80 - rtnl_unlock();
81
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
85 else
86 fsl_mc_free_irqs(ls_dev);
87
88 + rtnl_lock();
89 + dpaa2_eth_disconnect_mac(priv);
90 + rtnl_unlock();
91 dpaa2_eth_free_rings(priv);
92 free_percpu(priv->fd);
93 free_percpu(priv->sgt_cache);