diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2019-03-21 14:07:10 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2019-03-21 15:59:29 +0000 |
commit | 3e05531243d032bbff157999c99a30a969966927 (patch) | |
tree | 0582457f13123890b397e472aa4e49d44d317664 /drivers/gpu/drm/i915/i915_gem_context.c | |
parent | 7dc40713618c884bf07c030d1ab1f47a9dc1f310 (diff) |
drm/i915: Stop storing ctx->user_handle
The user_handle need only be known by userspace for it to lookup the
context via the idr; internally we have no use for it.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190321140711.11190-3-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_context.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_context.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 9c6987ee27e5..9187910391d8 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -602,20 +602,15 @@ static int gem_context_register(struct i915_gem_context *ctx, /* And finally expose ourselves to userspace via the idr */ mutex_lock(&fpriv->context_idr_lock); - ret = idr_alloc(&fpriv->context_idr, ctx, - DEFAULT_CONTEXT_HANDLE, 0, GFP_KERNEL); - if (ret >= 0) - ctx->user_handle = ret; + ret = idr_alloc(&fpriv->context_idr, ctx, 0, 0, GFP_KERNEL); mutex_unlock(&fpriv->context_idr_lock); - if (ret < 0) - goto err_name; - - return 0; + if (ret >= 0) + goto out; -err_name: kfree(fetch_and_zero(&ctx->name)); err_pid: put_pid(fetch_and_zero(&ctx->pid)); +out: return ret; } @@ -638,11 +633,11 @@ int i915_gem_context_open(struct drm_i915_private *i915, } err = gem_context_register(ctx, file_priv); - if (err) + if (err < 0) goto err_ctx; - GEM_BUG_ON(ctx->user_handle != DEFAULT_CONTEXT_HANDLE); GEM_BUG_ON(i915_gem_context_is_kernel(ctx)); + GEM_BUG_ON(err > 0); return 0; @@ -852,10 +847,10 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data, return PTR_ERR(ctx); ret = gem_context_register(ctx, file_priv); - if (ret) + if (ret < 0) goto err_ctx; - args->ctx_id = ctx->user_handle; + args->ctx_id = ret; DRM_DEBUG("HW context %d created\n", args->ctx_id); return 0; @@ -877,7 +872,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, if (args->pad != 0) return -EINVAL; - if (args->ctx_id == DEFAULT_CONTEXT_HANDLE) + if (!args->ctx_id) return -ENOENT; if (mutex_lock_interruptible(&file_priv->context_idr_lock)) |