]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915/selftests: Live tests emit requests and so require rpm
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 20 Sep 2018 14:49:34 +0000 (15:49 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 20 Sep 2018 16:01:26 +0000 (17:01 +0100)
As we emit requests or touch HW directly for some of the live tests, the
requirement is that we hold the rpm wakeref before doing so. We want a
mix of granularity since we will want to test runtime suspend, so try to
mark up only the critical sections where we need rpm for the live test.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108002
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/20180920144934.16611-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/selftests/i915_gem_coherency.c
drivers/gpu/drm/i915/selftests/i915_gem_context.c
drivers/gpu/drm/i915/selftests/i915_request.c
drivers/gpu/drm/i915/selftests/intel_guc.c
drivers/gpu/drm/i915/selftests/intel_lrc.c
drivers/gpu/drm/i915/selftests/intel_workarounds.c

index 4e6a221063acf6eda4ba95a8043036f98116b947..f7392c1ffe755cf3011f7457fac0294e2e41201d 100644 (file)
@@ -298,6 +298,7 @@ static int igt_gem_coherency(void *arg)
        values = offsets + ncachelines;
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
        for (over = igt_coherency_mode; over->name; over++) {
                if (!over->set)
                        continue;
@@ -375,6 +376,7 @@ static int igt_gem_coherency(void *arg)
                }
        }
 unlock:
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        kfree(offsets);
        return err;
index 441a51d4aa54a7c30129f4541ad5611bf478767c..76df25aa90c92b9da8f8a91ec785a54d82b13a8c 100644 (file)
@@ -119,6 +119,7 @@ static int live_nop_switch(void *arg)
                return PTR_ERR(file);
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        ctx = kcalloc(nctx, sizeof(*ctx), GFP_KERNEL);
        if (!ctx) {
@@ -221,6 +222,7 @@ static int live_nop_switch(void *arg)
        }
 
 out_unlock:
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        mock_file_free(i915, file);
        return err;
@@ -831,6 +833,8 @@ static int igt_switch_to_kernel_context(void *arg)
         */
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
+
        ctx = kernel_context(i915);
        if (IS_ERR(ctx)) {
                mutex_unlock(&i915->drm.struct_mutex);
@@ -853,6 +857,8 @@ out_unlock:
        GEM_TRACE_DUMP_ON(err);
        if (igt_flush_test(i915, I915_WAIT_LOCKED))
                err = -EIO;
+
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
 
        kernel_context_close(ctx);
index c4aac6141e04d0a217302122ebff9d8668de9ed8..07e5578153088cbdb434b58afae4ae1f1ddccc08 100644 (file)
@@ -342,6 +342,7 @@ static int live_nop_request(void *arg)
         */
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        for_each_engine(engine, i915, id) {
                struct i915_request *request = NULL;
@@ -402,6 +403,7 @@ static int live_nop_request(void *arg)
        }
 
 out_unlock:
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        return err;
 }
@@ -487,6 +489,7 @@ static int live_empty_request(void *arg)
         */
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        batch = empty_batch(i915);
        if (IS_ERR(batch)) {
@@ -550,6 +553,7 @@ out_batch:
        i915_vma_unpin(batch);
        i915_vma_put(batch);
 out_unlock:
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        return err;
 }
@@ -644,6 +648,7 @@ static int live_all_engines(void *arg)
         */
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        err = begin_live_test(&t, i915, __func__, "");
        if (err)
@@ -726,6 +731,7 @@ out_request:
        i915_vma_unpin(batch);
        i915_vma_put(batch);
 out_unlock:
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        return err;
 }
@@ -747,6 +753,7 @@ static int live_sequential_engines(void *arg)
         */
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        err = begin_live_test(&t, i915, __func__, "");
        if (err)
@@ -853,6 +860,7 @@ out_request:
                i915_request_put(request[id]);
        }
 out_unlock:
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        return err;
 }
index 90ba88c972cfebe24818d8dc8bbc3a02300f3031..0c0ab82b6228f84090d50806406350b820fa3ef9 100644 (file)
@@ -142,6 +142,7 @@ static int igt_guc_clients(void *args)
 
        GEM_BUG_ON(!HAS_GUC(dev_priv));
        mutex_lock(&dev_priv->drm.struct_mutex);
+       intel_runtime_pm_get(dev_priv);
 
        guc = &dev_priv->guc;
        if (!guc) {
@@ -269,6 +270,7 @@ out:
        guc_clients_create(guc);
        guc_clients_doorbell_init(guc);
 unlock:
+       intel_runtime_pm_put(dev_priv);
        mutex_unlock(&dev_priv->drm.struct_mutex);
        return err;
 }
@@ -287,6 +289,7 @@ static int igt_guc_doorbells(void *arg)
 
        GEM_BUG_ON(!HAS_GUC(dev_priv));
        mutex_lock(&dev_priv->drm.struct_mutex);
+       intel_runtime_pm_get(dev_priv);
 
        guc = &dev_priv->guc;
        if (!guc) {
@@ -379,6 +382,7 @@ out:
                        guc_client_free(clients[i]);
                }
 unlock:
+       intel_runtime_pm_put(dev_priv);
        mutex_unlock(&dev_priv->drm.struct_mutex);
        return err;
 }
index 582566faef090f395251c816690dad9dee521d7c..1aea7a8f2224a325652448966e59f0974c9a0e10 100644 (file)
@@ -221,6 +221,7 @@ static int live_sanitycheck(void *arg)
                return 0;
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        if (spinner_init(&spin, i915))
                goto err_unlock;
@@ -261,6 +262,7 @@ err_spin:
        spinner_fini(&spin);
 err_unlock:
        igt_flush_test(i915, I915_WAIT_LOCKED);
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        return err;
 }
@@ -278,6 +280,7 @@ static int live_preempt(void *arg)
                return 0;
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        if (spinner_init(&spin_hi, i915))
                goto err_unlock;
@@ -350,6 +353,7 @@ err_spin_hi:
        spinner_fini(&spin_hi);
 err_unlock:
        igt_flush_test(i915, I915_WAIT_LOCKED);
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        return err;
 }
@@ -368,6 +372,7 @@ static int live_late_preempt(void *arg)
                return 0;
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        if (spinner_init(&spin_hi, i915))
                goto err_unlock;
@@ -440,6 +445,7 @@ err_spin_hi:
        spinner_fini(&spin_hi);
 err_unlock:
        igt_flush_test(i915, I915_WAIT_LOCKED);
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        return err;
 
@@ -467,6 +473,7 @@ static int live_preempt_hang(void *arg)
                return 0;
 
        mutex_lock(&i915->drm.struct_mutex);
+       intel_runtime_pm_get(i915);
 
        if (spinner_init(&spin_hi, i915))
                goto err_unlock;
@@ -561,6 +568,7 @@ err_spin_hi:
        spinner_fini(&spin_hi);
 err_unlock:
        igt_flush_test(i915, I915_WAIT_LOCKED);
+       intel_runtime_pm_put(i915);
        mutex_unlock(&i915->drm.struct_mutex);
        return err;
 }
index 0d39b3bf0c0d0f11aaa883d672e9ba11dc33f5b5..d1a0923d2f383ea974ee5edbc6c59d3b074eaae7 100644 (file)
@@ -44,7 +44,9 @@ read_nonprivs(struct i915_gem_context *ctx, struct intel_engine_cs *engine)
        if (err)
                goto err_obj;
 
+       intel_runtime_pm_get(engine->i915);
        rq = i915_request_alloc(engine, ctx);
+       intel_runtime_pm_put(engine->i915);
        if (IS_ERR(rq)) {
                err = PTR_ERR(rq);
                goto err_pin;
@@ -175,7 +177,10 @@ static int switch_to_scratch_context(struct intel_engine_cs *engine)
        if (IS_ERR(ctx))
                return PTR_ERR(ctx);
 
+       intel_runtime_pm_get(engine->i915);
        rq = i915_request_alloc(engine, ctx);
+       intel_runtime_pm_put(engine->i915);
+
        kernel_context_close(ctx);
        if (IS_ERR(rq))
                return PTR_ERR(rq);