e7f42630b806a504322680db260faf0c7a440894
[oweals/openwrt.git] /
1 From 66ab63fbb33bf367807e3e471231379dce6f8b8c 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 5/7] 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 ---
16  .../broadcom/brcm80211/brcmfmac/cfg80211.c    | 23 +++++++++++--------
17  1 file changed, 13 insertions(+), 10 deletions(-)
18
19 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
20 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
21 @@ -1286,17 +1286,21 @@ static void brcmf_link_down(struct brcmf
22  {
23         struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy);
24         struct brcmf_pub *drvr = cfg->pub;
25 +       bool bus_up = drvr->bus_if->state == BRCMF_BUS_UP;
26         s32 err = 0;
27  
28         brcmf_dbg(TRACE, "Enter\n");
29  
30         if (test_and_clear_bit(BRCMF_VIF_STATUS_CONNECTED, &vif->sme_state)) {
31 -               brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n");
32 -               err = brcmf_fil_cmd_data_set(vif->ifp,
33 -                                            BRCMF_C_DISASSOC, NULL, 0);
34 -               if (err) {
35 -                       bphy_err(drvr, "WLC_DISASSOC failed (%d)\n", err);
36 +               if (bus_up) {
37 +                       brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n");
38 +                       err = brcmf_fil_cmd_data_set(vif->ifp,
39 +                                                    BRCMF_C_DISASSOC, NULL, 0);
40 +                       if (err)
41 +                               bphy_err(drvr, "WLC_DISASSOC failed (%d)\n",
42 +                                        err);
43                 }
44 +
45                 if ((vif->wdev.iftype == NL80211_IFTYPE_STATION) ||
46                     (vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT))
47                         cfg80211_disconnected(vif->wdev.netdev, reason, NULL, 0,
48 @@ -1306,7 +1310,8 @@ static void brcmf_link_down(struct brcmf
49         clear_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status);
50         brcmf_btcoex_set_mode(vif, BRCMF_BTCOEX_ENABLED, 0);
51         if (vif->profile.use_fwsup != BRCMF_PROFILE_FWSUP_NONE) {
52 -               brcmf_set_pmk(vif->ifp, NULL, 0);
53 +               if (bus_up)
54 +                       brcmf_set_pmk(vif->ifp, NULL, 0);
55                 vif->profile.use_fwsup = BRCMF_PROFILE_FWSUP_NONE;
56         }
57         brcmf_dbg(TRACE, "Exit\n");
58 @@ -5004,18 +5009,16 @@ static int brcmf_cfg80211_get_channel(st
59         struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
60         struct net_device *ndev = wdev->netdev;
61         struct brcmf_pub *drvr = cfg->pub;
62 -       struct brcmf_if *ifp;
63         struct brcmu_chan ch;
64         enum nl80211_band band = 0;
65         enum nl80211_chan_width width = 0;
66         u32 chanspec;
67         int freq, err;
68  
69 -       if (!ndev)
70 +       if (!ndev || drvr->bus_if->state != BRCMF_BUS_UP)
71                 return -ENODEV;
72 -       ifp = netdev_priv(ndev);
73  
74 -       err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
75 +       err = brcmf_fil_iovar_int_get(netdev_priv(ndev), "chanspec", &chanspec);
76         if (err) {
77                 bphy_err(drvr, "chanspec failed (%d)\n", err);
78                 return err;