[Intel-gfx] [PATCH 1/9] drm/i915: Add i915 perf infrastructure

Chris Wilson chris at chris-wilson.co.uk
Wed Apr 20 22:41:20 UTC 2016


On Wed, Apr 20, 2016 at 03:23:06PM +0100, Robert Bragg wrote:
> +static struct intel_context *
> +lookup_context(struct drm_i915_private *dev_priv,
> +	       struct file *user_filp,
> +	       u32 ctx_user_handle)
> +{
> +	struct intel_context *ctx;
> +
> +	mutex_lock(&dev_priv->dev->struct_mutex);
> +	list_for_each_entry(ctx, &dev_priv->context_list, link) {
> +		struct drm_file *drm_file;
> +
> +		if (!ctx->file_priv)
> +			continue;
> +
> +		drm_file = ctx->file_priv->file;
> +
> +		if (user_filp->private_data == drm_file &&
> +		    ctx->user_handle == ctx_user_handle) {
> +			i915_gem_context_reference(ctx);
> +			mutex_unlock(&dev_priv->dev->struct_mutex);
> +
> +			return ctx;
> +		}
> +	}
> +	mutex_unlock(&dev_priv->dev->struct_mutex);
> +
> +	return NULL;
> +}
> +
> +int i915_perf_open_ioctl_locked(struct drm_device *dev,
> +				struct drm_i915_perf_open_param *param,
> +				struct perf_open_properties *props,
> +				struct drm_file *file)
> +{
> +	struct drm_i915_private *dev_priv = dev->dev_private;
> +	struct intel_context *specific_ctx = NULL;
> +	struct i915_perf_stream *stream = NULL;
> +	unsigned long f_flags = 0;
> +	int stream_fd;
> +	int ret = 0;
> +
> +	if (props->single_context) {
> +		u32 ctx_handle = props->ctx_handle;
> +
> +		specific_ctx = lookup_context(dev_priv, file->filp, ctx_handle);

i915_gem_context_get(file->driver_priv, ctx_handle) ?

Though this doesn't allow ptrace like ability to watch a context
elsewhere. For that you need to pass in fd:ctx props.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list