ceb85055d5e8e7883e39e89f4c309a352884e3ea
[openwrt/staging/dangole.git] /
1 From 47dd82e3d25e85a7c7c4e4b0eac9d297d1e5e2d4 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Sun, 28 Apr 2019 23:38:26 +0200
4 Subject: [PATCH] brcmfmac: print firmware messages after a firmware crash
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Normally firmware messages are printed with debugging enabled only. It's
10 a good idea as firmware may print a lot of messages that normal users
11 don't need to care about.
12
13 However, on firmware crash, it may be very helpful to log all recent
14 messages. There is almost always a backtrace available as well as rought
15 info on the latest actions/state.
16
17 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
18 Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
19 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
20 ---
21 .../broadcom/brcm80211/brcmfmac/pcie.c | 24 ++++++++++++++-----
22 1 file changed, 18 insertions(+), 6 deletions(-)
23
24 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
25 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
26 @@ -764,15 +764,22 @@ static void brcmf_pcie_bus_console_init(
27 console->base_addr, console->buf_addr, console->bufsize);
28 }
29
30 -
31 -static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo)
32 +/**
33 + * brcmf_pcie_bus_console_read - reads firmware messages
34 + *
35 + * @error: specifies if error has occurred (prints messages unconditionally)
36 + */
37 +static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo,
38 + bool error)
39 {
40 + struct pci_dev *pdev = devinfo->pdev;
41 + struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
42 struct brcmf_pcie_console *console;
43 u32 addr;
44 u8 ch;
45 u32 newidx;
46
47 - if (!BRCMF_FWCON_ON())
48 + if (!error && !BRCMF_FWCON_ON())
49 return;
50
51 console = &devinfo->shared.console;
52 @@ -796,7 +803,10 @@ static void brcmf_pcie_bus_console_read(
53 }
54 if (ch == '\n') {
55 console->log_str[console->log_idx] = 0;
56 - pr_debug("CONSOLE: %s", console->log_str);
57 + if (error)
58 + brcmf_err(bus, "CONSOLE: %s", console->log_str);
59 + else
60 + pr_debug("CONSOLE: %s", console->log_str);
61 console->log_idx = 0;
62 }
63 }
64 @@ -857,7 +867,7 @@ static irqreturn_t brcmf_pcie_isr_thread
65 &devinfo->pdev->dev);
66 }
67 }
68 - brcmf_pcie_bus_console_read(devinfo);
69 + brcmf_pcie_bus_console_read(devinfo, false);
70 if (devinfo->state == BRCMFMAC_PCIE_STATE_UP)
71 brcmf_pcie_intr_enable(devinfo);
72 devinfo->in_irq = false;
73 @@ -1426,6 +1436,8 @@ static int brcmf_pcie_reset(struct devic
74 struct brcmf_fw_request *fwreq;
75 int err;
76
77 + brcmf_pcie_bus_console_read(devinfo, true);
78 +
79 brcmf_detach(dev);
80
81 brcmf_pcie_release_irq(devinfo);
82 @@ -1818,7 +1830,7 @@ static void brcmf_pcie_setup(struct devi
83 if (brcmf_attach(&devinfo->pdev->dev, devinfo->settings) == 0)
84 return;
85
86 - brcmf_pcie_bus_console_read(devinfo);
87 + brcmf_pcie_bus_console_read(devinfo, false);
88
89 fail:
90 device_release_driver(dev);