linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arend van Spriel <arend@broadcom.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>,
	Luciano Coelho <luca@coelho.fi>, Kalle Valo <kvalo@adurom.com>,
	<dri-devel@lists.freedesktop.org>,
	<linux-wireless@vger.kernel.org>
Subject: Re: [RFC v2] device coredump: add new device coredump class
Date: Mon, 8 Sep 2014 10:36:43 +0200	[thread overview]
Message-ID: <540D6A9B.5000008@broadcom.com> (raw)
In-Reply-To: <1409907054-17596-1-git-send-email-johannes@sipsolutions.net>

On 09/05/14 10:50, Johannes Berg wrote:
> From: Johannes Berg<johannes.berg@intel.com>
>
> Many devices run firmware and/or complex hardware, and most of that
> can have bugs. When it misbehaves, however, it is often much harder
> to debug than software running on the host.
>
> Introduce a "device coredump" mechanism to allow dumping internal
> device/firmware state through a generalized mechanism. As devices
> are different and information needed can vary accordingly, this
> doesn't prescribe a file format - it just provides mechanism to
> get data to be able to capture it in a generalized way (e.g. in
> distributions.)

Although it can be found in the patch it would not hurt to point out 
where the coredump can be found in sysfs in this patch description.

[...]

> +static struct class devcd_class = {
> +	.name		= "devcoredump",
> +	.owner		= THIS_MODULE,
> +	.dev_release	= devcd_dev_release,
> +	.dev_groups	= devcd_dev_groups,
> +};

[...]

> +/**
> + * dev_coredumpm - create firmware coredump with read/free methods
> + * @dev: the struct device for the crashed device
> + * @data: data cookie for the @read/@free functions
> + * @datalen: length of the data
> + * @gfp: allocation flags
> + * @read: function to read from the given buffer
> + * @free: function to free the given buffer
> + */
> +void dev_coredumpm(struct device *dev, struct module *owner,
> +		   const void *data, size_t datalen, gfp_t gfp,
> +		   ssize_t (*read)(char *buffer, loff_t offset, size_t count,
> +				   const void *data, size_t datalen),
> +		   void (*free)(const void *data))
> +{
> +	static atomic_t devcd_count = ATOMIC_INIT(0);
> +	struct devcd_entry *devcd;
> +	struct device *existing;
> +
> +	existing = class_find_device(&devcd_class, NULL, dev,
> +				     devcd_match_failing);
> +	if (existing) {
> +		put_device(existing);
> +		return;
> +	}
> +
> +	if (!try_module_get(owner))
> +		return;
> +
> +	devcd = kzalloc(sizeof(*devcd), gfp);
> +	if (!devcd)
> +		goto put_module;
> +
> +	devcd->owner = owner;
> +	devcd->data = data;
> +	devcd->datalen = datalen;
> +	devcd->read = read;
> +	devcd->free = free;
> +	devcd->failing_dev = get_device(dev);
> +
> +	device_initialize(&devcd->devcd_dev);
> +
> +	dev_set_name(&devcd->devcd_dev, "devcd%d",
> +		     atomic_inc_return(&devcd_count));
> +	devcd->devcd_dev.class =&devcd_class;
> +
> +	if (device_add(&devcd->devcd_dev))
> +		goto put_device;
> +
> +	if (sysfs_create_link(&devcd->devcd_dev.kobj,&dev->kobj,
> +			      "failing_device"))
> +		/* nothing - symlink will be missing */;
> +
> +	if (sysfs_create_link(&dev->kobj,&devcd->devcd_dev.kobj,
> +			      "dev_coredump"))
> +		/* nothing - symlink will be missing */;

The class is called "devcoredump" so you may want to be consistent here 
and get rid of the underscore.

Regards,
Arend

      parent reply	other threads:[~2014-09-08  8:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05  8:50 [RFC v2] device coredump: add new device coredump class Johannes Berg
2014-09-05  9:40 ` Jonas Gorski
2014-09-05  9:56   ` Johannes Berg
2014-09-05 22:13 ` Greg Kroah-Hartman
2014-09-07  9:37   ` Johannes Berg
2014-09-08  8:38   ` Johannes Berg
2014-09-12 16:40     ` Greg Kroah-Hartman
2014-09-07  7:42 ` Arik Nemtsov
2014-09-08  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=540D6A9B.5000008@broadcom.com \
    --to=arend@broadcom.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emmanuel.grumbach@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes@sipsolutions.net \
    --cc=kvalo@adurom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luca@coelho.fi \
    /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;
as well as URLs for NNTP newsgroup(s).