Skip to contentSkip to conversation

tests/gem_reset_stats.c: prepare for per engine resets

PATCH In review [email protected] 2 participants 5 messages Nov 18, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/gem_reset_stats.c: prepare for per engine resets

From: Tim Gore <[email protected]>

when checking to make sure that the driver has performed the expected number of resets, this test looks at the reset_count, which is incremented each time the GPU is reset. Upcoming changes in the way GPU hangs are handled mean that in most cases (and in all the cases in this test) only a single GPU engine is reset which does not cause the reset_count to be incremented. This is already causing this test to fail on Android. In this case we can instead look at the batch_active count which is also returned from the i915_get_reset_stats_ioctl and is incremented by both a single engine reset and a full gpu reset. There are differences between the reset_count and the batch_active count, but for establishing that the correct number of resets have occured either can be used. This change enables this test to run successfully on Android and will mean that the test does not break when the TDR patches get merged into the uptream driver.

---
 tests/gem_reset_stats.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)
tests/gem_reset_stats.c +26 -15
index 4cbbb4e..5ec026f 100644
@@ -104,9 +104,9 @@ static int gem_reset_stats(int fd, int ctx_id,
 
 	rs->ctx_id = ctx_id;
 	rs->flags = 0;
-	rs->reset_count = rand();
-	rs->batch_active = rand();
-	rs->batch_pending = rand();
+	rs->reset_count = UINT32_MAX;
+	rs->batch_active = UINT32_MAX;
+	rs->batch_pending = UINT32_MAX;
 	rs->pad = 0;
 
 	do {
@@ -690,6 +690,18 @@ static int get_reset_count(int fd, int ctx)
 	return rs.reset_count;
 }
 
+static int get_active_count(int fd, int ctx)
+{
+	int ret;
+	struct local_drm_i915_reset_stats rs;
+
+	ret = gem_reset_stats(fd, ctx, &rs);
+	if (ret)
+		return ret;
+
+	return rs.batch_active;
+}
+
 static void test_close_pending_ctx(void)
 {
 	int fd, h;
@@ -837,17 +849,16 @@ static void test_reset_count(const bool create_ctx)
 
 	assert_reset_status(fd, ctx, RS_NO_ERROR);
 
-	c1 = get_reset_count(fd, ctx);
-	igt_assert(c1 >= 0);
+	c1 = get_active_count(fd, ctx);
+	igt_assert(c1 == 0);
 
 	h = inject_hang(fd, ctx);
 	igt_assert_lte(0, h);
 	gem_sync(fd, h);
 
 	assert_reset_status(fd, ctx, RS_BATCH_ACTIVE);
-	c2 = get_reset_count(fd, ctx);
-	igt_assert(c2 >= 0);
-	igt_assert(c2 == (c1 + 1));
+	c2 = get_active_count(fd, ctx);
+	igt_assert(c2 == 1);
 
 	igt_fork(child, 1) {
 		igt_drop_root();
@@ -877,9 +888,9 @@ static int _test_params(int fd, int ctx, uint32_t flags, uint32_t pad)
 
 	rs.ctx_id = ctx;
 	rs.flags = flags;
-	rs.reset_count = rand();
-	rs.batch_active = rand();
-	rs.batch_pending = rand();
+	rs.reset_count = UINT32_MAX;
+	rs.batch_active = UINT32_MAX;
+	rs.batch_pending = UINT32_MAX;
 	rs.pad = pad;
 
 	do {
@@ -976,14 +987,14 @@ static void defer_hangcheck(int ring_num)
 
 	igt_skip_on(next_ring == current_ring);
 
-	count_start = get_reset_count(fd, 0);
-	igt_assert_lte(0, count_start);
+	count_start = get_active_count(fd, 0);
+	igt_assert(count_start == 0);
 
 	igt_assert(inject_hang_ring(fd, 0, current_ring->exec, true));
 	while (--seconds) {
 		igt_assert(exec_valid_ring(fd, 0, next_ring->exec));
 
-		count_end = get_reset_count(fd, 0);
+		count_end = get_active_count(fd, 0);
 		igt_assert_lte(0, count_end);
 
 		if (count_end > count_start)
@@ -992,7 +1003,7 @@ static void defer_hangcheck(int ring_num)
 		sleep(1);
 	}
 
-	igt_assert_lt(count_start, count_end);
+	igt_assert(count_end == 1);
 
 	close(fd);
 }
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 20 lines · On Wed, Nov 18, 2015 at 10:24:43AM +0000, [email protected] wrote:

From: Tim Gore <[email protected]>

when checking to make sure that the driver has performed the expected number of resets, this test looks at the reset_count, which is incremented each time the GPU is reset. Upcoming changes in the way GPU hangs are handled mean that in most cases (and in all the cases in this test) only a single GPU engine is reset which does not cause the reset_count to be incremented. This is already causing this test to fail on Android. In this case we can instead look at the batch_active count which is also returned from the i915_get_reset_stats_ioctl and is incremented by both a single engine reset and a full gpu reset. There are differences between the reset_count and the batch_active count, but for establishing that the correct number of resets have occured either can be used. This change enables this test to run successfully on Android and will mean that the test does not break when the TDR patches get merged into the uptream driver.

Quoted 1 line

Why doesn't TDR just count resets correctly?
-Daniel

Quoted 109 lines
---
 tests/gem_reset_stats.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)
tests/gem_reset_stats.c +26 -15
index 4cbbb4e..5ec026f 100644
@@ -104,9 +104,9 @@ static int gem_reset_stats(int fd, int ctx_id,
 
 	rs->ctx_id = ctx_id;
 	rs->flags = 0;
-	rs->reset_count = rand();
-	rs->batch_active = rand();
-	rs->batch_pending = rand();
+	rs->reset_count = UINT32_MAX;
+	rs->batch_active = UINT32_MAX;
+	rs->batch_pending = UINT32_MAX;
 	rs->pad = 0;
 
 	do {
@@ -690,6 +690,18 @@ static int get_reset_count(int fd, int ctx)
 	return rs.reset_count;
 }
 
+static int get_active_count(int fd, int ctx)
+{
+	int ret;
+	struct local_drm_i915_reset_stats rs;
+
+	ret = gem_reset_stats(fd, ctx, &rs);
+	if (ret)
+		return ret;
+
+	return rs.batch_active;
+}
+
 static void test_close_pending_ctx(void)
 {
 	int fd, h;
@@ -837,17 +849,16 @@ static void test_reset_count(const bool create_ctx)
 
 	assert_reset_status(fd, ctx, RS_NO_ERROR);
 
-	c1 = get_reset_count(fd, ctx);
-	igt_assert(c1 >= 0);
+	c1 = get_active_count(fd, ctx);
+	igt_assert(c1 == 0);
 
 	h = inject_hang(fd, ctx);
 	igt_assert_lte(0, h);
 	gem_sync(fd, h);
 
 	assert_reset_status(fd, ctx, RS_BATCH_ACTIVE);
-	c2 = get_reset_count(fd, ctx);
-	igt_assert(c2 >= 0);
-	igt_assert(c2 == (c1 + 1));
+	c2 = get_active_count(fd, ctx);
+	igt_assert(c2 == 1);
 
 	igt_fork(child, 1) {
 		igt_drop_root();
@@ -877,9 +888,9 @@ static int _test_params(int fd, int ctx, uint32_t flags, uint32_t pad)
 
 	rs.ctx_id = ctx;
 	rs.flags = flags;
-	rs.reset_count = rand();
-	rs.batch_active = rand();
-	rs.batch_pending = rand();
+	rs.reset_count = UINT32_MAX;
+	rs.batch_active = UINT32_MAX;
+	rs.batch_pending = UINT32_MAX;
 	rs.pad = pad;
 
 	do {
@@ -976,14 +987,14 @@ static void defer_hangcheck(int ring_num)
 
 	igt_skip_on(next_ring == current_ring);
 
-	count_start = get_reset_count(fd, 0);
-	igt_assert_lte(0, count_start);
+	count_start = get_active_count(fd, 0);
+	igt_assert(count_start == 0);
 
 	igt_assert(inject_hang_ring(fd, 0, current_ring->exec, true));
 	while (--seconds) {
 		igt_assert(exec_valid_ring(fd, 0, next_ring->exec));
 
-		count_end = get_reset_count(fd, 0);
+		count_end = get_active_count(fd, 0);
 		igt_assert_lte(0, count_end);
 
 		if (count_end > count_start)
@@ -992,7 +1003,7 @@ static void defer_hangcheck(int ring_num)
 		sleep(1);
 	}
 
-	igt_assert_lt(count_start, count_end);
+	igt_assert(count_end == 1);
 
 	close(fd);
 }
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#2 lore raw

Tim Gore
Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ

Quoted 30 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, November 18, 2015 11:54 AM
To: Gore, Tim
Cc: [email protected]; [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] tests/gem_reset_stats.c: prepare for per engine resets

Quoted 19 lines · On Wed, Nov 18, 2015 at 10:24:43AM +0000, [email protected] wrote:

From: Tim Gore <[email protected]>

when checking to make sure that the driver has performed the expected number of resets, this test looks at the reset_count, which is incremented each time the GPU is reset. Upcoming changes in the way GPU hangs are handled mean that in most cases (and in all the cases in this
test) only a single GPU engine is reset which does not cause the reset_count to be incremented. This is already causing this test to fail on Android. In this case we can instead look at the batch_active count which is also returned from the i915_get_reset_stats_ioctl and is incremented by both a single engine reset and a full gpu reset. There are differences between the reset_count and the batch_active count, but for establishing that the correct number of resets have occured either can be used.
This change enables this test to run successfully on Android and will mean that the test does not break when the TDR patches get merged into the uptream driver.

Quoted 5 lines
Quoted 1 line

Why doesn't TDR just count resets correctly?
-Daniel

It does. It just doesn't do gpu resets for most hangs. Instead it resets as single command streamer which is much less intrusive and loses the minimum amount of work.
Tim

Quoted 106 lines
Quoted 106 lines
---
 tests/gem_reset_stats.c | 41
++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)
tests/gem_reset_stats.c index renamed from tests/gem_reset_stats.c +0 -0

4cbbb4e..5ec026f 100644

tests/gem_reset_stats.c +18 -8
@@ -104,9 +104,9 @@ static int gem_reset_stats(int fd, int ctx_id,
 
 	rs->ctx_id = ctx_id;
 	rs->flags = 0;
-	rs->reset_count = rand();
-	rs->batch_active = rand();
-	rs->batch_pending = rand();
+	rs->reset_count = UINT32_MAX;
+	rs->batch_active = UINT32_MAX;
+	rs->batch_pending = UINT32_MAX;
 	rs->pad = 0;
 
 	do {
@@ -690,6 +690,18 @@ static int get_reset_count(int fd, int ctx)
 	return rs.reset_count;
 }
 
+static int get_active_count(int fd, int ctx) {
+	int ret;
+	struct local_drm_i915_reset_stats rs;
+
+	ret = gem_reset_stats(fd, ctx, &rs);
+	if (ret)
+		return ret;
+
+	return rs.batch_active;
+}
+
 static void test_close_pending_ctx(void)  {
 	int fd, h;
@@ -837,17 +849,16 @@ static void test_reset_count(const bool
 create_ctx)
 
 	assert_reset_status(fd, ctx, RS_NO_ERROR);
 
-	c1 = get_reset_count(fd, ctx);
-	igt_assert(c1 >= 0);
+	c1 = get_active_count(fd, ctx);
+	igt_assert(c1 == 0);
 
 	h = inject_hang(fd, ctx);
 	igt_assert_lte(0, h);
 	gem_sync(fd, h);
 
 	assert_reset_status(fd, ctx, RS_BATCH_ACTIVE);
-	c2 = get_reset_count(fd, ctx);
-	igt_assert(c2 >= 0);
-	igt_assert(c2 == (c1 + 1));
+	c2 = get_active_count(fd, ctx);
+	igt_assert(c2 == 1);
 
 	igt_fork(child, 1) {
tests/gem_reset_stats.c +3 -3
 		igt_drop_root();
@@ -877,9 +888,9 @@ static int _test_params(int fd, int ctx, uint32_t
 flags, uint32_t pad)
 
 	rs.ctx_id = ctx;
 	rs.flags = flags;
-	rs.reset_count = rand();
-	rs.batch_active = rand();
-	rs.batch_pending = rand();
+	rs.reset_count = UINT32_MAX;
+	rs.batch_active = UINT32_MAX;
+	rs.batch_pending = UINT32_MAX;
 	rs.pad = pad;
 
tests/gem_reset_stats.c +4 -5
 	do {
@@ -976,14 +987,14 @@ static void defer_hangcheck(int ring_num)
 
 	igt_skip_on(next_ring == current_ring);
 
-	count_start = get_reset_count(fd, 0);
-	igt_assert_lte(0, count_start);
+	count_start = get_active_count(fd, 0);
+	igt_assert(count_start == 0);
 
 	igt_assert(inject_hang_ring(fd, 0, current_ring->exec, true));
 	while (--seconds) {
 		igt_assert(exec_valid_ring(fd, 0, next_ring->exec));
 
-		count_end = get_reset_count(fd, 0);
+		count_end = get_active_count(fd, 0);
 		igt_assert_lte(0, count_end);
 
 		if (count_end > count_start)
@@ -992,7 +1003,7 @@ static void defer_hangcheck(int ring_num)
 		sleep(1);
 	}
 
-	igt_assert_lt(count_start, count_end);
+	igt_assert(count_end == 1);
 
 	close(fd);
 }
--

1.9.1

Quoted 9 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 36 lines · Tim

Tim Gore
Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ

Quoted 30 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, November 18, 2015 11:54 AM
To: Gore, Tim
Cc: [email protected]; [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] tests/gem_reset_stats.c: prepare for per engine resets

Quoted 19 lines · On Wed, Nov 18, 2015 at 10:24:43AM +0000, [email protected] wrote:

From: Tim Gore <[email protected]>

when checking to make sure that the driver has performed the expected number of resets, this test looks at the reset_count, which is incremented each time the GPU is reset. Upcoming changes in the way GPU hangs are handled mean that in most cases (and in all the cases in this
test) only a single GPU engine is reset which does not cause the reset_count to be incremented. This is already causing this test to fail on Android. In this case we can instead look at the batch_active count which is also returned from the i915_get_reset_stats_ioctl and is incremented by both a single engine reset and a full gpu reset. There are differences between the reset_count and the batch_active count, but for establishing that the correct number of resets have occured either can be used.
This change enables this test to run successfully on Android and will mean that the test does not break when the TDR patches get merged into the uptream driver.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Why doesn't TDR just count resets correctly?
-Daniel

It does. It just doesn't do gpu resets for most hangs. Instead it resets as single command streamer which is much less intrusive and loses the minimum amount of work.

Again: Why does TDR not count engine resets as resets? Afaiui that seems to be the problem you're working around here.
-Daniel

Quoted 117 lines

Tim

Quoted 115 lines
Quoted 106 lines
---
 tests/gem_reset_stats.c | 41
++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)
tests/gem_reset_stats.c index renamed from tests/gem_reset_stats.c +0 -0

4cbbb4e..5ec026f 100644

tests/gem_reset_stats.c +18 -8
@@ -104,9 +104,9 @@ static int gem_reset_stats(int fd, int ctx_id,
 
 	rs->ctx_id = ctx_id;
 	rs->flags = 0;
-	rs->reset_count = rand();
-	rs->batch_active = rand();
-	rs->batch_pending = rand();
+	rs->reset_count = UINT32_MAX;
+	rs->batch_active = UINT32_MAX;
+	rs->batch_pending = UINT32_MAX;
 	rs->pad = 0;
 
 	do {
@@ -690,6 +690,18 @@ static int get_reset_count(int fd, int ctx)
 	return rs.reset_count;
 }
 
+static int get_active_count(int fd, int ctx) {
+	int ret;
+	struct local_drm_i915_reset_stats rs;
+
+	ret = gem_reset_stats(fd, ctx, &rs);
+	if (ret)
+		return ret;
+
+	return rs.batch_active;
+}
+
 static void test_close_pending_ctx(void)  {
 	int fd, h;
@@ -837,17 +849,16 @@ static void test_reset_count(const bool
 create_ctx)
 
 	assert_reset_status(fd, ctx, RS_NO_ERROR);
 
-	c1 = get_reset_count(fd, ctx);
-	igt_assert(c1 >= 0);
+	c1 = get_active_count(fd, ctx);
+	igt_assert(c1 == 0);
 
 	h = inject_hang(fd, ctx);
 	igt_assert_lte(0, h);
 	gem_sync(fd, h);
 
 	assert_reset_status(fd, ctx, RS_BATCH_ACTIVE);
-	c2 = get_reset_count(fd, ctx);
-	igt_assert(c2 >= 0);
-	igt_assert(c2 == (c1 + 1));
+	c2 = get_active_count(fd, ctx);
+	igt_assert(c2 == 1);
 
 	igt_fork(child, 1) {
tests/gem_reset_stats.c +3 -3
 		igt_drop_root();
@@ -877,9 +888,9 @@ static int _test_params(int fd, int ctx, uint32_t
 flags, uint32_t pad)
 
 	rs.ctx_id = ctx;
 	rs.flags = flags;
-	rs.reset_count = rand();
-	rs.batch_active = rand();
-	rs.batch_pending = rand();
+	rs.reset_count = UINT32_MAX;
+	rs.batch_active = UINT32_MAX;
+	rs.batch_pending = UINT32_MAX;
 	rs.pad = pad;
 
tests/gem_reset_stats.c +4 -5
 	do {
@@ -976,14 +987,14 @@ static void defer_hangcheck(int ring_num)
 
 	igt_skip_on(next_ring == current_ring);
 
-	count_start = get_reset_count(fd, 0);
-	igt_assert_lte(0, count_start);
+	count_start = get_active_count(fd, 0);
+	igt_assert(count_start == 0);
 
 	igt_assert(inject_hang_ring(fd, 0, current_ring->exec, true));
 	while (--seconds) {
 		igt_assert(exec_valid_ring(fd, 0, next_ring->exec));
 
-		count_end = get_reset_count(fd, 0);
+		count_end = get_active_count(fd, 0);
 		igt_assert_lte(0, count_end);
 
 		if (count_end > count_start)
@@ -992,7 +1003,7 @@ static void defer_hangcheck(int ring_num)
 		sleep(1);
 	}
 
-	igt_assert_lt(count_start, count_end);
+	igt_assert(count_end == 1);
 
 	close(fd);
 }
--

1.9.1

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#4 lore raw

Tim Gore
Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ

Quoted 54 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, November 18, 2015 2:12 PM
To: Gore, Tim
Cc: Daniel Vetter; [email protected]; [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] tests/gem_reset_stats.c: prepare for per engine resets

Quoted 30 lines · Tim

Tim Gore
Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ

Quoted 23 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, November 18, 2015 11:54 AM
To: Gore, Tim
Cc: [email protected]; [email protected]; Wood, Thomas
Subject: Re: [Intel-gfx] [PATCH i-g-t] tests/gem_reset_stats.c:
prepare for per engine resets

Quoted 12 lines · On Wed, Nov 18, 2015 at 10:24:43AM +0000, [email protected] wrote:

From: Tim Gore <[email protected]>

when checking to make sure that the driver has performed the expected number of resets, this test looks at the reset_count, which is incremented each time the GPU is reset. Upcoming changes in the way GPU hangs are handled mean that in most cases (and in all the cases in this
test) only a single GPU engine is reset which does not cause the reset_count to be incremented. This is already causing this test to fail on Android. In this case we can instead look at the batch_active count which is also returned from the i915_get_reset_stats_ioctl and is incremented by both a single engine

reset and a full gpu reset.

Quoted 12 lines
Quoted 12 lines
Quoted 8 lines

There are differences between the reset_count and the batch_active count, but for establishing that the correct number of resets have occured either can be used.
This change enables this test to run successfully on Android and will mean that the test does not break when the TDR patches get merged into the uptream driver.

Why doesn't TDR just count resets correctly?
-Daniel

Quoted 8 lines
Quoted 3 lines

It does. It just doesn't do gpu resets for most hangs. Instead it resets as single command streamer which is much less intrusive and loses the minimum amount of work.

Again: Why does TDR not count engine resets as resets? Afaiui that seems to be the problem you're working around here.
-Daniel

This was not intended as a workaround, just to align the test with the way TDR is being implemented. I assume TDR chose not the alter the meaning of the reset_counter as this is implicitly part of the interface to userland. We can change reset_counter to count both GPU resets and engine resets but I think this may have knock on effects for the openGL robustness interface which uses this Ioctl. I'll check with the openGL team as I know they are still working on this.

Quoted 117 lines
Quoted 116 lines

Tim

Quoted 114 lines
Quoted 106 lines
---
 tests/gem_reset_stats.c | 41
++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)
tests/gem_reset_stats.c +18 -8
index 4cbbb4e..5ec026f 100644
@@ -104,9 +104,9 @@ static int gem_reset_stats(int fd, int ctx_id,
 
 	rs->ctx_id = ctx_id;
 	rs->flags = 0;
-	rs->reset_count = rand();
-	rs->batch_active = rand();
-	rs->batch_pending = rand();
+	rs->reset_count = UINT32_MAX;
+	rs->batch_active = UINT32_MAX;
+	rs->batch_pending = UINT32_MAX;
 	rs->pad = 0;
 
 	do {
@@ -690,6 +690,18 @@ static int get_reset_count(int fd, int ctx)
 	return rs.reset_count;
 }
 
+static int get_active_count(int fd, int ctx) {
+	int ret;
+	struct local_drm_i915_reset_stats rs;
+
+	ret = gem_reset_stats(fd, ctx, &rs);
+	if (ret)
+		return ret;
+
+	return rs.batch_active;
+}
+
 static void test_close_pending_ctx(void)  {
 	int fd, h;
@@ -837,17 +849,16 @@ static void test_reset_count(const bool
 create_ctx)
 
 	assert_reset_status(fd, ctx, RS_NO_ERROR);
 
-	c1 = get_reset_count(fd, ctx);
-	igt_assert(c1 >= 0);
+	c1 = get_active_count(fd, ctx);
+	igt_assert(c1 == 0);
 
 	h = inject_hang(fd, ctx);
 	igt_assert_lte(0, h);
 	gem_sync(fd, h);
 
 	assert_reset_status(fd, ctx, RS_BATCH_ACTIVE);
-	c2 = get_reset_count(fd, ctx);
-	igt_assert(c2 >= 0);
-	igt_assert(c2 == (c1 + 1));
+	c2 = get_active_count(fd, ctx);
+	igt_assert(c2 == 1);
 
 	igt_fork(child, 1) {
tests/gem_reset_stats.c +3 -3
 		igt_drop_root();
@@ -877,9 +888,9 @@ static int _test_params(int fd, int ctx,
 uint32_t flags, uint32_t pad)
 
 	rs.ctx_id = ctx;
 	rs.flags = flags;
-	rs.reset_count = rand();
-	rs.batch_active = rand();
-	rs.batch_pending = rand();
+	rs.reset_count = UINT32_MAX;
+	rs.batch_active = UINT32_MAX;
+	rs.batch_pending = UINT32_MAX;
 	rs.pad = pad;
 
tests/gem_reset_stats.c +4 -5
 	do {
@@ -976,14 +987,14 @@ static void defer_hangcheck(int ring_num)
 
 	igt_skip_on(next_ring == current_ring);
 
-	count_start = get_reset_count(fd, 0);
-	igt_assert_lte(0, count_start);
+	count_start = get_active_count(fd, 0);
+	igt_assert(count_start == 0);
 
 	igt_assert(inject_hang_ring(fd, 0, current_ring->exec, true));
 	while (--seconds) {
 		igt_assert(exec_valid_ring(fd, 0, next_ring->exec));
 
-		count_end = get_reset_count(fd, 0);
+		count_end = get_active_count(fd, 0);
 		igt_assert_lte(0, count_end);
 
 		if (count_end > count_start)
@@ -992,7 +1003,7 @@ static void defer_hangcheck(int ring_num)
 		sleep(1);
 	}
 
-	igt_assert_lt(count_start, count_end);
+	igt_assert(count_end == 1);
 
 	close(fd);
 }
--

1.9.1

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Daniel Vetter
Software Engineer, Intel Corporation http://blog.ffwll.ch

Quoted 4 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx