linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 1/2] brcmfmac: remove interface before notifying listener
@ 2016-06-18 18:18 Rafał Miłecki
  2016-06-18 18:18 ` [PATCH RFC 2/2] brcmfmac: support removing AP interfaces with "interface_remove" Rafał Miłecki
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Rafał Miłecki @ 2016-06-18 18:18 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Rafał Miłecki, Arend van Spriel, Franky Lin,
	Hante Meuleman, Pieter-Paul Giesberts, Franky (Zhenhui) Lin,
	open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
	open list:BROADCOM BRCM80211 IEEE802.11n WIRELESS DRIVER,
	open list:NETWORKING DRIVERS, open list

So far when receiving event about in-firmware-interface removal we were
notifying our listener and afterwards we were removing Linux interface.

This order was most likely a try to avoid a lockup. Removing in-firmware
interface could be requested by a driver code holding rtnl lock. Such
code waits for a corresponding event (still holding rtnl lock) which
prevents us from calling unregister_netdev. Notifying listener first
allowed it to release rtnl lock and removing interface succesfully.

Please note we couldn't switch to unregister_netdevice as interface
removal event could also occur in other (unpredictable) moments.

Unfortunately above workaround doesn't work in some corner cases. Focus
on the time slot between calling event handler and removing Linux
interface. During that time original caller may leave (unlocking rtnl
semaphore) *and* another call to the same code may be done (locking it
again). If that happens our event handler will stuck at removing Linux
interface, it won't handle another event and will block process holding
rtnl lock.

So the real solution is to remove interface before notifying listener.
We just need to know if rtnl is hold by a caller that triggered our
event.

Moreover this changes makes sure we call unregister_netdevice before
del_virtual_intf leaves which isn't critical but it makes a bit more of
sense to handle it this way.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
index 9da7a4c..5fd1886 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
@@ -18,6 +18,7 @@
 #include "brcmu_wifi.h"
 #include "brcmu_utils.h"
 
+#include "cfg80211.h"
 #include "core.h"
 #include "debug.h"
 #include "tracepoint.h"
@@ -180,10 +181,16 @@ static void brcmf_fweh_handle_if_event(struct brcmf_pub *drvr,
 	if (ifp && ifevent->action == BRCMF_E_IF_CHANGE)
 		brcmf_fws_reset_interface(ifp);
 
-	err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data);
+	if (ifp && ifevent->action == BRCMF_E_IF_DEL) {
+		bool rtnl_locked = brcmf_cfg80211_vif_event_armed(drvr->config);
+
+		brcmf_remove_interface(ifp, rtnl_locked);
+	}
 
-	if (ifp && ifevent->action == BRCMF_E_IF_DEL)
-		brcmf_remove_interface(ifp, false);
+	err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data);
+	if (err)
+		brcmf_err("event %d handler failed (%d)\n", emsg->event_code,
+			  err);
 }
 
 /**
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-07-08 13:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-18 18:18 [PATCH RFC 1/2] brcmfmac: remove interface before notifying listener Rafał Miłecki
2016-06-18 18:18 ` [PATCH RFC 2/2] brcmfmac: support removing AP interfaces with "interface_remove" Rafał Miłecki
2016-06-18 19:32   ` Arend van Spriel
2016-06-18 19:26 ` [PATCH RFC 1/2] brcmfmac: remove interface before notifying listener Arend van Spriel
2016-06-18 21:58   ` Rafał Miłecki
2016-06-18 22:42     ` Rafał Miłecki
2016-06-19 16:23 ` [PATCH V2 RFC 1/2] brcmfmac: delete interface directly in code that sent fw request Rafał Miłecki
2016-06-19 16:23   ` [PATCH V2 RFC 2/2] brcmfmac: support removing AP interfaces with "interface_remove" Rafał Miłecki
     [not found]   ` <1467230067-3302-1-git-send-email-zajec5@gmail.com>
2016-06-29 19:54     ` [PATCH 1/2] brcmfmac: delete interface directly in code that sent fw request Rafał Miłecki
2016-07-08 13:46       ` [1/2] " Kalle Valo
2016-06-29 19:54     ` [PATCH 2/2] brcmfmac: support removing AP interfaces with "interface_remove" Rafał Miłecki
2016-06-29 19:57     ` [PATCH 0/2] brcmfmac: support removing AP interfaces with new fw Rafał Miłecki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).