701-v6.2-0006-net-dpaa2-switch-assign-port_priv-mac-after-dpaa2_ma.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. From a5e7f7e277bd4403c45c1c7922d56d0eb08dbc7c Mon Sep 17 00:00:00 2001
  2. From: Vladimir Oltean <[email protected]>
  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. The dpaa2-switch has the exact same locking requirements when connected
  7. to a DPMAC, so it needs port_priv->mac to always point either to NULL,
  8. or to a DPMAC with a fully initialized phylink instance.
  9. Make the same preparatory change in the dpaa2-switch driver as in the
  10. dpaa2-eth one.
  11. Signed-off-by: Vladimir Oltean <[email protected]>
  12. Reviewed-by: Ioana Ciornei <[email protected]>
  13. Tested-by: Ioana Ciornei <[email protected]>
  14. Signed-off-by: Paolo Abeni <[email protected]>
  15. ---
  16. .../ethernet/freescale/dpaa2/dpaa2-switch.c | 21 +++++++++++--------
  17. 1 file changed, 12 insertions(+), 9 deletions(-)
  18. --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
  19. +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
  20. @@ -1450,9 +1450,8 @@ static int dpaa2_switch_port_connect_mac
  21. err = dpaa2_mac_open(mac);
  22. if (err)
  23. goto err_free_mac;
  24. - port_priv->mac = mac;
  25. - if (dpaa2_switch_port_is_type_phy(port_priv)) {
  26. + if (dpaa2_mac_is_type_phy(mac)) {
  27. err = dpaa2_mac_connect(mac);
  28. if (err) {
  29. netdev_err(port_priv->netdev,
  30. @@ -1462,11 +1461,12 @@ static int dpaa2_switch_port_connect_mac
  31. }
  32. }
  33. + port_priv->mac = mac;
  34. +
  35. return 0;
  36. err_close_mac:
  37. dpaa2_mac_close(mac);
  38. - port_priv->mac = NULL;
  39. err_free_mac:
  40. kfree(mac);
  41. return err;
  42. @@ -1474,15 +1474,18 @@ err_free_mac:
  43. static void dpaa2_switch_port_disconnect_mac(struct ethsw_port_priv *port_priv)
  44. {
  45. - if (dpaa2_switch_port_is_type_phy(port_priv))
  46. - dpaa2_mac_disconnect(port_priv->mac);
  47. + struct dpaa2_mac *mac = port_priv->mac;
  48. +
  49. + port_priv->mac = NULL;
  50. - if (!dpaa2_switch_port_has_mac(port_priv))
  51. + if (!mac)
  52. return;
  53. - dpaa2_mac_close(port_priv->mac);
  54. - kfree(port_priv->mac);
  55. - port_priv->mac = NULL;
  56. + if (dpaa2_mac_is_type_phy(mac))
  57. + dpaa2_mac_disconnect(mac);
  58. +
  59. + dpaa2_mac_close(mac);
  60. + kfree(mac);
  61. }
  62. static irqreturn_t dpaa2_switch_irq0_handler_thread(int irq_num, void *arg)