2018-12-03 19:50:11 +07:00
|
|
|
/*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
* Copyright © 2018 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "igt_reset.h"
|
|
|
|
|
2019-04-25 00:48:39 +07:00
|
|
|
#include "gt/intel_engine.h"
|
2019-07-13 02:29:53 +07:00
|
|
|
#include "gt/intel_gt.h"
|
2019-04-25 00:48:39 +07:00
|
|
|
|
2018-12-03 19:50:11 +07:00
|
|
|
#include "../i915_drv.h"
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
void igt_global_reset_lock(struct intel_gt *gt)
|
2018-12-03 19:50:11 +07:00
|
|
|
{
|
|
|
|
struct intel_engine_cs *engine;
|
|
|
|
enum intel_engine_id id;
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
pr_debug("%s: current gpu_error=%08lx\n", __func__, gt->reset.flags);
|
2018-12-03 19:50:11 +07:00
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
while (test_and_set_bit(I915_RESET_BACKOFF, >->reset.flags))
|
|
|
|
wait_event(gt->reset.queue,
|
|
|
|
!test_bit(I915_RESET_BACKOFF, >->reset.flags));
|
2018-12-03 19:50:11 +07:00
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
for_each_engine(engine, gt->i915, id) {
|
2018-12-03 19:50:11 +07:00
|
|
|
while (test_and_set_bit(I915_RESET_ENGINE + id,
|
2019-07-13 02:29:53 +07:00
|
|
|
>->reset.flags))
|
|
|
|
wait_on_bit(>->reset.flags, I915_RESET_ENGINE + id,
|
2018-12-03 19:50:11 +07:00
|
|
|
TASK_UNINTERRUPTIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
void igt_global_reset_unlock(struct intel_gt *gt)
|
2018-12-03 19:50:11 +07:00
|
|
|
{
|
|
|
|
struct intel_engine_cs *engine;
|
|
|
|
enum intel_engine_id id;
|
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
for_each_engine(engine, gt->i915, id)
|
|
|
|
clear_bit(I915_RESET_ENGINE + id, >->reset.flags);
|
2018-12-03 19:50:11 +07:00
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
clear_bit(I915_RESET_BACKOFF, >->reset.flags);
|
|
|
|
wake_up_all(>->reset.queue);
|
2018-12-03 19:50:11 +07:00
|
|
|
}
|
2019-05-23 02:31:56 +07:00
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
bool igt_force_reset(struct intel_gt *gt)
|
2019-05-23 02:31:56 +07:00
|
|
|
{
|
2019-07-13 02:29:53 +07:00
|
|
|
intel_gt_set_wedged(gt);
|
|
|
|
intel_gt_reset(gt, 0, NULL);
|
2019-05-23 02:31:56 +07:00
|
|
|
|
2019-07-13 02:29:53 +07:00
|
|
|
return !intel_gt_is_wedged(gt);
|
2019-05-23 02:31:56 +07:00
|
|
|
}
|