]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/linux/linux-5.15-arm64-dpaa2-fix-lock-issue.patch
kernel: add patches for SFP support on NXP Layerscape/DPAA2 (arm64)
[people/pmueller/ipfire-2.x.git] / src / patches / linux / linux-5.15-arm64-dpaa2-fix-lock-issue.patch
CommitLineData
e77ef363
MM
1From 3a39dbe0c0c41f8dba5246ce6e2c5c4bcd6ba661 Mon Sep 17 00:00:00 2001
2From: Ioana Ciornei <ioana.ciornei@nxp.com>
3Date: Thu, 21 Nov 2019 21:15:25 +0200
4Subject: [PATCH 1/4] dpaa2-eth: do not hold rtnl_lock on phylink_create() or
5 _destroy()
6
7The rtnl_lock should not be held when calling phylink_create() or
8phylink_destroy() since it leads to the deadlock listed below:
9
10[ 18.656576] rtnl_lock+0x18/0x20
11[ 18.659798] sfp_bus_add_upstream+0x28/0x90
12[ 18.663974] phylink_create+0x2cc/0x828
13[ 18.667803] dpaa2_mac_connect+0x14c/0x2a8
14[ 18.671890] dpaa2_eth_connect_mac+0x94/0xd8
15
16Fix this by moving the _lock() and _unlock() calls just outside of
17phylink_of_phy_connect() and phylink_disconnect_phy().
18
19Fixes: 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")
20Reported-by: Russell King <linux@armlinux.org.uk>
21Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
22Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
23---
24 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ----
25 drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 4 ++++
26 2 files changed, 4 insertions(+), 4 deletions(-)
27
28diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
29index 8b7a29e1e221..20e65053f036 100644
30--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
31+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
32@@ -4214,12 +4214,10 @@ static irqreturn_t dpni_irq0_handler_thread(int irq_num, void *arg)
33 dpaa2_eth_set_mac_addr(netdev_priv(net_dev));
34 dpaa2_eth_update_tx_fqids(priv);
35
36- rtnl_lock();
37 if (dpaa2_eth_has_mac(priv))
38 dpaa2_eth_disconnect_mac(priv);
39 else
40 dpaa2_eth_connect_mac(priv);
41- rtnl_unlock();
42 }
43
44 return IRQ_HANDLED;
45@@ -4513,9 +4511,7 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
46 #endif
47
48 unregister_netdev(net_dev);
49- rtnl_lock();
50 dpaa2_eth_disconnect_mac(priv);
51- rtnl_unlock();
52
53 dpaa2_eth_dl_port_del(priv);
54 dpaa2_eth_dl_traps_unregister(priv);
55diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
56index ae6d382d8735..8fe32ed4f6dc 100644
57--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
58+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
59@@ -351,7 +351,9 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac)
60 if (mac->pcs)
61 phylink_set_pcs(mac->phylink, &mac->pcs->pcs);
62
63+ rtnl_lock();
64 err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0);
65+ rtnl_unlock();
66 if (err) {
67 netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err);
68 goto err_phylink_destroy;
69@@ -372,7 +374,9 @@ void dpaa2_mac_disconnect(struct dpaa2_mac *mac)
70 if (!mac->phylink)
71 return;
72
73+ rtnl_lock();
74 phylink_disconnect_phy(mac->phylink);
75+ rtnl_unlock();
76 phylink_destroy(mac->phylink);
77 dpaa2_pcs_destroy(mac);
78 }
79--
802.30.1
81