static int igt_global_reset(void *arg) { struct drm_i915_private *i915 = arg; unsigned int reset_count; int err = 0; /* Check that we can issue a global GPU reset */ igt_global_reset_lock(i915); set_bit(I915_RESET_HANDOFF, &i915->gpu_error.flags); mutex_lock(&i915->drm.struct_mutex); reset_count = i915_reset_count(&i915->gpu_error); i915_reset(i915, ALL_ENGINES, NULL); if (i915_reset_count(&i915->gpu_error) == reset_count) { pr_err("No GPU reset recorded!\n"); err = -EINVAL; } mutex_unlock(&i915->drm.struct_mutex); GEM_BUG_ON(test_bit(I915_RESET_HANDOFF, &i915->gpu_error.flags)); igt_global_reset_unlock(i915); if (i915_terminally_wedged(&i915->gpu_error)) err = -EIO; return err; }
int intel_reset_live_selftests(struct drm_i915_private *i915) { static const struct i915_subtest tests[] = { SUBTEST(igt_global_reset), /* attempt to recover GPU first */ SUBTEST(igt_wedged_reset), SUBTEST(igt_atomic_reset), }; intel_wakeref_t wakeref; int err = 0; if (!intel_has_gpu_reset(i915)) return 0; if (i915_terminally_wedged(i915)) return -EIO; /* we're long past hope of a successful reset */ with_intel_runtime_pm(i915, wakeref) err = i915_subtests(tests, i915); return err; }
static int igt_hang_sanitycheck(void *arg) { struct drm_i915_private *i915 = arg; struct i915_request *rq; struct intel_engine_cs *engine; enum intel_engine_id id; struct hang h; int err; /* Basic check that we can execute our hanging batch */ mutex_lock(&i915->drm.struct_mutex); err = hang_init(&h, i915); if (err) goto unlock; for_each_engine(engine, i915, id) { struct igt_wedge_me w; long timeout; if (!intel_engine_can_store_dword(engine)) continue; rq = hang_create_request(&h, engine); if (IS_ERR(rq)) { err = PTR_ERR(rq); pr_err("Failed to create request for %s, err=%d\n", engine->name, err); goto fini; } i915_request_get(rq); *h.batch = MI_BATCH_BUFFER_END; i915_gem_chipset_flush(i915); i915_request_add(rq); timeout = 0; igt_wedge_on_timeout(&w, i915, HZ / 10 /* 100ms timeout*/) timeout = i915_request_wait(rq, I915_WAIT_LOCKED, MAX_SCHEDULE_TIMEOUT); if (i915_terminally_wedged(&i915->gpu_error)) timeout = -EIO; i915_request_put(rq); if (timeout < 0) { err = timeout; pr_err("Wait for request failed on %s, err=%d\n", engine->name, err); goto fini; } } fini: hang_fini(&h); unlock: mutex_unlock(&i915->drm.struct_mutex); return err; }