diff mbox series

[1/2] drm/i915: Add a few asserts around handling of i915_request_is_active()

Message ID 20200529085809.23691-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915: Add a few asserts around handling of i915_request_is_active() | expand

Commit Message

Chris Wilson May 29, 2020, 8:58 a.m. UTC
Let's assert that we only call the execute callbacks on making the
request active, and that we do not execute the request without calling
the callbacks.

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

Comments

Tvrtko Ursulin May 29, 2020, 1:57 p.m. UTC | #1
On 29/05/2020 09:58, Chris Wilson wrote:
> Let's assert that we only call the execute callbacks on making the
> request active, and that we do not execute the request without calling
> the callbacks.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/i915_request.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
> index 0d810a62ff46..e5aba6824e26 100644
> --- a/drivers/gpu/drm/i915/i915_request.c
> +++ b/drivers/gpu/drm/i915/i915_request.c
> @@ -192,6 +192,7 @@ static void __notify_execute_cb(struct i915_request *rq)
>   
>   	lockdep_assert_held(&rq->lock);
>   
> +	GEM_BUG_ON(!i915_request_is_active(rq));
>   	if (llist_empty(&rq->execute_cb))
>   		return;
>   
> @@ -518,15 +519,15 @@ bool __i915_request_submit(struct i915_request *request)
>   	if (!test_and_set_bit(I915_FENCE_FLAG_ACTIVE, &request->fence.flags)) {
>   		list_move_tail(&request->sched.link, &engine->active.requests);
>   		clear_bit(I915_FENCE_FLAG_PQUEUE, &request->fence.flags);
> +		__notify_execute_cb(request);
>   	}
> +	GEM_BUG_ON(!llist_empty(&request->execute_cb));
>   
>   	if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &request->fence.flags) &&
>   	    !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &request->fence.flags) &&
>   	    !i915_request_enable_breadcrumb(request))
>   		intel_engine_signal_breadcrumbs(engine);
>   
> -	__notify_execute_cb(request);
> -
>   	spin_unlock(&request->lock);
>   
>   	return result;
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index 0d810a62ff46..e5aba6824e26 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -192,6 +192,7 @@  static void __notify_execute_cb(struct i915_request *rq)
 
 	lockdep_assert_held(&rq->lock);
 
+	GEM_BUG_ON(!i915_request_is_active(rq));
 	if (llist_empty(&rq->execute_cb))
 		return;
 
@@ -518,15 +519,15 @@  bool __i915_request_submit(struct i915_request *request)
 	if (!test_and_set_bit(I915_FENCE_FLAG_ACTIVE, &request->fence.flags)) {
 		list_move_tail(&request->sched.link, &engine->active.requests);
 		clear_bit(I915_FENCE_FLAG_PQUEUE, &request->fence.flags);
+		__notify_execute_cb(request);
 	}
+	GEM_BUG_ON(!llist_empty(&request->execute_cb));
 
 	if (test_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, &request->fence.flags) &&
 	    !test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &request->fence.flags) &&
 	    !i915_request_enable_breadcrumb(request))
 		intel_engine_signal_breadcrumbs(engine);
 
-	__notify_execute_cb(request);
-
 	spin_unlock(&request->lock);
 
 	return result;