[Intel-gfx] [PATCH 3/5] drm/i915: Update client name on context create
Chris Wilson
chris at chris-wilson.co.uk
Mon Dec 16 12:57:13 UTC 2019
Quoting Tvrtko Ursulin (2019-12-16 12:07:02)
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 46b4d1d643f8..cd4ba6486f35 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -2178,7 +2178,9 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
> {
> struct drm_i915_private *i915 = to_i915(dev);
> struct drm_i915_gem_context_create_ext *args = data;
> + struct drm_i915_file_private *file_priv = file->driver_priv;
> struct create_ext ext_data;
> + struct pid *pid;
> int ret;
>
> if (!DRIVER_CAPS(i915)->has_logical_contexts)
> @@ -2191,14 +2193,30 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
> if (ret)
> return ret;
>
> - ext_data.fpriv = file->driver_priv;
> + ext_data.fpriv = file_priv;
> + pid = get_task_pid(current, PIDTYPE_PID);
> if (client_is_banned(ext_data.fpriv)) {
> DRM_DEBUG("client %s[%d] banned from creating ctx\n",
> - current->comm,
> - pid_nr(get_task_pid(current, PIDTYPE_PID)));
> + current->comm, pid_nr(pid));
> + put_pid(pid);
> return -EIO;
> }
>
> + /*
> + * Borrow the context idr_lock to protect the client remove-add cycle.
> + */
> + if (mutex_lock_interruptible(&file_priv->context_idr_lock))
put_pid(pid); /* I'm helping! */
> + return -EINTR;
> + if (pid_nr(file_priv->client.pid) != pid_nr(pid)) {
> + i915_gem_remove_client(file_priv);
> + ret = i915_gem_add_client(i915, file_priv, current,
> + file_priv->client.id);
> + }
> + mutex_unlock(&file_priv->context_idr_lock);
> + put_pid(pid);
> + if (ret)
> + return ret;
More information about the Intel-gfx
mailing list