Commit 339cc6ae authored by Chris Wilson's avatar Chris Wilson Committed by Rodrigo Vivi

drm/i915/selftests: Always free spinner on __sseu_prepare error

Prepare a nice little onion unwind to ensure that we always free the
spinner if we __sseu_prepare fails.

Fixes: c06ee6ff ("drm/i915/selftests: Context SSEU reconfiguration tests")
Reported-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190215195010.16637-1-chris@chris-wilson.co.ukReviewed-by: default avatarRadhakrishna Sripada <radhakrishna.sripada@intel.com>
(cherry picked from commit 2a4a2754)
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 7b1366b4
...@@ -710,47 +710,45 @@ __sseu_prepare(struct drm_i915_private *i915, ...@@ -710,47 +710,45 @@ __sseu_prepare(struct drm_i915_private *i915,
unsigned int flags, unsigned int flags,
struct i915_gem_context *ctx, struct i915_gem_context *ctx,
struct intel_engine_cs *engine, struct intel_engine_cs *engine,
struct igt_spinner **spin_out) struct igt_spinner **spin)
{ {
int ret = 0;
if (flags & (TEST_BUSY | TEST_RESET)) {
struct igt_spinner *spin;
struct i915_request *rq; struct i915_request *rq;
int ret;
spin = kzalloc(sizeof(*spin), GFP_KERNEL); *spin = NULL;
if (!spin) { if (!(flags & (TEST_BUSY | TEST_RESET)))
ret = -ENOMEM; return 0;
goto out;
}
ret = igt_spinner_init(spin, i915); *spin = kzalloc(sizeof(**spin), GFP_KERNEL);
if (!*spin)
return -ENOMEM;
ret = igt_spinner_init(*spin, i915);
if (ret) if (ret)
return ret; goto err_free;
rq = igt_spinner_create_request(spin, ctx, engine, MI_NOOP); rq = igt_spinner_create_request(*spin, ctx, engine, MI_NOOP);
if (IS_ERR(rq)) { if (IS_ERR(rq)) {
ret = PTR_ERR(rq); ret = PTR_ERR(rq);
igt_spinner_fini(spin); goto err_fini;
kfree(spin);
goto out;
} }
i915_request_add(rq); i915_request_add(rq);
if (!igt_wait_for_spinner(spin, rq)) { if (!igt_wait_for_spinner(*spin, rq)) {
pr_err("%s: Spinner failed to start!\n", name); pr_err("%s: Spinner failed to start!\n", name);
igt_spinner_end(spin);
igt_spinner_fini(spin);
kfree(spin);
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
goto out; goto err_end;
} }
*spin_out = spin; return 0;
}
out: err_end:
igt_spinner_end(*spin);
err_fini:
igt_spinner_fini(*spin);
err_free:
kfree(fetch_and_zero(spin));
return ret; return ret;
} }
...@@ -897,22 +895,23 @@ __sseu_test(struct drm_i915_private *i915, ...@@ -897,22 +895,23 @@ __sseu_test(struct drm_i915_private *i915,
ret = __sseu_prepare(i915, name, flags, ctx, engine, &spin); ret = __sseu_prepare(i915, name, flags, ctx, engine, &spin);
if (ret) if (ret)
goto out; goto out_context;
ret = __i915_gem_context_reconfigure_sseu(ctx, engine, sseu); ret = __i915_gem_context_reconfigure_sseu(ctx, engine, sseu);
if (ret) if (ret)
goto out; goto out_spin;
ret = __sseu_finish(i915, name, flags, ctx, kctx, engine, obj, ret = __sseu_finish(i915, name, flags, ctx, kctx, engine, obj,
hweight32(sseu.slice_mask), spin); hweight32(sseu.slice_mask), spin);
out: out_spin:
if (spin) { if (spin) {
igt_spinner_end(spin); igt_spinner_end(spin);
igt_spinner_fini(spin); igt_spinner_fini(spin);
kfree(spin); kfree(spin);
} }
out_context:
kernel_context_close(kctx); kernel_context_close(kctx);
return ret; return ret;
......
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