diff mbox series

drm/i915: Skip repeated calls to i915_gem_set_wedged()

Message ID 20180723145335.24579-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915: Skip repeated calls to i915_gem_set_wedged() | expand

Commit Message

Chris Wilson July 23, 2018, 2:53 p.m. UTC
If we already wedged, i915_gem_set_wedged() becomes a complicated no-op.

References: https://bugs.freedesktop.org/show_bug.cgi?id=107343
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Rodrigo Vivi July 23, 2018, 10:23 p.m. UTC | #1
On Mon, Jul 23, 2018 at 03:53:35PM +0100, Chris Wilson wrote:
> If we already wedged, i915_gem_set_wedged() becomes a complicated no-op.
> 
> References: https://bugs.freedesktop.org/show_bug.cgi?id=107343
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/gpu/drm/i915/i915_gem.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 8b52cb768a67..a4031fab57b0 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -3312,8 +3312,8 @@ void i915_gem_set_wedged(struct drm_i915_private *i915)
>  			intel_engine_dump(engine, &p, "%s\n", engine->name);
>  	}
>  
> -	set_bit(I915_WEDGED, &i915->gpu_error.flags);
> -	smp_mb__after_atomic();
> +	if (test_and_set_bit(I915_WEDGED, &i915->gpu_error.flags))
> +		goto out;
>  
>  	/*
>  	 * First, stop submission to hw, but do not yet complete requests by
> @@ -3372,6 +3372,7 @@ void i915_gem_set_wedged(struct drm_i915_private *i915)
>  		i915_gem_reset_finish_engine(engine);
>  	}
>  
> +out:
>  	GEM_TRACE("end\n");
>  
>  	wake_up_all(&i915->gpu_error.reset_queue);
> -- 
> 2.18.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Chris Wilson July 25, 2018, 7:09 a.m. UTC | #2
Quoting Rodrigo Vivi (2018-07-23 23:23:32)
> On Mon, Jul 23, 2018 at 03:53:35PM +0100, Chris Wilson wrote:
> > If we already wedged, i915_gem_set_wedged() becomes a complicated no-op.
> > 
> > References: https://bugs.freedesktop.org/show_bug.cgi?id=107343
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

Ta, I'll come back to v2+ when we have a test case that demonstrates the
danger in the race between wedging and unwedging. (Ever descending the
scale of probability.)
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 8b52cb768a67..a4031fab57b0 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3312,8 +3312,8 @@  void i915_gem_set_wedged(struct drm_i915_private *i915)
 			intel_engine_dump(engine, &p, "%s\n", engine->name);
 	}
 
-	set_bit(I915_WEDGED, &i915->gpu_error.flags);
-	smp_mb__after_atomic();
+	if (test_and_set_bit(I915_WEDGED, &i915->gpu_error.flags))
+		goto out;
 
 	/*
 	 * First, stop submission to hw, but do not yet complete requests by
@@ -3372,6 +3372,7 @@  void i915_gem_set_wedged(struct drm_i915_private *i915)
 		i915_gem_reset_finish_engine(engine);
 	}
 
+out:
 	GEM_TRACE("end\n");
 
 	wake_up_all(&i915->gpu_error.reset_queue);