[Intel-gfx] [PATCH 4/4] drm/i915: add error_state sysfs entry
Chris Wilson
chris at chris-wilson.co.uk
Thu Jun 6 15:48:53 CEST 2013
On Thu, Jun 06, 2013 at 04:33:06PM +0300, Mika Kuoppala wrote:
> As getting error state doesn't anymore require big kmallocs,
> make error state accessible also from sysfs.
>
> v2: - error state clearing (Chris Wilson)
> - user hint, proper access mode bits and name (Daniel Vetter)
>
> Suggested-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> Signed-off-by: Mika Kuoppala <mika.kuoppala at intel.com>
> ---
> +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);
Not quite oniony enough.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list