the __igt_ctx_sseu() function iterates over the engines in a system, but
only calls igt_global_reset_lock() on to_gt() (so GT0). Move the lock
deeper into the function such that the call is done for a specific
gt depending on which engine is currently being selected via engine->gt.

Signed-off-by: Krzysztof Niemiec <[email protected]>
---

This is opinionated as stated in the cover letter, the alternative way
to run this is to pass a GT to the test itself, and run it in a
for_each_gt loop, and then skip on engines that don't belong to the
currently processed GT.

Also same assumption as in patch 2, using essentially || instead of &&
for checking wedge.

 .../drm/i915/gem/selftests/i915_gem_context.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c 
b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
index 9d405098f9e7..afa170a4c740 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_context.c
@@ -1249,9 +1249,6 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
        if (GRAPHICS_VER(i915) < 9)
                return 0;
 
-       if (flags & TEST_RESET)
-               igt_global_reset_lock(to_gt(i915));
-
        obj = i915_gem_object_create_internal(i915, PAGE_SIZE);
        if (IS_ERR(obj)) {
                ret = PTR_ERR(obj);
@@ -1295,6 +1292,9 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
                        goto out_put;
                }
 
+               if (flags & TEST_RESET)
+                       igt_global_reset_lock(engine->gt);
+
                ret = intel_context_pin(ce);
                if (ret)
                        goto out_ce;
@@ -1323,6 +1323,8 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
                intel_context_unpin(ce);
 out_ce:
                intel_context_put(ce);
+               if (flags & TEST_RESET)
+                       igt_global_reset_unlock(engine->gt);
        } while (!ret);
 
        if (igt_flush_test(i915))
@@ -1332,9 +1334,6 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
        i915_gem_object_put(obj);
 
 out_unlock:
-       if (flags & TEST_RESET)
-               igt_global_reset_unlock(to_gt(i915));
-
        if (ret)
                pr_err("%s: Failed with %d!\n", name, ret);
 
@@ -1908,9 +1907,13 @@ int i915_gem_context_live_selftests(struct 
drm_i915_private *i915)
                SUBTEST(igt_shared_ctx_exec),
                SUBTEST(igt_vm_isolation),
        };
+       struct intel_gt *gt;
+       unsigned int id;
 
-       if (intel_gt_is_wedged(to_gt(i915)))
-               return 0;
+       for_each_gt(gt, i915, id) {
+               if (intel_gt_is_wedged(gt))
+                       return 0;
+       }
 
        return i915_live_subtests(tests, i915);
 }
-- 
2.55.0

Reply via email to