86533b95b61ea56ede37f2c030c124a26e1e52b2
[openwrt/staging/linusw.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 [rafal@milecki.pl: use LINUX_VERSION_CODE]
12 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
13 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
14 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
15 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
16 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
17 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
18 ---
19 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 1 +
20 drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 2 ++
21 drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 8 ++++++++
22 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 1 +
23 4 files changed, 12 insertions(+)
24
25 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
26 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
27 @@ -1165,6 +1165,9 @@ static struct sdio_driver brcmf_sdmmc_dr
28 #ifdef CONFIG_PM_SLEEP
29 .pm = &brcmf_sdio_pm_ops,
30 #endif /* CONFIG_PM_SLEEP */
31 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
32 + .coredump = brcmf_dev_coredump,
33 +#endif
34 },
35 };
36
37 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
38 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
39 @@ -250,6 +250,8 @@ int brcmf_attach(struct device *dev, str
40 void brcmf_detach(struct device *dev);
41 /* Indication from bus module that dongle should be reset */
42 void brcmf_dev_reset(struct device *dev);
43 +/* Request from bus module to initiate a coredump */
44 +void brcmf_dev_coredump(struct device *dev);
45
46 /* Configure the "global" bus state used by upper layers */
47 void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);
48 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
49 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
50 @@ -1201,6 +1201,14 @@ void brcmf_dev_reset(struct device *dev)
51 brcmf_fil_cmd_int_set(drvr->iflist[0], BRCMF_C_TERMINATED, 1);
52 }
53
54 +void brcmf_dev_coredump(struct device *dev)
55 +{
56 + struct brcmf_bus *bus_if = dev_get_drvdata(dev);
57 +
58 + if (brcmf_debug_create_memdump(bus_if, NULL, 0) < 0)
59 + brcmf_dbg(TRACE, "failed to create coredump\n");
60 +}
61 +
62 void brcmf_detach(struct device *dev)
63 {
64 s32 i;
65 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
66 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
67 @@ -2044,6 +2044,9 @@ static struct pci_driver brcmf_pciedrvr
68 #ifdef CONFIG_PM
69 .driver.pm = &brcmf_pciedrvr_pm,
70 #endif
71 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
72 + .driver.coredump = brcmf_dev_coredump,
73 +#endif
74 };
75
76