1d1365b1dbc3368d6e86cef5469c834fcd6d90cc
[oweals/openwrt.git] /
1 From 8e072168f75ebce85b96cbcefea2b10ddbd5913f Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Wed, 16 May 2018 14:11:59 +0200
4 Subject: [PATCH] brcmfmac: add support for sysfs initiated coredump
5
6 The driver already supports device coredump initiated by firmware
7 event. Since commit 3c47d19ff4dc ("drivers: base: add coredump driver
8 ops") it is also possible to initiate it from user-space through
9 sysfs. This patch adds support for SDIO and PCIe devices.
10
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  drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 1 +
18  drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h    | 2 ++
19  drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c   | 8 ++++++++
20  drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c   | 1 +
21  4 files changed, 12 insertions(+)
22
23 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
24 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
25 @@ -1299,6 +1299,9 @@ static struct sdio_driver brcmf_sdmmc_dr
26  #ifdef CONFIG_PM_SLEEP
27                 .pm = &brcmf_sdio_pm_ops,
28  #endif /* CONFIG_PM_SLEEP */
29 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
30 +               .coredump = brcmf_dev_coredump,
31 +#endif
32         },
33  };
34  
35 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
36 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
37 @@ -231,6 +231,8 @@ void brcmf_detach(struct device *dev);
38  void brcmf_dev_reset(struct device *dev);
39  /* Indication from bus module to change flow-control state */
40  void brcmf_txflowblock(struct device *dev, bool state);
41 +/* Request from bus module to initiate a coredump */
42 +void brcmf_dev_coredump(struct device *dev);
43  
44  /* Notify the bus has transferred the tx packet to firmware */
45  void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success);
46 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
47 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
48 @@ -1159,6 +1159,14 @@ void brcmf_dev_reset(struct device *dev)
49                 brcmf_fil_cmd_int_set(drvr->iflist[0], BRCMF_C_TERMINATED, 1);
50  }
51  
52 +void brcmf_dev_coredump(struct device *dev)
53 +{
54 +       struct brcmf_bus *bus_if = dev_get_drvdata(dev);
55 +
56 +       if (brcmf_debug_create_memdump(bus_if, NULL, 0) < 0)
57 +               brcmf_dbg(TRACE, "failed to create coredump\n");
58 +}
59 +
60  void brcmf_detach(struct device *dev)
61  {
62         s32 i;
63 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
64 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
65 @@ -1995,6 +1995,9 @@ static struct pci_driver brcmf_pciedrvr
66  #ifdef CONFIG_PM
67         .driver.pm = &brcmf_pciedrvr_pm,
68  #endif
69 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
70 +       .driver.coredump = brcmf_dev_coredump,
71 +#endif
72  };
73  
74