Commit 07a635a8 authored by Jason Ekstrand's avatar Jason Ekstrand Committed by Daniel Vetter

drm/i915/gem: Rework error handling in default_engines

Since free_engines works for partially constructed engine sets, we can
use the usual goto pattern.
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-18-jason@jlekstrand.net
parent a34857dc
...@@ -366,7 +366,7 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx) ...@@ -366,7 +366,7 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
{ {
const struct intel_gt *gt = &ctx->i915->gt; const struct intel_gt *gt = &ctx->i915->gt;
struct intel_engine_cs *engine; struct intel_engine_cs *engine;
struct i915_gem_engines *e; struct i915_gem_engines *e, *err;
enum intel_engine_id id; enum intel_engine_id id;
e = alloc_engines(I915_NUM_ENGINES); e = alloc_engines(I915_NUM_ENGINES);
...@@ -384,18 +384,21 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx) ...@@ -384,18 +384,21 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
ce = intel_context_create(engine); ce = intel_context_create(engine);
if (IS_ERR(ce)) { if (IS_ERR(ce)) {
__free_engines(e, e->num_engines + 1); err = ERR_CAST(ce);
return ERR_CAST(ce); goto free_engines;
} }
intel_context_set_gem(ce, ctx); intel_context_set_gem(ce, ctx);
e->engines[engine->legacy_idx] = ce; e->engines[engine->legacy_idx] = ce;
e->num_engines = max(e->num_engines, engine->legacy_idx); e->num_engines = max(e->num_engines, engine->legacy_idx + 1);
} }
e->num_engines++;
return e; return e;
free_engines:
free_engines(e);
return err;
} }
void i915_gem_context_release(struct kref *ref) void i915_gem_context_release(struct kref *ref)
......
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