From: Daniel Vetter <daniel@ffwll.ch>
To: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 4/4] drm/i915: add i915_error_state sysfs entry
Date: Thu, 6 Jun 2013 14:24:14 +0200 [thread overview]
Message-ID: <20130606122414.GE7827@phenom.ffwll.local> (raw)
In-Reply-To: <1370521122-20268-4-git-send-email-mika.kuoppala@intel.com>
On Thu, Jun 06, 2013 at 03:18:42PM +0300, Mika Kuoppala wrote:
> As getting error state doesn't anymore require big kmallocs,
> make error state accessible also from sysfs.
>
> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/i915_sysfs.c | 49 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
> index 6875b56..d4c754b 100644
> --- a/drivers/gpu/drm/i915/i915_sysfs.c
> +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> @@ -409,6 +409,49 @@ static const struct attribute *gen6_attrs[] = {
> NULL,
> };
>
> +static ssize_t error_state_read(struct file *filp, struct kobject *kobj,
> + struct bin_attribute *attr, char *buf,
> + loff_t off, size_t count)
> +{
> +
> + struct device *kdev = container_of(kobj, struct device, kobj);
> + struct drm_minor *minor = container_of(kdev, struct drm_minor, kdev);
> + struct drm_device *dev = minor->dev;
> + struct i915_error_state_file_priv error_priv;
> + struct drm_i915_error_state_buf error_str;
> + ssize_t ret_count = 0;
> + int ret;
> +
> + memset(&error_priv, 0, sizeof(error_priv));
> +
> + ret = i915_error_state_buf_init(&error_str, count, off);
> + if (ret)
> + return ret;
> +
> + error_priv.dev = dev;
> + i915_error_state_get(dev, &error_priv);
> +
> + ret = i915_error_state_to_str(&error_str, &error_priv);
> + if (ret)
> + goto out;
> +
> + ret_count = count < error_str.bytes ? count : error_str.bytes;
> +
> + memcpy(buf, error_str.buf, ret_count);
> +out:
> + i915_error_state_buf_release(&error_str);
> + i915_error_state_put(&error_priv);
> +
> + return ret ?: ret_count;
> +}
> +
> +static struct bin_attribute error_state_attr = {
> + .attr.name = "i915_error_state",
> + .attr.mode = 0444,
Error state could easily leak sensitive information, so I think we should
only allow root to read it. Also maybe a new name for it, i915_ is kinda
meh ... I vote for gpu_error_state.
-Daniel
> + .size = 0,
> + .read = error_state_read,
> +};
> +
> void i915_setup_sysfs(struct drm_device *dev)
> {
> int ret;
> @@ -432,10 +475,16 @@ void i915_setup_sysfs(struct drm_device *dev)
> if (ret)
> DRM_ERROR("gen6 sysfs setup failed\n");
> }
> +
> + ret = sysfs_create_bin_file(&dev->primary->kdev.kobj,
> + &error_state_attr);
> + if (ret)
> + DRM_ERROR("error_state sysfs setup failed\n");
> }
>
> void i915_teardown_sysfs(struct drm_device *dev)
> {
> + sysfs_remove_bin_file(&dev->primary->kdev.kobj, &error_state_attr);
> sysfs_remove_files(&dev->primary->kdev.kobj, gen6_attrs);
> device_remove_bin_file(&dev->primary->kdev, &dpf_attrs);
> #ifdef CONFIG_PM
> --
> 1.7.9.5
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
next prev parent reply other threads:[~2013-06-06 12:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 12:18 [PATCH 1/4] drm/i915: export error state to string conversion Mika Kuoppala
2013-06-06 12:18 ` [PATCH 2/4] drm/i915: export error state ref handling Mika Kuoppala
2013-06-06 12:18 ` [PATCH 3/4] drm/i915: introduce i915_error_state_buf_init Mika Kuoppala
2013-06-06 12:18 ` [PATCH 4/4] drm/i915: add i915_error_state sysfs entry Mika Kuoppala
2013-06-06 12:22 ` Chris Wilson
2013-06-06 12:24 ` Daniel Vetter [this message]
2013-06-06 13:33 ` [PATCH 4/4] drm/i915: add error_state " Mika Kuoppala
2013-06-06 13:48 ` Chris Wilson
2013-06-06 14:38 ` Mika Kuoppala
2013-07-01 16:19 ` Chris Wilson
2013-07-01 16:56 ` Daniel Vetter
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=20130606122414.GE7827@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mika.kuoppala@linux.intel.com \
/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