352-0001-brcmfmac-delete-interface-directly-in-code-that-sent.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  2. Date: Wed, 29 Jun 2016 21:54:26 +0200
  3. Subject: [PATCH] brcmfmac: delete interface directly in code that sent fw
  4. request
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. So far when receiving event about in-firmware-interface removal our
  9. event worker was notifying listener and afterwards it was removing Linux
  10. interface.
  11. First of all it was resulting in slightly unexpected order. The listener
  12. (del_virtual_intf callback) was (usually) returning with success before
  13. we even called unregister_netdev(ice).
  14. Please note this couldn't be simply fixed by changing order of calls in
  15. brcmf_fweh_handle_if_event as unregistering interface earlier could free
  16. struct brcmf_if.
  17. Another problem of current implementation are possible lockups. Focus on
  18. the time slot between calling event handler and removing Linux
  19. interface. During that time original caller may leave (unlocking rtnl
  20. semaphore) *and* another call to the same code may be done (locking it
  21. again). If that happens our event handler will stuck at removing Linux
  22. interface, it won't handle another event and will block process holding
  23. rtnl lock.
  24. This can be simply solved by unregistering interface in a proper
  25. callback, right after receiving confirmation event from firmware. This
  26. only required modifying worker to don't unregister on its own if there
  27. is someone waiting for the event.
  28. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  29. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  30. ---
  31. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
  32. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
  33. @@ -18,6 +18,7 @@
  34. #include "brcmu_wifi.h"
  35. #include "brcmu_utils.h"
  36. +#include "cfg80211.h"
  37. #include "core.h"
  38. #include "debug.h"
  39. #include "tracepoint.h"
  40. @@ -182,8 +183,13 @@ static void brcmf_fweh_handle_if_event(s
  41. err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data);
  42. - if (ifp && ifevent->action == BRCMF_E_IF_DEL)
  43. - brcmf_remove_interface(ifp, false);
  44. + if (ifp && ifevent->action == BRCMF_E_IF_DEL) {
  45. + bool armed = brcmf_cfg80211_vif_event_armed(drvr->config);
  46. +
  47. + /* Default handling in case no-one waits for this event */
  48. + if (!armed)
  49. + brcmf_remove_interface(ifp, false);
  50. + }
  51. }
  52. /**
  53. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
  54. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
  55. @@ -2290,8 +2290,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiph
  56. else
  57. err = 0;
  58. }
  59. - if (err)
  60. - brcmf_remove_interface(vif->ifp, true);
  61. + brcmf_remove_interface(vif->ifp, true);
  62. brcmf_cfg80211_arm_vif_event(cfg, NULL);
  63. if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)