1
0

726-net-eth-dpaa2-eth-do-not-hold-rtnl_lock.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From d5af37ae22f0364be9ded773d737dd6e5b207b10 Mon Sep 17 00:00:00 2001
  2. From: Ioana Ciornei <ioana.ciornei@nxp.com>
  3. Date: Thu, 21 Nov 2019 21:15:25 +0200
  4. Subject: [PATCH 3/4] dpaa2-eth: do not hold rtnl_lock on phylink_create() or
  5. _destroy()
  6. The rtnl_lock should not be held when calling phylink_create() or
  7. phylink_destroy() since it leads to the deadlock listed below:
  8. [ 18.656576] rtnl_lock+0x18/0x20
  9. [ 18.659798] sfp_bus_add_upstream+0x28/0x90
  10. [ 18.663974] phylink_create+0x2cc/0x828
  11. [ 18.667803] dpaa2_mac_connect+0x14c/0x2a8
  12. [ 18.671890] dpaa2_eth_connect_mac+0x94/0xd8
  13. Fix this by moving the _lock() and _unlock() calls just outside of
  14. phylink_of_phy_connect() and phylink_disconnect_phy().
  15. Fixes: 719479230893 ("dpaa2-eth: add MAC/PHY support through phylink")
  16. Reported-by: Russell King <linux@armlinux.org.uk>
  17. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
  18. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
  19. ---
  20. drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 4 ----
  21. drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 4 ++++
  22. 2 files changed, 4 insertions(+), 4 deletions(-)
  23. --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
  24. +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
  25. @@ -4215,12 +4215,10 @@ static irqreturn_t dpni_irq0_handler_thr
  26. dpaa2_eth_set_mac_addr(netdev_priv(net_dev));
  27. dpaa2_eth_update_tx_fqids(priv);
  28. - rtnl_lock();
  29. if (dpaa2_eth_has_mac(priv))
  30. dpaa2_eth_disconnect_mac(priv);
  31. else
  32. dpaa2_eth_connect_mac(priv);
  33. - rtnl_unlock();
  34. }
  35. return IRQ_HANDLED;
  36. @@ -4516,9 +4514,7 @@ static int dpaa2_eth_remove(struct fsl_m
  37. #endif
  38. unregister_netdev(net_dev);
  39. - rtnl_lock();
  40. dpaa2_eth_disconnect_mac(priv);
  41. - rtnl_unlock();
  42. dpaa2_eth_dl_port_del(priv);
  43. dpaa2_eth_dl_traps_unregister(priv);
  44. --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
  45. +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c
  46. @@ -357,7 +357,9 @@ int dpaa2_mac_connect(struct dpaa2_mac *
  47. if (mac->pcs)
  48. phylink_set_pcs(mac->phylink, &mac->pcs->pcs);
  49. + rtnl_lock();
  50. err = phylink_fwnode_phy_connect(mac->phylink, dpmac_node, 0);
  51. + rtnl_unlock();
  52. if (err) {
  53. netdev_err(net_dev, "phylink_fwnode_phy_connect() = %d\n", err);
  54. goto err_phylink_destroy;
  55. @@ -378,7 +380,9 @@ void dpaa2_mac_disconnect(struct dpaa2_m
  56. if (!mac->phylink)
  57. return;
  58. + rtnl_lock();
  59. phylink_disconnect_phy(mac->phylink);
  60. + rtnl_unlock();
  61. phylink_destroy(mac->phylink);
  62. dpaa2_pcs_destroy(mac);
  63. }