drm/i915/selftests: Skip live eviction tests when wedged
[linux-2.6-microblaze.git] / drivers / gpu / drm / i915 / selftests / i915_gem_evict.c
index ab9d7be..128ad1c 100644 (file)
@@ -35,7 +35,7 @@ static int populate_ggtt(struct drm_i915_private *i915)
        u64 size;
 
        for (size = 0;
-            size + I915_GTT_PAGE_SIZE <= i915->ggtt.base.total;
+            size + I915_GTT_PAGE_SIZE <= i915->ggtt.vm.total;
             size += I915_GTT_PAGE_SIZE) {
                struct i915_vma *vma;
 
@@ -57,7 +57,7 @@ static int populate_ggtt(struct drm_i915_private *i915)
                return -EINVAL;
        }
 
-       if (list_empty(&i915->ggtt.base.inactive_list)) {
+       if (list_empty(&i915->ggtt.vm.inactive_list)) {
                pr_err("No objects on the GGTT inactive list!\n");
                return -EINVAL;
        }
@@ -69,7 +69,7 @@ static void unpin_ggtt(struct drm_i915_private *i915)
 {
        struct i915_vma *vma;
 
-       list_for_each_entry(vma, &i915->ggtt.base.inactive_list, vm_link)
+       list_for_each_entry(vma, &i915->ggtt.vm.inactive_list, vm_link)
                i915_vma_unpin(vma);
 }
 
@@ -103,7 +103,7 @@ static int igt_evict_something(void *arg)
                goto cleanup;
 
        /* Everything is pinned, nothing should happen */
-       err = i915_gem_evict_something(&ggtt->base,
+       err = i915_gem_evict_something(&ggtt->vm,
                                       I915_GTT_PAGE_SIZE, 0, 0,
                                       0, U64_MAX,
                                       0);
@@ -116,7 +116,7 @@ static int igt_evict_something(void *arg)
        unpin_ggtt(i915);
 
        /* Everything is unpinned, we should be able to evict something */
-       err = i915_gem_evict_something(&ggtt->base,
+       err = i915_gem_evict_something(&ggtt->vm,
                                       I915_GTT_PAGE_SIZE, 0, 0,
                                       0, U64_MAX,
                                       0);
@@ -181,7 +181,7 @@ static int igt_evict_for_vma(void *arg)
                goto cleanup;
 
        /* Everything is pinned, nothing should happen */
-       err = i915_gem_evict_for_node(&ggtt->base, &target, 0);
+       err = i915_gem_evict_for_node(&ggtt->vm, &target, 0);
        if (err != -ENOSPC) {
                pr_err("i915_gem_evict_for_node on a full GGTT returned err=%d\n",
                       err);
@@ -191,7 +191,7 @@ static int igt_evict_for_vma(void *arg)
        unpin_ggtt(i915);
 
        /* Everything is unpinned, we should be able to evict the node */
-       err = i915_gem_evict_for_node(&ggtt->base, &target, 0);
+       err = i915_gem_evict_for_node(&ggtt->vm, &target, 0);
        if (err) {
                pr_err("i915_gem_evict_for_node returned err=%d\n",
                       err);
@@ -229,7 +229,7 @@ static int igt_evict_for_cache_color(void *arg)
         * i915_gtt_color_adjust throughout our driver, so using a mock color
         * adjust will work just fine for our purposes.
         */
-       ggtt->base.mm.color_adjust = mock_color_adjust;
+       ggtt->vm.mm.color_adjust = mock_color_adjust;
 
        obj = i915_gem_object_create_internal(i915, I915_GTT_PAGE_SIZE);
        if (IS_ERR(obj)) {
@@ -265,7 +265,7 @@ static int igt_evict_for_cache_color(void *arg)
        i915_vma_unpin(vma);
 
        /* Remove just the second vma */
-       err = i915_gem_evict_for_node(&ggtt->base, &target, 0);
+       err = i915_gem_evict_for_node(&ggtt->vm, &target, 0);
        if (err) {
                pr_err("[0]i915_gem_evict_for_node returned err=%d\n", err);
                goto cleanup;
@@ -276,7 +276,7 @@ static int igt_evict_for_cache_color(void *arg)
         */
        target.color = I915_CACHE_L3_LLC;
 
-       err = i915_gem_evict_for_node(&ggtt->base, &target, 0);
+       err = i915_gem_evict_for_node(&ggtt->vm, &target, 0);
        if (!err) {
                pr_err("[1]i915_gem_evict_for_node returned err=%d\n", err);
                err = -EINVAL;
@@ -288,7 +288,7 @@ static int igt_evict_for_cache_color(void *arg)
 cleanup:
        unpin_ggtt(i915);
        cleanup_objects(i915);
-       ggtt->base.mm.color_adjust = NULL;
+       ggtt->vm.mm.color_adjust = NULL;
        return err;
 }
 
@@ -305,7 +305,7 @@ static int igt_evict_vm(void *arg)
                goto cleanup;
 
        /* Everything is pinned, nothing should happen */
-       err = i915_gem_evict_vm(&ggtt->base);
+       err = i915_gem_evict_vm(&ggtt->vm);
        if (err) {
                pr_err("i915_gem_evict_vm on a full GGTT returned err=%d]\n",
                       err);
@@ -314,7 +314,7 @@ static int igt_evict_vm(void *arg)
 
        unpin_ggtt(i915);
 
-       err = i915_gem_evict_vm(&ggtt->base);
+       err = i915_gem_evict_vm(&ggtt->vm);
        if (err) {
                pr_err("i915_gem_evict_vm on a full GGTT returned err=%d]\n",
                       err);
@@ -359,9 +359,9 @@ static int igt_evict_contexts(void *arg)
 
        /* Reserve a block so that we know we have enough to fit a few rq */
        memset(&hole, 0, sizeof(hole));
-       err = i915_gem_gtt_insert(&i915->ggtt.base, &hole,
+       err = i915_gem_gtt_insert(&i915->ggtt.vm, &hole,
                                  PRETEND_GGTT_SIZE, 0, I915_COLOR_UNEVICTABLE,
-                                 0, i915->ggtt.base.total,
+                                 0, i915->ggtt.vm.total,
                                  PIN_NOEVICT);
        if (err)
                goto out_locked;
@@ -377,9 +377,9 @@ static int igt_evict_contexts(void *arg)
                        goto out_locked;
                }
 
-               if (i915_gem_gtt_insert(&i915->ggtt.base, &r->node,
+               if (i915_gem_gtt_insert(&i915->ggtt.vm, &r->node,
                                        1ul << 20, 0, I915_COLOR_UNEVICTABLE,
-                                       0, i915->ggtt.base.total,
+                                       0, i915->ggtt.vm.total,
                                        PIN_NOEVICT)) {
                        kfree(r);
                        break;
@@ -490,7 +490,7 @@ int i915_gem_evict_mock_selftests(void)
        err = i915_subtests(tests, i915);
        mutex_unlock(&i915->drm.struct_mutex);
 
-       drm_dev_unref(&i915->drm);
+       drm_dev_put(&i915->drm);
        return err;
 }
 
@@ -500,5 +500,8 @@ int i915_gem_evict_live_selftests(struct drm_i915_private *i915)
                SUBTEST(igt_evict_contexts),
        };
 
+       if (i915_terminally_wedged(&i915->gpu_error))
+               return 0;
+
        return i915_subtests(tests, i915);
 }