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
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.
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>
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(+)
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,
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);
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);
52 +void brcmf_dev_coredump(struct device *dev)
54 + struct brcmf_bus *bus_if = dev_get_drvdata(dev);
56 + if (brcmf_debug_create_memdump(bus_if, NULL, 0) < 0)
57 + brcmf_dbg(TRACE, "failed to create coredump\n");
60 void brcmf_detach(struct device *dev)
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
67 .driver.pm = &brcmf_pciedrvr_pm,
69 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 16, 0)
70 + .driver.coredump = brcmf_dev_coredump,