drm/i915/selftests: Err out on coherency if initialisation failed
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 27 Dec 2019 10:30:50 +0000 (10:30 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 27 Dec 2019 17:01:32 +0000 (17:01 +0000)
If gt initialisation failed, we are left with no engines to use for
coherency testing. Currently we bug out, which makes the actual error,
so fail more gracefully instead.

Closes: https://gitlab.freedesktop.org/drm/intel/issues/896
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Andi Shyti <andi.shyti@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191227103050.2715402-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c

index 49edc51111d5366bbc35b3692d986cf63bfb385a..3f6079e1dfb6d48129d8cf4089f942f29e346657 100644 (file)
@@ -325,7 +325,10 @@ static int igt_gem_coherency(void *arg)
        values = offsets + ncachelines;
 
        ctx.engine = random_engine(i915, &prng);
-       GEM_BUG_ON(!ctx.engine);
+       if (!ctx.engine) {
+               err = -ENODEV;
+               goto out_free;
+       }
        pr_info("%s: using %s\n", __func__, ctx.engine->name);
        intel_engine_pm_get(ctx.engine);
 
@@ -354,7 +357,7 @@ static int igt_gem_coherency(void *arg)
                                        ctx.obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
                                        if (IS_ERR(ctx.obj)) {
                                                err = PTR_ERR(ctx.obj);
-                                               goto free;
+                                               goto out_pm;
                                        }
 
                                        i915_random_reorder(offsets, ncachelines, &prng);
@@ -405,14 +408,15 @@ static int igt_gem_coherency(void *arg)
                        }
                }
        }
-free:
+out_pm:
        intel_engine_pm_put(ctx.engine);
+out_free:
        kfree(offsets);
        return err;
 
 put_object:
        i915_gem_object_put(ctx.obj);
-       goto free;
+       goto out_pm;
 }
 
 int i915_gem_coherency_live_selftests(struct drm_i915_private *i915)