0011-02-nss_dp_switchdev-correctly-unregister-notifier-on-dp.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 079bfe441b274a8c06474be82e4ccc88599a5e0e Mon Sep 17 00:00:00 2001
  2. From: Christian Marangi <[email protected]>
  3. Date: Tue, 16 Apr 2024 16:08:46 +0200
  4. Subject: [PATCH 2/6] nss_dp_switchdev: correctly unregister notifier on
  5. dp_remove
  6. Correctly unregister notifier on dp_remove to fix kernel panic on system
  7. reboot.
  8. Signed-off-by: Christian Marangi <[email protected]>
  9. ---
  10. include/nss_dp_dev.h | 1 +
  11. nss_dp_main.c | 4 ++++
  12. nss_dp_switchdev.c | 13 +++++++++++++
  13. 3 files changed, 18 insertions(+)
  14. --- a/include/nss_dp_dev.h
  15. +++ b/include/nss_dp_dev.h
  16. @@ -349,6 +349,7 @@ void nss_dp_set_ethtool_ops(struct net_d
  17. */
  18. #ifdef CONFIG_NET_SWITCHDEV
  19. void nss_dp_switchdev_setup(struct net_device *dev);
  20. +void nss_dp_switchdev_remove(struct net_device *dev);
  21. bool nss_dp_is_phy_dev(struct net_device *dev);
  22. #endif
  23. --- a/nss_dp_main.c
  24. +++ b/nss_dp_main.c
  25. @@ -970,6 +970,10 @@ static int nss_dp_remove(struct platform
  26. if (!dp_priv)
  27. continue;
  28. + #ifdef CONFIG_NET_SWITCHDEV
  29. + nss_dp_switchdev_remove(dp_priv->netdev);
  30. + #endif
  31. +
  32. dp_ops = dp_priv->data_plane_ops;
  33. hal_ops = dp_priv->gmac_hal_ops;
  34. --- a/nss_dp_switchdev.c
  35. +++ b/nss_dp_switchdev.c
  36. @@ -648,4 +648,17 @@ void nss_dp_switchdev_setup(struct net_d
  37. switch_init_done = true;
  38. }
  39. +
  40. +void nss_dp_switchdev_remove(struct net_device *dev)
  41. +{
  42. + if (!switch_init_done)
  43. + return;
  44. +
  45. + if (nss_dp_sw_ev_nb)
  46. + unregister_switchdev_notifier(nss_dp_sw_ev_nb);
  47. +
  48. + unregister_switchdev_blocking_notifier(&nss_dp_switchdev_notifier);
  49. +
  50. + switch_init_done = false;
  51. +}
  52. #endif