Re: [PATCH] [v2] drm/i915/ppgtt: Never return a NULL context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ben Widawsky <benjamin.widawsky@xxxxxxxxx> writes:

> It makes all the code which calls into this function way too confusing.
>
> v2: Fix destroy IOCTL as well
>

callsite inside i915_gem_validate_context() and after it is called
in i915_gem_do_execbuffer() are still confusing as they seem to expect
NULL. Latter even tries to dig out error value from NULL.

-- Mika

> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72903
> Signed-off-by: Ben Widawsky <ben@xxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/i915_gem_context.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index a90a0a1..f3ac9a2 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -524,10 +524,16 @@ void i915_gem_context_close(struct drm_device *dev, struct drm_file *file)
>  struct i915_hw_context *
>  i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id)
>  {
> +	struct i915_hw_context *ctx;
> +
>  	if (!HAS_HW_CONTEXTS(file_priv->dev_priv->dev))
>  		return file_priv->private_default_ctx;
>  
> -	return (struct i915_hw_context *)idr_find(&file_priv->context_idr, id);
> +	ctx = (struct i915_hw_context *)idr_find(&file_priv->context_idr, id);
> +	if (!ctx)
> +		return ERR_PTR(-ENOENT);
> +
> +	return ctx;
>  }
>  
>  static inline int
> @@ -774,9 +780,9 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
>  		return ret;
>  
>  	ctx = i915_gem_context_get(file_priv, args->ctx_id);
> -	if (!ctx) {
> +	if (IS_ERR(ctx)) {
>  		mutex_unlock(&dev->struct_mutex);
> -		return -ENOENT;
> +		return PTR_ERR(ctx);
>  	}
>  
>  	idr_remove(&ctx->file_priv->context_idr, ctx->id);
> -- 
> 1.8.5.2
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux