diff mbox series

drm/i915/selftests: Wait only on the expected barrier

Message ID 20191129103455.744389-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915/selftests: Wait only on the expected barrier | expand

Commit Message

Chris Wilson Nov. 29, 2019, 10:34 a.m. UTC
Wait on only the last request on the kernel_context after emitting a
barrier so that we do not wait for everything in general and by doing so
cause an accidental emission of the barrier!

Bugzilla; https://bugs.freedesktop.org/show_bug.cgi?id=112405
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 .../drm/i915/gt/selftest_engine_heartbeat.c   | 24 ++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

Comments

Tvrtko Ursulin Nov. 29, 2019, 11:39 a.m. UTC | #1
On 29/11/2019 10:34, Chris Wilson wrote:
> Wait on only the last request on the kernel_context after emitting a
> barrier so that we do not wait for everything in general and by doing so
> cause an accidental emission of the barrier!
> 
> Bugzilla; https://bugs.freedesktop.org/show_bug.cgi?id=112405
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   .../drm/i915/gt/selftest_engine_heartbeat.c   | 24 ++++++++++++++++++-
>   1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c b/drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c
> index 0b1148cf3f61..5227e79204a5 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c
> @@ -11,6 +11,28 @@
>   #include "intel_gt_requests.h"
>   #include "i915_selftest.h"
>   
> +static int timeline_sync(struct intel_timeline *tl)
> +{
> +	struct dma_fence *fence;
> +	long timeout;
> +
> +	fence = i915_active_fence_get(&tl->last_request);
> +	if (!fence)
> +		return 0;
> +
> +	timeout = dma_fence_wait_timeout(fence, true, HZ / 2);
> +	dma_fence_put(fence);
> +	if (timeout < 0)
> +		return timeout;
> +
> +	return 0;
> +}
> +
> +static int engine_sync_barrier(struct intel_engine_cs *engine)
> +{
> +	return timeline_sync(engine->kernel_context->timeline);
> +}
> +
>   struct pulse {
>   	struct i915_active active;
>   	struct kref kref;
> @@ -90,7 +112,7 @@ static int __live_idle_pulse(struct intel_engine_cs *engine,
>   
>   	GEM_BUG_ON(!llist_empty(&engine->barrier_tasks));
>   
> -	if (intel_gt_retire_requests_timeout(engine->gt, HZ / 5)) {
> +	if (engine_sync_barrier(engine)) {
>   		struct drm_printer m = drm_err_printer("pulse");
>   
>   		pr_err("%s: no heartbeat pulse?\n", engine->name);
> 

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

Regards,

Tvrtko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c b/drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c
index 0b1148cf3f61..5227e79204a5 100644
--- a/drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c
@@ -11,6 +11,28 @@ 
 #include "intel_gt_requests.h"
 #include "i915_selftest.h"
 
+static int timeline_sync(struct intel_timeline *tl)
+{
+	struct dma_fence *fence;
+	long timeout;
+
+	fence = i915_active_fence_get(&tl->last_request);
+	if (!fence)
+		return 0;
+
+	timeout = dma_fence_wait_timeout(fence, true, HZ / 2);
+	dma_fence_put(fence);
+	if (timeout < 0)
+		return timeout;
+
+	return 0;
+}
+
+static int engine_sync_barrier(struct intel_engine_cs *engine)
+{
+	return timeline_sync(engine->kernel_context->timeline);
+}
+
 struct pulse {
 	struct i915_active active;
 	struct kref kref;
@@ -90,7 +112,7 @@  static int __live_idle_pulse(struct intel_engine_cs *engine,
 
 	GEM_BUG_ON(!llist_empty(&engine->barrier_tasks));
 
-	if (intel_gt_retire_requests_timeout(engine->gt, HZ / 5)) {
+	if (engine_sync_barrier(engine)) {
 		struct drm_printer m = drm_err_printer("pulse");
 
 		pr_err("%s: no heartbeat pulse?\n", engine->name);