diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-05-24 09:53:39 -0400 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-05-24 10:29:27 -0400 |
commit | d28b99ab8c812a582469f04a698081d495e4bd8f (patch) | |
tree | cc02ca845673706409a6cd5a28ef7a900074811e | |
parent | c6aab9161a0343e63f44043cf22b6d67a3250143 (diff) |
drm/i915: Show i915_gem_context owner in debugfs
Print the context's owner (via the pid under file_priv) under debugfs.
In doing so, we must be careful that the filp is not accessed after it
is freed (notified via i915_gem_context_close).
v2: Mark the file_priv as closed.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1464098023-3294-6-git-send-email-chris@chris-wilson.co.uk
-rw-r--r-- | drivers/gpu/drm/i915/i915_debugfs.c | 18 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_context.c | 3 |
2 files changed, 18 insertions, 3 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 424e11efa3e1..05b9e5e0ee10 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -2014,9 +2014,23 @@ static int i915_context_status(struct seq_file *m, void *unused) | |||
2014 | continue; | 2014 | continue; |
2015 | 2015 | ||
2016 | seq_printf(m, "HW context %u ", ctx->hw_id); | 2016 | seq_printf(m, "HW context %u ", ctx->hw_id); |
2017 | if (IS_ERR(ctx->file_priv)) { | ||
2018 | seq_puts(m, "(deleted) "); | ||
2019 | } else if (ctx->file_priv) { | ||
2020 | struct pid *pid = ctx->file_priv->file->pid; | ||
2021 | struct task_struct *task; | ||
2022 | |||
2023 | task = get_pid_task(pid, PIDTYPE_PID); | ||
2024 | if (task) { | ||
2025 | seq_printf(m, "(%s [%d]) ", | ||
2026 | task->comm, task->pid); | ||
2027 | put_task_struct(task); | ||
2028 | } | ||
2029 | } else { | ||
2030 | seq_puts(m, "(kernel) "); | ||
2031 | } | ||
2032 | |||
2017 | describe_ctx(m, ctx); | 2033 | describe_ctx(m, ctx); |
2018 | if (ctx == dev_priv->kernel_context) | ||
2019 | seq_printf(m, "(kernel context) "); | ||
2020 | 2034 | ||
2021 | if (i915.enable_execlists) { | 2035 | if (i915.enable_execlists) { |
2022 | seq_putc(m, '\n'); | 2036 | seq_putc(m, '\n'); |
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 104d4819aca8..8d8c79b88816 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -468,6 +468,7 @@ static int context_idr_cleanup(int id, void *p, void *data) | |||
468 | { | 468 | { |
469 | struct i915_gem_context *ctx = p; | 469 | struct i915_gem_context *ctx = p; |
470 | 470 | ||
471 | ctx->file_priv = ERR_PTR(-EBADF); | ||
471 | i915_gem_context_unreference(ctx); | 472 | i915_gem_context_unreference(ctx); |
472 | return 0; | 473 | return 0; |
473 | } | 474 | } |
@@ -938,7 +939,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, | |||
938 | return PTR_ERR(ctx); | 939 | return PTR_ERR(ctx); |
939 | } | 940 | } |
940 | 941 | ||
941 | idr_remove(&ctx->file_priv->context_idr, ctx->user_handle); | 942 | idr_remove(&file_priv->context_idr, ctx->user_handle); |
942 | i915_gem_context_unreference(ctx); | 943 | i915_gem_context_unreference(ctx); |
943 | mutex_unlock(&dev->struct_mutex); | 944 | mutex_unlock(&dev->struct_mutex); |
944 | 945 | ||