[Intel-gfx] [RFC 3/5] drm/i915: Update client name on context create

Chris Wilson chris at chris-wilson.co.uk
Fri Oct 25 14:39:56 UTC 2019


Quoting Tvrtko Ursulin (2019-10-25 15:21:29)
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 55f1f93c0925..c7f6684eb366 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -2084,6 +2084,8 @@ 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;
> +       pid_t pid = pid_nr(get_task_pid(current, PIDTYPE_PID));
> +       struct drm_i915_file_private *file_priv = file->driver_priv;
>         struct create_ext ext_data;
>         int ret;
>  
> @@ -2097,14 +2099,23 @@ 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;
>         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);
>                 return -EIO;
>         }
>  
> +       mutex_lock(&dev->struct_mutex);
> +       if (file_priv->client.pid != pid) {
> +               i915_gem_remove_client(file_priv);
> +               ret = i915_gem_add_client(i915, file_priv, current,
> +                                         file_priv->client.id);
> +       }
> +       mutex_unlock(&dev->struct_mutex);

You are serialising against multiple context_create_ioctl from the same
file, right? Could abuse fpriv->context_idr_lock. Or add a new one.

> +       if (ret)
> +               return ret;
> +

Hmm, is get_task_pid() the one that returns a reference to the pid_t?
Aye, it is, we need a put_pid().
-Chris


More information about the Intel-gfx mailing list