]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/i915: Define explicit wedged on init reset state
authorMichał Winiarski <michal.winiarski@intel.com>
Thu, 26 Sep 2019 13:31:40 +0000 (14:31 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 26 Sep 2019 17:44:35 +0000 (18:44 +0100)
We're currently using scratch presence as a way of identifying that we
entered wedged state at driver initialization time.
Let's use a separate flag rather than rely on scratch.

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190926133142.2838-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gt/intel_reset.c
drivers/gpu/drm/i915/gt/intel_reset.h
drivers/gpu/drm/i915/gt/intel_reset_types.h
drivers/gpu/drm/i915/i915_gem.c

index ae68c3786f63dba3bdffd953a8a5ae26d9920903..ec978b4d1be34ed7789360f20c2505b1576c205a 100644 (file)
@@ -811,7 +811,8 @@ static bool __intel_gt_unset_wedged(struct intel_gt *gt)
        if (!test_bit(I915_WEDGED, &gt->reset.flags))
                return true;
 
-       if (!gt->scratch) /* Never full initialised, recovery impossible */
+       /* Never fully initialised, recovery impossible */
+       if (test_bit(I915_WEDGED_ON_INIT, &gt->reset.flags))
                return false;
 
        GEM_TRACE("start\n");
@@ -1279,6 +1280,14 @@ int intel_gt_terminally_wedged(struct intel_gt *gt)
        return intel_gt_is_wedged(gt) ? -EIO : 0;
 }
 
+void intel_gt_set_wedged_on_init(struct intel_gt *gt)
+{
+       BUILD_BUG_ON(I915_RESET_ENGINE + I915_NUM_ENGINES >
+                    I915_WEDGED_ON_INIT);
+       intel_gt_set_wedged(gt);
+       set_bit(I915_WEDGED_ON_INIT, &gt->reset.flags);
+}
+
 void intel_gt_init_reset(struct intel_gt *gt)
 {
        init_waitqueue_head(&gt->reset.queue);
index 52c00199e06941052f28a625269de322acb3defb..0b6ff1ee7f063b793b1418093931429a17258883 100644 (file)
@@ -45,6 +45,12 @@ void intel_gt_set_wedged(struct intel_gt *gt);
 bool intel_gt_unset_wedged(struct intel_gt *gt);
 int intel_gt_terminally_wedged(struct intel_gt *gt);
 
+/*
+ * There's no unset_wedged_on_init paired with this one.
+ * Once we're wedged on init, there's no going back.
+ */
+void intel_gt_set_wedged_on_init(struct intel_gt *gt);
+
 int __intel_gt_reset(struct intel_gt *gt, intel_engine_mask_t engine_mask);
 
 int intel_reset_guc(struct intel_gt *gt);
@@ -68,6 +74,9 @@ void __intel_fini_wedge(struct intel_wedge_me *w);
 
 static inline bool __intel_reset_failed(const struct intel_reset *reset)
 {
+       GEM_BUG_ON(test_bit(I915_WEDGED_ON_INIT, &reset->flags) ?
+                  !test_bit(I915_WEDGED, &reset->flags) : false);
+
        return unlikely(test_bit(I915_WEDGED, &reset->flags));
 }
 
index 31968356e0c01e084a4fe1a4043658aaae9e802f..f43bc3a0fe4feb149985b45a143ff2ab36f3a66a 100644 (file)
@@ -29,11 +29,17 @@ struct intel_reset {
         * we set the #I915_WEDGED bit. Prior to command submission, e.g.
         * i915_request_alloc(), this bit is checked and the sequence
         * aborted (with -EIO reported to userspace) if set.
+        *
+        * #I915_WEDGED_ON_INIT - If we fail to initialize the GPU we can no
+        * longer use the GPU - similar to #I915_WEDGED bit. The difference in
+        * in the way we're handling "forced" unwedged (e.g. through debugfs),
+        * which is not allowed in case we failed to initialize.
         */
        unsigned long flags;
 #define I915_RESET_BACKOFF     0
 #define I915_RESET_MODESET     1
 #define I915_RESET_ENGINE      2
+#define I915_WEDGED_ON_INIT    (BITS_PER_LONG - 2)
 #define I915_WEDGED            (BITS_PER_LONG - 1)
 
        struct mutex mutex; /* serialises wedging/unwedging */
index 2da9544fa9a4e1d5173c94466cb4de4aaabf5e59..e2897a6662258981ee6e178ff025be5ad3bff632 100644 (file)
@@ -1411,7 +1411,7 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
 err_gt:
        mutex_unlock(&dev_priv->drm.struct_mutex);
 
-       intel_gt_set_wedged(&dev_priv->gt);
+       intel_gt_set_wedged_on_init(&dev_priv->gt);
        i915_gem_suspend(dev_priv);
        i915_gem_suspend_late(dev_priv);