Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 562f5d45 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Create a unique name for the context



This will be used for communicating issues with this context to
userspace, so we want to identify the parent process and the individual
context. Note that the name isn't quite unique, it makes the presumption
of there only being a single device fd per process.

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20161028125858.23563-31-chris@chris-wilson.co.uk
parent 85e17f59
Loading
Loading
Loading
Loading
+2 −9
Original line number Original line Diff line number Diff line
@@ -631,17 +631,10 @@ static void print_request(struct seq_file *m,
			  struct drm_i915_gem_request *rq,
			  struct drm_i915_gem_request *rq,
			  const char *prefix)
			  const char *prefix)
{
{
	struct pid *pid = rq->ctx->pid;
	seq_printf(m, "%s%x [%x:%x] @ %d: %s\n", prefix,
	struct task_struct *task;

	rcu_read_lock();
	task = pid ? pid_task(pid, PIDTYPE_PID) : NULL;
	seq_printf(m, "%s%x [%x:%x] @ %d: %s [%d]\n", prefix,
		   rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno,
		   rq->global_seqno, rq->ctx->hw_id, rq->fence.seqno,
		   jiffies_to_msecs(jiffies - rq->emitted_jiffies),
		   jiffies_to_msecs(jiffies - rq->emitted_jiffies),
		   task ? task->comm : "<unknown>",
		   rq->timeline->common->name);
		   task ? task->pid : -1);
	rcu_read_unlock();
}
}


static int i915_gem_request_info(struct seq_file *m, void *data)
static int i915_gem_request_info(struct seq_file *m, void *data)
+1 −0
Original line number Original line Diff line number Diff line
@@ -937,6 +937,7 @@ struct i915_gem_context {
	struct drm_i915_file_private *file_priv;
	struct drm_i915_file_private *file_priv;
	struct i915_hw_ppgtt *ppgtt;
	struct i915_hw_ppgtt *ppgtt;
	struct pid *pid;
	struct pid *pid;
	const char *name;


	struct i915_ctx_hang_stats hang_stats;
	struct i915_ctx_hang_stats hang_stats;


+18 −5
Original line number Original line Diff line number Diff line
@@ -158,6 +158,7 @@ void i915_gem_context_free(struct kref *ctx_ref)
		__i915_gem_object_release_unless_active(ce->state->obj);
		__i915_gem_object_release_unless_active(ce->state->obj);
	}
	}


	kfree(ctx->name);
	put_pid(ctx->pid);
	put_pid(ctx->pid);
	list_del(&ctx->link);
	list_del(&ctx->link);


@@ -303,19 +304,28 @@ __create_hw_context(struct drm_device *dev,
	}
	}


	/* Default context will never have a file_priv */
	/* Default context will never have a file_priv */
	if (file_priv != NULL) {
	ret = DEFAULT_CONTEXT_HANDLE;
	if (file_priv) {
		ret = idr_alloc(&file_priv->context_idr, ctx,
		ret = idr_alloc(&file_priv->context_idr, ctx,
				DEFAULT_CONTEXT_HANDLE, 0, GFP_KERNEL);
				DEFAULT_CONTEXT_HANDLE, 0, GFP_KERNEL);
		if (ret < 0)
		if (ret < 0)
			goto err_out;
			goto err_out;
	} else
	}
		ret = DEFAULT_CONTEXT_HANDLE;
	ctx->user_handle = ret;


	ctx->file_priv = file_priv;
	ctx->file_priv = file_priv;
	if (file_priv)
	if (file_priv) {
		ctx->pid = get_task_pid(current, PIDTYPE_PID);
		ctx->pid = get_task_pid(current, PIDTYPE_PID);
		ctx->name = kasprintf(GFP_KERNEL, "%s[%d]/%x",
				      current->comm,
				      pid_nr(ctx->pid),
				      ctx->user_handle);
		if (!ctx->name) {
			ret = -ENOMEM;
			goto err_pid;
		}
	}


	ctx->user_handle = ret;
	/* NB: Mark all slices as needing a remap so that when the context first
	/* NB: Mark all slices as needing a remap so that when the context first
	 * loads it will restore whatever remap state already exists. If there
	 * loads it will restore whatever remap state already exists. If there
	 * is no remap info, it will be a NOP. */
	 * is no remap info, it will be a NOP. */
@@ -329,6 +339,9 @@ __create_hw_context(struct drm_device *dev,


	return ctx;
	return ctx;


err_pid:
	put_pid(ctx->pid);
	idr_remove(&file_priv->context_idr, ctx->user_handle);
err_out:
err_out:
	context_close(ctx);
	context_close(ctx);
	return ERR_PTR(ret);
	return ERR_PTR(ret);