diff mbox

drm/i915: Check fence status after serialising with the spinlock

Message ID 20170127130607.31970-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Jan. 27, 2017, 1:06 p.m. UTC
A very rare problem we encounter is that as retire the request we find
that it appears to not have been yet executed. Other than malevolent hw,
one possible explanation is that the update of the fence status on one
cpu (an atomic_dec_and_test) is not yet visible to the retiree on
another cpu. However, since retirement is serialised with execution via
a fence-local spinlock, we can use these to ensure that we have
sufficient barriers between the execution and the assert in retirement.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_request.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Joonas Lahtinen Jan. 30, 2017, 12:27 p.m. UTC | #1
On pe, 2017-01-27 at 13:06 +0000, Chris Wilson wrote:
> A very rare problem we encounter is that as retire the request we find
                                         we -^
> that it appears to not have been yet executed. Other than malevolent hw,
> one possible explanation is that the update of the fence status on one
> cpu (an atomic_dec_and_test) is not yet visible to the retiree on
> another cpu. However, since retirement is serialised with execution via
> a fence-local spinlock, we can use these to ensure that we have

But it uses timeline spinlock?

> sufficient barriers between the execution and the assert in retirement.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Regards, Joonas
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index 72b7f7d9461d..53966e10c1d8 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -210,10 +210,7 @@  static void i915_gem_request_retire(struct drm_i915_gem_request *request)
 	struct i915_gem_active *active, *next;
 
 	lockdep_assert_held(&request->i915->drm.struct_mutex);
-	GEM_BUG_ON(!i915_sw_fence_signaled(&request->submit));
-	GEM_BUG_ON(!i915_sw_fence_signaled(&request->execute));
 	GEM_BUG_ON(!i915_gem_request_completed(request));
-	GEM_BUG_ON(!request->i915->gt.active_requests);
 
 	trace_i915_gem_request_retire(request);
 
@@ -221,6 +218,10 @@  static void i915_gem_request_retire(struct drm_i915_gem_request *request)
 	list_del_init(&request->link);
 	spin_unlock_irq(&engine->timeline->lock);
 
+	GEM_BUG_ON(!i915_sw_fence_signaled(&request->submit));
+	GEM_BUG_ON(!i915_sw_fence_signaled(&request->execute));
+	GEM_BUG_ON(!request->i915->gt.active_requests);
+
 	/* We know the GPU must have read the request to have
 	 * sent us the seqno + interrupt, so use the position
 	 * of tail of the request to update the last known position