595b8948c71541bab6dfaa564bfd8a09f5f66faa
[openwrt/staging/dangole.git] /
1 From a2ec87ddbf1637f854ffcfff9d12d392fa30758b Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Tue, 26 Feb 2019 14:11:18 +0100
4 Subject: [PATCH] brcmfmac: add a function designated for handling firmware
5 fails
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 This improves handling PCIe firmware halts by printing a clear error
11 message and replaces a similar code in the SDIO bus support.
12
13 It will also allow further improvements like trying to recover from a
14 firmware crash.
15
16 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
17 Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
18 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
19 ---
20 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 2 ++
21 .../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 10 ++++++++++
22 .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 2 +-
23 .../net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 4 ++--
24 4 files changed, 15 insertions(+), 3 deletions(-)
25
26 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
27 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
28 @@ -262,6 +262,8 @@ void brcmf_detach(struct device *dev);
29 void brcmf_dev_reset(struct device *dev);
30 /* Request from bus module to initiate a coredump */
31 void brcmf_dev_coredump(struct device *dev);
32 +/* Indication that firmware has halted or crashed */
33 +void brcmf_fw_crashed(struct device *dev);
34
35 /* Configure the "global" bus state used by upper layers */
36 void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);
37 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
38 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
39 @@ -1294,6 +1294,16 @@ void brcmf_dev_coredump(struct device *d
40 brcmf_dbg(TRACE, "failed to create coredump\n");
41 }
42
43 +void brcmf_fw_crashed(struct device *dev)
44 +{
45 + struct brcmf_bus *bus_if = dev_get_drvdata(dev);
46 + struct brcmf_pub *drvr = bus_if->drvr;
47 +
48 + bphy_err(drvr, "Firmware has halted or crashed\n");
49 +
50 + brcmf_dev_coredump(dev);
51 +}
52 +
53 void brcmf_detach(struct device *dev)
54 {
55 s32 i;
56 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
57 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
58 @@ -730,7 +730,7 @@ static void brcmf_pcie_handle_mb_data(st
59 }
60 if (dtoh_mb_data & BRCMF_D2H_DEV_FWHALT) {
61 brcmf_dbg(PCIE, "D2H_MB_DATA: FW HALT\n");
62 - brcmf_dev_coredump(&devinfo->pdev->dev);
63 + brcmf_fw_crashed(&devinfo->pdev->dev);
64 }
65 }
66
67 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
68 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
69 @@ -1090,8 +1090,8 @@ static u32 brcmf_sdio_hostmail(struct br
70
71 /* dongle indicates the firmware has halted/crashed */
72 if (hmb_data & HMB_DATA_FWHALT) {
73 - brcmf_err("mailbox indicates firmware halted\n");
74 - brcmf_dev_coredump(&sdiod->func1->dev);
75 + brcmf_dbg(SDIO, "mailbox indicates firmware halted\n");
76 + brcmf_fw_crashed(&sdiod->func1->dev);
77 }
78
79 /* Dongle recomposed rx frames, accept them again */