351-0020-brcmfmac-fix-lockup-when-removing-P2P-interface-afte.patch 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. From b50ddfa8530e9b5f52e873fdd6ff04f327a88799 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  3. Date: Fri, 17 Jun 2016 12:29:21 +0200
  4. Subject: [PATCH] brcmfmac: fix lockup when removing P2P interface after event
  5. timeout
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. Removing P2P interface is handled by sending a proper request to the
  10. firmware. On success firmware triggers an event and driver's handler
  11. removes a matching interface.
  12. However on event timeout we remove interface directly from the cfg80211
  13. callback. Current code doesn't handle this case correctly as it always
  14. assumes rtnl to be unlocked.
  15. Fix it by adding an extra rtnl_locked parameter to functions and calling
  16. unregister_netdevice when needed.
  17. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  18. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  19. ---
  20. .../wireless/broadcom/brcm80211/brcmfmac/core.c | 29 +++++++++++++---------
  21. .../wireless/broadcom/brcm80211/brcmfmac/core.h | 2 +-
  22. .../wireless/broadcom/brcm80211/brcmfmac/fweh.c | 2 +-
  23. .../net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 4 +--
  24. 4 files changed, 21 insertions(+), 16 deletions(-)
  25. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  26. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  27. @@ -548,12 +548,16 @@ fail:
  28. return -EBADE;
  29. }
  30. -static void brcmf_net_detach(struct net_device *ndev)
  31. +static void brcmf_net_detach(struct net_device *ndev, bool rtnl_locked)
  32. {
  33. - if (ndev->reg_state == NETREG_REGISTERED)
  34. - unregister_netdev(ndev);
  35. - else
  36. + if (ndev->reg_state == NETREG_REGISTERED) {
  37. + if (rtnl_locked)
  38. + unregister_netdevice(ndev);
  39. + else
  40. + unregister_netdev(ndev);
  41. + } else {
  42. brcmf_cfg80211_free_netdev(ndev);
  43. + }
  44. }
  45. void brcmf_net_setcarrier(struct brcmf_if *ifp, bool on)
  46. @@ -651,7 +655,7 @@ struct brcmf_if *brcmf_add_if(struct brc
  47. brcmf_err("ERROR: netdev:%s already exists\n",
  48. ifp->ndev->name);
  49. netif_stop_queue(ifp->ndev);
  50. - brcmf_net_detach(ifp->ndev);
  51. + brcmf_net_detach(ifp->ndev, false);
  52. drvr->iflist[bsscfgidx] = NULL;
  53. } else {
  54. brcmf_dbg(INFO, "netdev:%s ignore IF event\n",
  55. @@ -699,7 +703,8 @@ struct brcmf_if *brcmf_add_if(struct brc
  56. return ifp;
  57. }
  58. -static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx)
  59. +static void brcmf_del_if(struct brcmf_pub *drvr, s32 bsscfgidx,
  60. + bool rtnl_locked)
  61. {
  62. struct brcmf_if *ifp;
  63. @@ -729,7 +734,7 @@ static void brcmf_del_if(struct brcmf_pu
  64. cancel_work_sync(&ifp->multicast_work);
  65. cancel_work_sync(&ifp->ndoffload_work);
  66. }
  67. - brcmf_net_detach(ifp->ndev);
  68. + brcmf_net_detach(ifp->ndev, rtnl_locked);
  69. } else {
  70. /* Only p2p device interfaces which get dynamically created
  71. * end up here. In this case the p2p module should be informed
  72. @@ -743,14 +748,14 @@ static void brcmf_del_if(struct brcmf_pu
  73. }
  74. }
  75. -void brcmf_remove_interface(struct brcmf_if *ifp)
  76. +void brcmf_remove_interface(struct brcmf_if *ifp, bool rtnl_locked)
  77. {
  78. if (!ifp || WARN_ON(ifp->drvr->iflist[ifp->bsscfgidx] != ifp))
  79. return;
  80. brcmf_dbg(TRACE, "Enter, bsscfgidx=%d, ifidx=%d\n", ifp->bsscfgidx,
  81. ifp->ifidx);
  82. brcmf_fws_del_interface(ifp);
  83. - brcmf_del_if(ifp->drvr, ifp->bsscfgidx);
  84. + brcmf_del_if(ifp->drvr, ifp->bsscfgidx, rtnl_locked);
  85. }
  86. #ifdef CONFIG_INET
  87. @@ -1057,9 +1062,9 @@ fail:
  88. brcmf_fws_deinit(drvr);
  89. }
  90. if (ifp)
  91. - brcmf_net_detach(ifp->ndev);
  92. + brcmf_net_detach(ifp->ndev, false);
  93. if (p2p_ifp)
  94. - brcmf_net_detach(p2p_ifp->ndev);
  95. + brcmf_net_detach(p2p_ifp->ndev, false);
  96. drvr->iflist[0] = NULL;
  97. drvr->iflist[1] = NULL;
  98. if (drvr->settings->ignore_probe_fail)
  99. @@ -1128,7 +1133,7 @@ void brcmf_detach(struct device *dev)
  100. /* make sure primary interface removed last */
  101. for (i = BRCMF_MAX_IFS-1; i > -1; i--)
  102. - brcmf_remove_interface(drvr->iflist[i]);
  103. + brcmf_remove_interface(drvr->iflist[i], false);
  104. brcmf_cfg80211_detach(drvr->config);
  105. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
  106. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
  107. @@ -216,7 +216,7 @@ struct brcmf_if *brcmf_get_ifp(struct br
  108. int brcmf_net_attach(struct brcmf_if *ifp, bool rtnl_locked);
  109. struct brcmf_if *brcmf_add_if(struct brcmf_pub *drvr, s32 bsscfgidx, s32 ifidx,
  110. bool is_p2pdev, char *name, u8 *mac_addr);
  111. -void brcmf_remove_interface(struct brcmf_if *ifp);
  112. +void brcmf_remove_interface(struct brcmf_if *ifp, bool rtnl_locked);
  113. void brcmf_txflowblock_if(struct brcmf_if *ifp,
  114. enum brcmf_netif_stop_reason reason, bool state);
  115. void brcmf_txfinalize(struct brcmf_if *ifp, struct sk_buff *txp, bool success);
  116. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
  117. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
  118. @@ -183,7 +183,7 @@ static void brcmf_fweh_handle_if_event(s
  119. err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data);
  120. if (ifp && ifevent->action == BRCMF_E_IF_DEL)
  121. - brcmf_remove_interface(ifp);
  122. + brcmf_remove_interface(ifp, false);
  123. }
  124. /**
  125. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
  126. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
  127. @@ -2289,7 +2289,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiph
  128. err = 0;
  129. }
  130. if (err)
  131. - brcmf_remove_interface(vif->ifp);
  132. + brcmf_remove_interface(vif->ifp, true);
  133. brcmf_cfg80211_arm_vif_event(cfg, NULL);
  134. if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
  135. @@ -2395,7 +2395,7 @@ void brcmf_p2p_detach(struct brcmf_p2p_i
  136. if (vif != NULL) {
  137. brcmf_p2p_cancel_remain_on_channel(vif->ifp);
  138. brcmf_p2p_deinit_discovery(p2p);
  139. - brcmf_remove_interface(vif->ifp);
  140. + brcmf_remove_interface(vif->ifp, false);
  141. }
  142. /* just set it all to zero */
  143. memset(p2p, 0, sizeof(*p2p));