[PATCH 1/4] drm/i915: Refine placement of gt.reset_lockmap

Chris Wilson
2019-06-13T06:20:28Z

If we pull the lockmap into reset_prepare/reset_finish, it will
naturally cover i915_gem_set_wedged() as well as i915_reset(). And with
another tweak, we can pull __i915_gem_unset_wedged() underneath the
lockmap covering the mutexes used there.

As a bonus, it should hide the ugliness of the i915_reset exit path ;)

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_reset.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_reset.c b/drivers/gpu/drm/i915/gt/intel_reset.c
index 6368b37f26d1..952e11b4b5c5 100644
--- a/drivers/gpu/drm/i915/gt/intel_reset.c
+++ b/drivers/gpu/drm/i915/gt/intel_reset.c
@@ -723,6 +723,8 @@ static void reset_prepare(struct drm_i915_private *i915)
enum intel_engine_id id;

intel_gt_pm_get(i915);
+ lock_map_acquire(&i915->gt.reset_lockmap);
+
for_each_engine(engine, i915, id)
reset_prepare_engine(engine);

@@ -773,6 +775,8 @@ static void reset_finish(struct drm_i915_private *i915)
reset_finish_engine(engine);
intel_engine_signal_breadcrumbs(engine);
}
+
+ lock_map_release(&i915->gt.reset_lockmap);
intel_gt_pm_put(i915);
}

@@ -978,17 +982,17 @@ void i915_reset(struct drm_i915_private *i915,

might_sleep();
GEM_BUG_ON(!test_bit(I915_RESET_BACKOFF, &error->flags));
- lock_map_acquire(&i915->gt.reset_lockmap);
+
+ reset_prepare(i915);

/* Clear any previous failed attempts at recovery. Time to try again. */
if (!__i915_gem_unset_wedged(i915))
- goto unlock;
+ goto finish;

if (reason)
dev_notice(i915->drm.dev, "Resetting chip for %s\n", reason);
error->reset_count++;

- reset_prepare(i915);

if (!intel_has_gpu_reset(i915)) {
if (i915_modparams.reset)
@@ -1030,8 +1034,6 @@ void i915_reset(struct drm_i915_private *i915,

finish:
reset_finish(i915);
-unlock:
- lock_map_release(&i915->gt.reset_lockmap);
return;