[Intel-gfx] [PATCH 3/3] drm/i915: Grab gpu state through debugfs
Daniel Vetter
daniel at ffwll.ch
Fri Oct 24 10:57:28 CEST 2014
On Thu, Oct 23, 2014 at 08:35:24PM +0300, Mika Kuoppala wrote:
> because it is handy to direct bug reporters to do things like:
> 'grep -i suspend /sys/kernel/debug/dri/0/i915_gpu_state'
>
> Signed-off-by: Mika Kuoppala <mika.kuoppala at intel.com>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 42 +++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/i915/i915_drv.h | 4 ++++
> drivers/gpu/drm/i915/i915_gpu_error.c | 22 ++++++++++++++----
> 3 files changed, 64 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index e60d5c2..8d3266d 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -976,6 +976,47 @@ static const struct file_operations i915_error_state_fops = {
> .release = i915_error_state_release,
> };
>
> +static int i915_gpu_state_open(struct inode *inode, struct file *file)
> +{
> + struct drm_device *dev = inode->i_private;
> + struct i915_error_state_file_priv *gpu_priv;
> +
> + gpu_priv = kzalloc(sizeof(*gpu_priv), GFP_KERNEL);
> + if (!gpu_priv)
> + return -ENOMEM;
> +
> + gpu_priv->dev = dev;
> +
> + gpu_priv->error = i915_capture_gpu_state(dev);
> + if (gpu_priv->error == NULL) {
> + kfree(gpu_priv);
> + return -ENOMEM;
> + }
> +
> + file->private_data = gpu_priv;
> +
> + return 0;
> +}
> +
> +static int i915_gpu_state_release(struct inode *inode, struct file *file)
> +{
> + struct i915_error_state_file_priv *gpu_priv = file->private_data;
> +
> + kref_put(&gpu_priv->error->ref, i915_gpu_state_free);
> + kfree(gpu_priv);
> +
> + return 0;
> +}
> +
> +static const struct file_operations i915_gpu_state_fops = {
> + .owner = THIS_MODULE,
> + .open = i915_gpu_state_open,
> + .read = i915_error_state_read,
> + .write = NULL,
> + .llseek = default_llseek,
> + .release = i915_gpu_state_release,
> +};
> +
> static int
> i915_next_seqno_get(void *data, u64 *val)
> {
> @@ -4217,6 +4258,7 @@ static const struct i915_debugfs_files {
> {"i915_ring_test_irq", &i915_ring_test_irq_fops},
> {"i915_gem_drop_caches", &i915_drop_caches_fops},
> {"i915_error_state", &i915_error_state_fops},
> + {"i915_gpu_state", &i915_gpu_state_fops},
> {"i915_next_seqno", &i915_next_seqno_fops},
> {"i915_display_crc_ctl", &i915_display_crc_ctl_fops},
> {"i915_pri_wm_latency", &i915_pri_wm_latency_fops},
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 23e7f20..cbefc64 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2756,6 +2756,10 @@ static inline void i915_error_state_buf_release(
> {
> kfree(eb->buf);
> }
> +
> +struct drm_i915_error_state *i915_capture_gpu_state(struct drm_device *dev);
> +void i915_gpu_state_free(struct kref *error_ref);
> +
> void i915_capture_error_state(struct drm_device *dev, bool wedge,
> const char *error_msg);
> void i915_error_state_get(struct drm_device *dev,
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
> index c11882a..76211b5 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -538,7 +538,7 @@ static void i915_error_object_free(struct drm_i915_error_object *obj)
> kfree(obj);
> }
>
> -static void i915_error_state_free(struct kref *error_ref)
> +void i915_gpu_state_free(struct kref *error_ref)
> {
> struct drm_i915_error_state *error = container_of(error_ref,
> typeof(*error), ref);
> @@ -1291,6 +1291,20 @@ __i915_capture_gpu_state(struct drm_device *dev)
> return error;
> }
>
> +struct drm_i915_error_state *i915_capture_gpu_state(struct drm_device *dev)
kerneldoc for this new non-static function is missing.
-Daniel
> +{
> + struct drm_i915_error_state *gpu_state;
> +
> + gpu_state = __i915_capture_gpu_state(dev);
> + if (gpu_state == NULL)
> + return NULL;
> +
> + scnprintf(gpu_state->error_msg, sizeof(gpu_state->error_msg),
> + "GPU state snapshot\n");
> +
> + return gpu_state;
> +}
> +
> /**
> * i915_capture_error_state - capture an error record for later analysis
> * @dev: drm device
> @@ -1323,7 +1337,7 @@ void i915_capture_error_state(struct drm_device *dev, bool wedged,
> spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
>
> if (error) {
> - i915_error_state_free(&error->ref);
> + i915_gpu_state_free(&error->ref);
> return;
> }
>
> @@ -1353,7 +1367,7 @@ void i915_error_state_get(struct drm_device *dev,
> void i915_error_state_put(struct i915_error_state_file_priv *error_priv)
> {
> if (error_priv->error)
> - kref_put(&error_priv->error->ref, i915_error_state_free);
> + kref_put(&error_priv->error->ref, i915_gpu_state_free);
> }
>
> void i915_destroy_error_state(struct drm_device *dev)
> @@ -1367,7 +1381,7 @@ void i915_destroy_error_state(struct drm_device *dev)
> spin_unlock_irq(&dev_priv->gpu_error.lock);
>
> if (error)
> - kref_put(&error->ref, i915_error_state_free);
> + kref_put(&error->ref, i915_gpu_state_free);
> }
>
> const char *i915_cache_level_str(struct drm_i915_private *i915, int type)
> --
> 1.9.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at 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
More information about the Intel-gfx
mailing list