mac80211: brcmfmac: fix PCIe reset crash and WARNING lede-17.01
authorRafał Miłecki <rafal@milecki.pl>
Mon, 18 Nov 2019 13:45:59 +0000 (14:45 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Tue, 19 Nov 2019 05:51:15 +0000 (06:51 +0100)
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
(cherry picked from commit cde8c2f2fba019c4cd3b9f6ad463ff86cc783061)

package/kernel/mac80211/patches/359-v5.4-brcmfmac-don-t-net_ratelimit-CONSOLE-messages-on-fir.patch [new file with mode: 0644]
package/kernel/mac80211/patches/360-brcmfmac-disable-PCIe-interrupts-before-bus-reset.patch [new file with mode: 0644]
package/kernel/mac80211/patches/361-brcmfmac-remove-monitor-interface-when-detaching.patch [new file with mode: 0644]
package/kernel/mac80211/patches/470-v5.4-brcmfmac-don-t-net_ratelimit-CONSOLE-messages-on-fir.patch [deleted file]
package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch

diff --git a/package/kernel/mac80211/patches/359-v5.4-brcmfmac-don-t-net_ratelimit-CONSOLE-messages-on-fir.patch b/package/kernel/mac80211/patches/359-v5.4-brcmfmac-don-t-net_ratelimit-CONSOLE-messages-on-fir.patch
new file mode 100644 (file)
index 0000000..e7e2885
--- /dev/null
@@ -0,0 +1,38 @@
+From e3b1d879ccda9ffd5332777bb1beeb2cc913faa8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Sun, 21 Jul 2019 21:52:17 +0200
+Subject: [PATCH] brcmfmac: don't net_ratelimit() CONSOLE messages on firmware
+ crash
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Firmware crash is a pretty rare event and can't happen too frequently as
+it has to be followed by a hardware reinitialization and config reload.
+It should be safe to don't use net_ratelimit() when it happens.
+
+For reporting & debugging purposes it's important to provide a complete
+log as the last lines are actually the most important. This change
+modifies brcmfmac to print all messages in an unlimited way in that
+specific case. With this change there should be finally a backtrace of
+firmware finally visible after a crash.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+@@ -800,7 +800,8 @@ static void brcmf_pcie_bus_console_read(
+               if (ch == '\n') {
+                       console->log_str[console->log_idx] = 0;
+                       if (error)
+-                              brcmf_err(bus, "CONSOLE: %s", console->log_str);
++                              __brcmf_err(bus, __func__, "CONSOLE: %s",
++                                          console->log_str);
+                       else
+                               pr_debug("CONSOLE: %s", console->log_str);
+                       console->log_idx = 0;
diff --git a/package/kernel/mac80211/patches/360-brcmfmac-disable-PCIe-interrupts-before-bus-reset.patch b/package/kernel/mac80211/patches/360-brcmfmac-disable-PCIe-interrupts-before-bus-reset.patch
new file mode 100644 (file)
index 0000000..18cf218
--- /dev/null
@@ -0,0 +1,54 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Mon, 18 Nov 2019 11:52:41 +0100
+Subject: [PATCH FIX] brcmfmac: disable PCIe interrupts before bus reset
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Keeping interrupts on could result in brcmfmac freeing some resources
+and then IRQ handlers trying to use them. That was obviously a straight
+path for crashing a kernel.
+
+Example:
+CPU0                           CPU1
+----                           ----
+brcmf_pcie_reset
+  brcmf_pcie_bus_console_read
+  brcmf_detach
+    ...
+    brcmf_fweh_detach
+    brcmf_proto_detach
+                               brcmf_pcie_isr_thread
+                                 ...
+                                 brcmf_proto_msgbuf_rx_trigger
+                                   ...
+                                   drvr->proto->pd
+    brcmf_pcie_release_irq
+
+[  363.789218] Unable to handle kernel NULL pointer dereference at virtual address 00000038
+[  363.797339] pgd = c0004000
+[  363.800050] [00000038] *pgd=00000000
+[  363.803635] Internal error: Oops: 17 [#1] SMP ARM
+(...)
+[  364.029209] Backtrace:
+[  364.031725] [<bf243838>] (brcmf_proto_msgbuf_rx_trigger [brcmfmac]) from [<bf2471dc>] (brcmf_pcie_isr_thread+0x228/0x274 [brcmfmac])
+[  364.043662]  r7:00000001 r6:c8ca0000 r5:00010000 r4:c7b4f800
+
+Fixes: 4684997d9eea ("brcmfmac: reset PCIe bus on a firmware crash")
+Cc: stable@vger.kernel.org # v5.2+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+@@ -1409,6 +1409,8 @@ static int brcmf_pcie_reset(struct devic
+       u16 bus_nr;
+       int err;
++      brcmf_pcie_intr_disable(devinfo);
++
+       brcmf_pcie_bus_console_read(devinfo, true);
+       brcmf_detach(dev);
diff --git a/package/kernel/mac80211/patches/361-brcmfmac-remove-monitor-interface-when-detaching.patch b/package/kernel/mac80211/patches/361-brcmfmac-remove-monitor-interface-when-detaching.patch
new file mode 100644 (file)
index 0000000..28e3e2a
--- /dev/null
@@ -0,0 +1,30 @@
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Mon, 18 Nov 2019 13:35:20 +0100
+Subject: [PATCH 5.5] brcmfmac: remove monitor interface when detaching
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This fixes a minor WARNING in the cfg80211:
+[  130.658034] ------------[ cut here ]------------
+[  130.662805] WARNING: CPU: 1 PID: 610 at net/wireless/core.c:954 wiphy_unregister+0xb4/0x198 [cfg80211]
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -1320,6 +1320,11 @@ void brcmf_detach(struct device *dev)
+       brcmf_proto_detach(drvr);
+       brcmf_debug_detach(drvr);
++      if (drvr->mon_if) {
++              brcmf_net_detach(drvr->mon_if->ndev, false);
++              drvr->mon_if = NULL;
++      }
++
+       /* make sure primary interface removed last */
+       for (i = BRCMF_MAX_IFS - 1; i > -1; i--) {
+               if (drvr->iflist[i])
diff --git a/package/kernel/mac80211/patches/470-v5.4-brcmfmac-don-t-net_ratelimit-CONSOLE-messages-on-fir.patch b/package/kernel/mac80211/patches/470-v5.4-brcmfmac-don-t-net_ratelimit-CONSOLE-messages-on-fir.patch
deleted file mode 100644 (file)
index e7e2885..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-From e3b1d879ccda9ffd5332777bb1beeb2cc913faa8 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
-Date: Sun, 21 Jul 2019 21:52:17 +0200
-Subject: [PATCH] brcmfmac: don't net_ratelimit() CONSOLE messages on firmware
- crash
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Firmware crash is a pretty rare event and can't happen too frequently as
-it has to be followed by a hardware reinitialization and config reload.
-It should be safe to don't use net_ratelimit() when it happens.
-
-For reporting & debugging purposes it's important to provide a complete
-log as the last lines are actually the most important. This change
-modifies brcmfmac to print all messages in an unlimited way in that
-specific case. With this change there should be finally a backtrace of
-firmware finally visible after a crash.
-
-Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
-Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
----
- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
---- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
-+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
-@@ -800,7 +800,8 @@ static void brcmf_pcie_bus_console_read(
-               if (ch == '\n') {
-                       console->log_str[console->log_idx] = 0;
-                       if (error)
--                              brcmf_err(bus, "CONSOLE: %s", console->log_str);
-+                              __brcmf_err(bus, __func__, "CONSOLE: %s",
-+                                          console->log_str);
-                       else
-                               pr_debug("CONSOLE: %s", console->log_str);
-                       console->log_idx = 0;
index 4f31ae86b4a0ccd51149a42e709d01dd1e383faf..c39c2049dc23fa61f8775ef3e373567168e9b03b 100644 (file)
@@ -13,7 +13,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
 
 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
-@@ -1404,6 +1404,7 @@ int __init brcmf_core_init(void)
+@@ -1409,6 +1409,7 @@ int __init brcmf_core_init(void)
  {
        if (!schedule_work(&brcmf_driver_work))
                return -EBUSY;