mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arend van Spriel <aspriel@gmail.com>
To: Greg Koah Hartmann <gregkh@linuxfoundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Arend van Spriel <aspriel@gmail.com>
Subject: [RFC V2 3/3] brcmfmac: pcie: implement .coredump() driver callback
Date: Thu, 11 Jan 2018 09:36:39 +0100	[thread overview]
Message-ID: <1515659799-23521-4-git-send-email-aspriel@gmail.com> (raw)
In-Reply-To: <1515659799-23521-1-git-send-email-aspriel@gmail.com>

This implements the .coredump() driver callback obtaining binary data
from the device and using devcoredump function to expose it in sysfs.

Signed-off-by: Arend van Spriel <aspriel@gmail.com>
---
V2:
 - no changes
---
 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c    | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 3c87157..55d0d25 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -22,6 +22,7 @@
 #include <linux/interrupt.h>
 #include <linux/bcma/bcma.h>
 #include <linux/sched.h>
+#include <linux/devcoredump.h>
 #include <asm/unaligned.h>
 
 #include <soc.h>
@@ -1744,6 +1745,26 @@ static void brcmf_pcie_setup(struct device *dev, int ret,
 	device_release_driver(dev);
 }
 
+static int brcmf_pcie_dev_coredump(struct device *dev)
+{
+	struct brcmf_bus *bus_if = dev_get_drvdata(dev);
+	struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie;
+	struct brcmf_pciedev_info *devinfo = buspub->devinfo;
+	size_t len;
+	void *dump;
+
+	len = devinfo->ci->ramsize - devinfo->ci->srsize;
+	dump = vzalloc(len);
+	if (!dump)
+		return -ENOMEM;
+
+	brcmf_dbg(PCIE, "dump at 0x%08X: len=%zu\n", devinfo->ci->rambase, len);
+	brcmf_pcie_copy_dev_tomem(devinfo, devinfo->ci->rambase, dump, len);
+
+	dev_coredumpv(dev, dump, len, GFP_KERNEL);
+	return 0;
+}
+
 static int
 brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
@@ -2002,6 +2023,7 @@ static int brcmf_pcie_pm_leave_D3(struct device *dev)
 	.id_table = brcmf_pcie_devid_table,
 	.probe = brcmf_pcie_probe,
 	.remove = brcmf_pcie_remove,
+	.driver.coredump = brcmf_pcie_dev_coredump,
 #ifdef CONFIG_PM
 	.driver.pm = &brcmf_pciedrvr_pm,
 #endif
-- 
1.9.1

      parent reply	other threads:[~2018-01-11  8:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11  8:36 [PATCH V3 0/3] sysfs: allow user-space request for devcoredump Arend van Spriel
2018-01-11  8:36 ` [PATCH V3 1/3] sysfs: add attribute specification for /sysfs/devices/.../coredump Arend van Spriel
2018-01-11  8:36 ` [PATCH V3 2/3] drivers: base: add coredump driver ops Arend van Spriel
2018-01-11  8:36 ` Arend van Spriel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515659799-23521-4-git-send-email-aspriel@gmail.com \
    --to=aspriel@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®