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