2
0

701-v6.2-0009-net-dpaa2-eth-connect-to-MAC-before-requesting-the-e.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From e0ea63162cb5f1ca7f844d6ef5fc4079448ee2d5 Mon Sep 17 00:00:00 2001
  2. From: Vladimir Oltean <[email protected]>
  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. dpaa2_eth_connect_mac() is called both from dpaa2_eth_probe() and from
  7. dpni_irq0_handler_thread().
  8. It could happen that the DPNI gets connected to a DPMAC on the fsl-mc
  9. bus exactly during probe, as soon as the "endpoint change" interrupt is
  10. requested in dpaa2_eth_setup_irqs(). This will cause the
  11. dpni_irq0_handler_thread() to register a phylink instance for that DPMAC.
  12. Then, the probing function will also try to register a phylink instance
  13. for the same DPMAC, operation which should fail (and this will fail the
  14. probing of the driver).
  15. Reorder dpaa2_eth_setup_irqs() and dpaa2_eth_connect_mac(), such that
  16. dpni_irq0_handler_thread() never races with the DPMAC-related portion of
  17. the probing path.
  18. Also reorder dpaa2_eth_disconnect_mac() to be in the mirror position of
  19. dpaa2_eth_connect_mac() in the teardown path.
  20. Signed-off-by: Vladimir Oltean <[email protected]>
  21. Reviewed-by: Ioana Ciornei <[email protected]>
  22. Tested-by: Ioana Ciornei <[email protected]>
  23. Signed-off-by: Paolo Abeni <[email protected]>
  24. ---
  25. .../net/ethernet/freescale/dpaa2/dpaa2-eth.c | 18 +++++++++---------
  26. 1 file changed, 9 insertions(+), 9 deletions(-)
  27. --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
  28. +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
  29. @@ -4710,6 +4710,10 @@ static int dpaa2_eth_probe(struct fsl_mc
  30. }
  31. #endif
  32. + err = dpaa2_eth_connect_mac(priv);
  33. + if (err)
  34. + goto err_connect_mac;
  35. +
  36. err = dpaa2_eth_setup_irqs(dpni_dev);
  37. if (err) {
  38. netdev_warn(net_dev, "Failed to set link interrupt, fall back to polling\n");
  39. @@ -4722,10 +4726,6 @@ static int dpaa2_eth_probe(struct fsl_mc
  40. priv->do_link_poll = true;
  41. }
  42. - err = dpaa2_eth_connect_mac(priv);
  43. - if (err)
  44. - goto err_connect_mac;
  45. -
  46. err = dpaa2_eth_dl_alloc(priv);
  47. if (err)
  48. goto err_dl_register;
  49. @@ -4759,13 +4759,13 @@ err_dl_port_add:
  50. err_dl_trap_register:
  51. dpaa2_eth_dl_free(priv);
  52. err_dl_register:
  53. - dpaa2_eth_disconnect_mac(priv);
  54. -err_connect_mac:
  55. if (priv->do_link_poll)
  56. kthread_stop(priv->poll_thread);
  57. else
  58. fsl_mc_free_irqs(dpni_dev);
  59. err_poll_thread:
  60. + dpaa2_eth_disconnect_mac(priv);
  61. +err_connect_mac:
  62. dpaa2_eth_free_rings(priv);
  63. err_alloc_rings:
  64. err_csum:
  65. @@ -4813,9 +4813,6 @@ static int dpaa2_eth_remove(struct fsl_m
  66. #endif
  67. unregister_netdev(net_dev);
  68. - rtnl_lock();
  69. - dpaa2_eth_disconnect_mac(priv);
  70. - rtnl_unlock();
  71. dpaa2_eth_dl_port_del(priv);
  72. dpaa2_eth_dl_traps_unregister(priv);
  73. @@ -4826,6 +4823,9 @@ static int dpaa2_eth_remove(struct fsl_m
  74. else
  75. fsl_mc_free_irqs(ls_dev);
  76. + rtnl_lock();
  77. + dpaa2_eth_disconnect_mac(priv);
  78. + rtnl_unlock();
  79. dpaa2_eth_free_rings(priv);
  80. free_percpu(priv->fd);
  81. free_percpu(priv->sgt_cache);