747cf58b7b51913070b49e3d17084e7320c6c5c3
[openwrt/staging/ldir.git] /
1 From 1ac11ae949dd883854f4523ef8e3a32aabfd6256 Mon Sep 17 00:00:00 2001
2 From: Arend van Spriel <arend.vanspriel@broadcom.com>
3 Date: Thu, 11 Jul 2019 11:05:10 +0200
4 Subject: [PATCH] brcmfmac: avoid firmware commands when bus is down
5
6 Upon rmmod a few attempts are made to inform firmware, but there is
7 no point as the bus is down and these will fail. Avoid them to keep
8 the logs clean.
9
10 Reported-by: Stefan Wahren <stefan.wahren@i2se.com>
11 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
12 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
13 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
14 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
15 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
16 ---
17 .../broadcom/brcm80211/brcmfmac/cfg80211.c | 23 +++++++++++--------
18 1 file changed, 13 insertions(+), 10 deletions(-)
19
20 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
21 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
22 @@ -1286,17 +1286,21 @@ static void brcmf_link_down(struct brcmf
23 {
24 struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy);
25 struct brcmf_pub *drvr = cfg->pub;
26 + bool bus_up = drvr->bus_if->state == BRCMF_BUS_UP;
27 s32 err = 0;
28
29 brcmf_dbg(TRACE, "Enter\n");
30
31 if (test_and_clear_bit(BRCMF_VIF_STATUS_CONNECTED, &vif->sme_state)) {
32 - brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n");
33 - err = brcmf_fil_cmd_data_set(vif->ifp,
34 - BRCMF_C_DISASSOC, NULL, 0);
35 - if (err) {
36 - bphy_err(drvr, "WLC_DISASSOC failed (%d)\n", err);
37 + if (bus_up) {
38 + brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n");
39 + err = brcmf_fil_cmd_data_set(vif->ifp,
40 + BRCMF_C_DISASSOC, NULL, 0);
41 + if (err)
42 + bphy_err(drvr, "WLC_DISASSOC failed (%d)\n",
43 + err);
44 }
45 +
46 if ((vif->wdev.iftype == NL80211_IFTYPE_STATION) ||
47 (vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT))
48 cfg80211_disconnected(vif->wdev.netdev, reason, NULL, 0,
49 @@ -1306,7 +1310,8 @@ static void brcmf_link_down(struct brcmf
50 clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status);
51 brcmf_btcoex_set_mode(vif, BRCMF_BTCOEX_ENABLED, 0);
52 if (vif->profile.use_fwsup != BRCMF_PROFILE_FWSUP_NONE) {
53 - brcmf_set_pmk(vif->ifp, NULL, 0);
54 + if (bus_up)
55 + brcmf_set_pmk(vif->ifp, NULL, 0);
56 vif->profile.use_fwsup = BRCMF_PROFILE_FWSUP_NONE;
57 }
58 brcmf_dbg(TRACE, "Exit\n");
59 @@ -5004,18 +5009,16 @@ static int brcmf_cfg80211_get_channel(st
60 struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
61 struct net_device *ndev = wdev->netdev;
62 struct brcmf_pub *drvr = cfg->pub;
63 - struct brcmf_if *ifp;
64 struct brcmu_chan ch;
65 enum nl80211_band band = 0;
66 enum nl80211_chan_width width = 0;
67 u32 chanspec;
68 int freq, err;
69
70 - if (!ndev)
71 + if (!ndev || drvr->bus_if->state != BRCMF_BUS_UP)
72 return -ENODEV;
73 - ifp = netdev_priv(ndev);
74
75 - err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
76 + err = brcmf_fil_iovar_int_get(netdev_priv(ndev), "chanspec", &chanspec);
77 if (err) {
78 bphy_err(drvr, "chanspec failed (%d)\n", err);
79 return err;