Commit 046d1660 authored by Jason Ekstrand's avatar Jason Ekstrand Committed by Daniel Vetter

drm/i915/gem: Return an error ptr from context_lookup

We're about to start doing lazy context creation which means contexts
get created in i915_gem_context_lookup and we may start having more
errors than -ENOENT.
Signed-off-by: default avatarJason Ekstrand <jason@jlekstrand.net>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210708154835.528166-23-jason@jlekstrand.net
parent d4433c76
...@@ -2636,8 +2636,8 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data, ...@@ -2636,8 +2636,8 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,
int ret = 0; int ret = 0;
ctx = i915_gem_context_lookup(file_priv, args->ctx_id); ctx = i915_gem_context_lookup(file_priv, args->ctx_id);
if (!ctx) if (IS_ERR(ctx))
return -ENOENT; return PTR_ERR(ctx);
switch (args->param) { switch (args->param) {
case I915_CONTEXT_PARAM_GTT_SIZE: case I915_CONTEXT_PARAM_GTT_SIZE:
...@@ -2705,8 +2705,8 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, ...@@ -2705,8 +2705,8 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
int ret; int ret;
ctx = i915_gem_context_lookup(file_priv, args->ctx_id); ctx = i915_gem_context_lookup(file_priv, args->ctx_id);
if (!ctx) if (IS_ERR(ctx))
return -ENOENT; return PTR_ERR(ctx);
ret = ctx_setparam(file_priv, ctx, args); ret = ctx_setparam(file_priv, ctx, args);
...@@ -2725,8 +2725,8 @@ int i915_gem_context_reset_stats_ioctl(struct drm_device *dev, ...@@ -2725,8 +2725,8 @@ int i915_gem_context_reset_stats_ioctl(struct drm_device *dev,
return -EINVAL; return -EINVAL;
ctx = i915_gem_context_lookup(file->driver_priv, args->ctx_id); ctx = i915_gem_context_lookup(file->driver_priv, args->ctx_id);
if (!ctx) if (IS_ERR(ctx))
return -ENOENT; return PTR_ERR(ctx);
/* /*
* We opt for unserialised reads here. This may result in tearing * We opt for unserialised reads here. This may result in tearing
......
...@@ -739,8 +739,8 @@ static int eb_select_context(struct i915_execbuffer *eb) ...@@ -739,8 +739,8 @@ static int eb_select_context(struct i915_execbuffer *eb)
struct i915_gem_context *ctx; struct i915_gem_context *ctx;
ctx = i915_gem_context_lookup(eb->file->driver_priv, eb->args->rsvd1); ctx = i915_gem_context_lookup(eb->file->driver_priv, eb->args->rsvd1);
if (unlikely(!ctx)) if (unlikely(IS_ERR(ctx)))
return -ENOENT; return PTR_ERR(ctx);
eb->gem_context = ctx; eb->gem_context = ctx;
if (rcu_access_pointer(ctx->vm)) if (rcu_access_pointer(ctx->vm))
......
...@@ -1858,7 +1858,7 @@ i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id) ...@@ -1858,7 +1858,7 @@ i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id)
ctx = NULL; ctx = NULL;
rcu_read_unlock(); rcu_read_unlock();
return ctx; return ctx ? ctx : ERR_PTR(-ENOENT);
} }
static inline struct i915_address_space * static inline struct i915_address_space *
......
...@@ -3414,10 +3414,10 @@ i915_perf_open_ioctl_locked(struct i915_perf *perf, ...@@ -3414,10 +3414,10 @@ i915_perf_open_ioctl_locked(struct i915_perf *perf,
struct drm_i915_file_private *file_priv = file->driver_priv; struct drm_i915_file_private *file_priv = file->driver_priv;
specific_ctx = i915_gem_context_lookup(file_priv, ctx_handle); specific_ctx = i915_gem_context_lookup(file_priv, ctx_handle);
if (!specific_ctx) { if (IS_ERR(specific_ctx)) {
DRM_DEBUG("Failed to look up context with ID %u for opening perf stream\n", DRM_DEBUG("Failed to look up context with ID %u for opening perf stream\n",
ctx_handle); ctx_handle);
ret = -ENOENT; ret = PTR_ERR(specific_ctx);
goto err; goto err;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment