e63654984a51944dd72b5e9a62bb0478fbdd01ff
[openwrt/staging/neocturne.git] /
1 From a5e7f7e277bd4403c45c1c7922d56d0eb08dbc7c Mon Sep 17 00:00:00 2001
2 From: Vladimir Oltean <vladimir.oltean@nxp.com>
3 Date: Tue, 29 Nov 2022 16:12:15 +0200
4 Subject: [PATCH 08/14] net: dpaa2-switch: assign port_priv->mac after
5 dpaa2_mac_connect() call
6
7 The dpaa2-switch has the exact same locking requirements when connected
8 to a DPMAC, so it needs port_priv->mac to always point either to NULL,
9 or to a DPMAC with a fully initialized phylink instance.
10
11 Make the same preparatory change in the dpaa2-switch driver as in the
12 dpaa2-eth one.
13
14 Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
15 Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
16 Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com>
17 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
18 ---
19 .../ethernet/freescale/dpaa2/dpaa2-switch.c | 21 +++++++++++--------
20 1 file changed, 12 insertions(+), 9 deletions(-)
21
22 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
23 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
24 @@ -1450,9 +1450,8 @@ static int dpaa2_switch_port_connect_mac
25 err = dpaa2_mac_open(mac);
26 if (err)
27 goto err_free_mac;
28 - port_priv->mac = mac;
29
30 - if (dpaa2_switch_port_is_type_phy(port_priv)) {
31 + if (dpaa2_mac_is_type_phy(mac)) {
32 err = dpaa2_mac_connect(mac);
33 if (err) {
34 netdev_err(port_priv->netdev,
35 @@ -1462,11 +1461,12 @@ static int dpaa2_switch_port_connect_mac
36 }
37 }
38
39 + port_priv->mac = mac;
40 +
41 return 0;
42
43 err_close_mac:
44 dpaa2_mac_close(mac);
45 - port_priv->mac = NULL;
46 err_free_mac:
47 kfree(mac);
48 return err;
49 @@ -1474,15 +1474,18 @@ err_free_mac:
50
51 static void dpaa2_switch_port_disconnect_mac(struct ethsw_port_priv *port_priv)
52 {
53 - if (dpaa2_switch_port_is_type_phy(port_priv))
54 - dpaa2_mac_disconnect(port_priv->mac);
55 + struct dpaa2_mac *mac = port_priv->mac;
56 +
57 + port_priv->mac = NULL;
58
59 - if (!dpaa2_switch_port_has_mac(port_priv))
60 + if (!mac)
61 return;
62
63 - dpaa2_mac_close(port_priv->mac);
64 - kfree(port_priv->mac);
65 - port_priv->mac = NULL;
66 + if (dpaa2_mac_is_type_phy(mac))
67 + dpaa2_mac_disconnect(mac);
68 +
69 + dpaa2_mac_close(mac);
70 + kfree(mac);
71 }
72
73 static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)