diff mbox series

[v2] drm/i915/selftests: Flush the active callbacks

Message ID 20191122132404.690440-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [v2] drm/i915/selftests: Flush the active callbacks | expand

Commit Message

Chris Wilson Nov. 22, 2019, 1:24 p.m. UTC
Before checking the current i915_active state for the asynchronous work
we submitted, flush any ongoing callback. This ensures that our sampling
is robust and does not sporadically fail due to bad timing as the work
is running on another cpu.

v2: Drop the fence callback sync, retiring under the lock should be good
enough to synchronize with engine_retire() and the
intel_gt_retire_requests() background worker.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/selftest_context.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Tvrtko Ursulin Nov. 22, 2019, 5:30 p.m. UTC | #1
On 22/11/2019 13:24, Chris Wilson wrote:
> Before checking the current i915_active state for the asynchronous work
> we submitted, flush any ongoing callback. This ensures that our sampling
> is robust and does not sporadically fail due to bad timing as the work
> is running on another cpu.
> 
> v2: Drop the fence callback sync, retiring under the lock should be good
> enough to synchronize with engine_retire() and the
> intel_gt_retire_requests() background worker.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/gt/selftest_context.c | 16 ++++++++++------
>   1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/selftest_context.c b/drivers/gpu/drm/i915/gt/selftest_context.c
> index 3586af636304..a0ebd00b6ad4 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_context.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_context.c
> @@ -48,20 +48,22 @@ static int context_sync(struct intel_context *ce)
>   
>   	mutex_lock(&tl->mutex);
>   	do {
> -		struct dma_fence *fence;
> +		struct i915_request *rq;
>   		long timeout;
>   
> -		fence = i915_active_fence_get(&tl->last_request);
> -		if (!fence)
> +		if (list_empty(&tl->requests))
>   			break;
>   
> -		timeout = dma_fence_wait_timeout(fence, false, HZ / 10);
> +		rq = list_last_entry(&tl->requests, typeof(*rq), link);
> +		i915_request_get(rq);
> +
> +		timeout = i915_request_wait(rq, 0, HZ / 10);
>   		if (timeout < 0)
>   			err = timeout;
>   		else
> -			i915_request_retire_upto(to_request(fence));
> +			i915_request_retire_upto(rq);
>   
> -		dma_fence_put(fence);
> +		i915_request_put(rq);
>   	} while (!err);
>   	mutex_unlock(&tl->mutex);
>   
> @@ -282,6 +284,8 @@ static int __live_active_context(struct intel_engine_cs *engine,
>   		err = -EINVAL;
>   	}
>   
> +	intel_engine_pm_flush(engine);
> +
>   	if (intel_engine_pm_is_awake(engine)) {
>   		struct drm_printer p = drm_debug_printer(__func__);
>   
> 

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

Regards,

Tvrtko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/selftest_context.c b/drivers/gpu/drm/i915/gt/selftest_context.c
index 3586af636304..a0ebd00b6ad4 100644
--- a/drivers/gpu/drm/i915/gt/selftest_context.c
+++ b/drivers/gpu/drm/i915/gt/selftest_context.c
@@ -48,20 +48,22 @@  static int context_sync(struct intel_context *ce)
 
 	mutex_lock(&tl->mutex);
 	do {
-		struct dma_fence *fence;
+		struct i915_request *rq;
 		long timeout;
 
-		fence = i915_active_fence_get(&tl->last_request);
-		if (!fence)
+		if (list_empty(&tl->requests))
 			break;
 
-		timeout = dma_fence_wait_timeout(fence, false, HZ / 10);
+		rq = list_last_entry(&tl->requests, typeof(*rq), link);
+		i915_request_get(rq);
+
+		timeout = i915_request_wait(rq, 0, HZ / 10);
 		if (timeout < 0)
 			err = timeout;
 		else
-			i915_request_retire_upto(to_request(fence));
+			i915_request_retire_upto(rq);
 
-		dma_fence_put(fence);
+		i915_request_put(rq);
 	} while (!err);
 	mutex_unlock(&tl->mutex);
 
@@ -282,6 +284,8 @@  static int __live_active_context(struct intel_engine_cs *engine,
 		err = -EINVAL;
 	}
 
+	intel_engine_pm_flush(engine);
+
 	if (intel_engine_pm_is_awake(engine)) {
 		struct drm_printer p = drm_debug_printer(__func__);