drm/i915: i915_gem_object_sync must handle NULL
Subsystems (2)
PATCH 1/3 drm/i915: i915_gem_object_sync must handle NULL
When I extracted the synchronization code for implementing semaphorified pageflips (74f5f6e0), I neglected the non pipelined case which also calls this code. The modesetting code wants to make sure the object has finished rendering to the frame before configuring the scanout (ie. non-pipelined case).
As a result of a follow on discussion on IRC, I've decided to add a comment about the function itself which received much inspiration from Chris as well. So really, this patch was ghost-written by Chris :).
--- drivers/gpu/drm/i915/i915_gem.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +13 -1
@@ -1953,6 +1953,18 @@ i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj)return 0 ; } +/** +* i915_gem_object_sync - sync an object to a ring. +* +* @obj: object which may be in use on another ring. +* @to: ring we wish to use the object on. May be NULL. +* +* This code is meant to abstract object synchronization with the GPU. +* Calling with NULL implies synchronizing the object with the CPU +* rather than a particular GPU ring. +* +* Returns 0 if successful, else propagates up the lower layer error. +*/ int i915_gem_object_sync (struct drm_i915_gem_object *obj,struct intel_ring_buffer *to)
@@ -1964,7 +1976,7 @@ i915_gem_object_sync(struct drm_i915_gem_object *obj,if (from ==NULL || to == from)return 0 ; -if (!i915_semaphore_is_enabled (obj->base.dev)) +if (to ==NULL || !i915_semaphore_is_enabled (obj->base.dev))return i915_gem_object_wait_rendering (obj); idx =intel_ring_sync_index (from, to);
Signature · 1 line
1.7.10
PATCH 2/3 drm/i915: fix for when semaphore updates fail
This fixes a long standing issue where emitting the semaphore updates may have failed, but we've already updated our internal data structure.
--- drivers/gpu/drm/i915/i915_gem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +4 -2
@@ -2001,10 +2001,12 @@ i915_gem_object_sync(struct drm_i915_gem_object *obj, seqno = request->seqno; } - from->sync_seqno[idx] = seqno; -return to->sync_to (to, from, seqno -1 ); + ret = to->sync_to (to, from, seqno -1 ); +if (!ret) + from->sync_seqno[idx] = seqno; +return ret; }static void i915_gem_object_finish_gtt (struct drm_i915_gem_object *obj)
Signature · 1 line
1.7.10
Re: [PATCH 2/3] drm/i915: fix for when semaphore updates fail
Quoted 5 lines · Ben Widawsky
This fixes a long standing issue where emitting the semaphore updates may have failed, but we've already updated our internal data structure.
Reported-by Daniel Vetter <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
I would have written it as ret == 0, but since I didn't write this,
Fortunately the impact of the bug would have been render corruption and not a GPU hang.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 3/3 drm/i915: hide (seqno-1) in ringbuffer code
In reply to Ben WidawskyWaiting for seqno-1 in our object synchronization code is an implementation detail given how we've decided to do the waits within the rest of our code.
--- drivers/gpu/drm/i915/i915_gem.c | 2 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -2002,7 +2002,7 @@ i915_gem_object_sync(struct drm_i915_gem_object *obj, } - ret = to->sync_to (to, from, seqno -1 ); + ret = to->sync_to (to, from, seqno);if (!ret) from->sync_seqno[idx] = seqno;
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -0
@@ -482,6 +482,12 @@ intel_ring_sync(struct intel_ring_buffer *waiter,MI_SEMAPHORE_COMPARE |MI_SEMAPHORE_REGISTER ; +/* Throughout all of the GEM code, seqno passed implies our current +* seqno is >= the last seqno executed. However for hardware the +* comparison is strictly greater than. +*/ + seqno -=1 ; + ret =intel_ring_begin (waiter,4 );if (ret)return ret;
Signature · 1 line
1.7.10
Re: [PATCH 3/3] drm/i915: hide (seqno-1) in ringbuffer code
Quoted 6 lines · Ben Widawsky
Waiting for seqno-1 in our object synchronization code is an implementation detail given how we've decided to do the waits within the rest of our code.
Requested-by Daniel Vetter <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
Thanks for the comment, I had forgotten about that hw detail.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 6 lines · Ben Widawsky
When I extracted the synchronization code for implementing semaphorified pageflips (
74f5f6e0), I neglected the non pipelined case which also calls this code. The modesetting code wants to make sure the object has finished rendering to the frame before configuring the scanout (ie. non-pipelined case).
Quoted 6 lines
As a result of a follow on discussion on IRC, I've decided to add a comment about the function itself which received much inspiration from Chris as well. So really, this patch was ghost-written by Chris :).
Reported-by Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Daniel Vetter
AppliedQuoted 7 lines · Chris Wilson
Quoted 6 lines · Ben Widawsky
When I extracted the synchronization code for implementing semaphorified pageflips (
74f5f6e0), I neglected the non pipelined case which also calls this code. The modesetting code wants to make sure the object has finished rendering to the frame before configuring the scanout (ie. non-pipelined case).
Quoted 8 lines
Quoted 6 lines
As a result of a follow on discussion on IRC, I've decided to add a comment about the function itself which received much inspiration from Chris as well. So really, this patch was ghost-written by Chris :).
Reported-by Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>Reviewed-by Chris Wilson <[email protected]>Tested-by Chris Wilson <[email protected]>
I've picked up all 3 patches for -next, thanks for them. -Daniel
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48