Skip to contentSkip to conversation

Fence register stuff

PATCH In review [email protected] 3 participants 13 messages Apr 9, 2013 – Apr 11, 2013

lore
Share & tools
lore
#0 lore raw

cover Fence register stuff

Some fence stuff related to the 32 fence registers/256KB max fence stride kernel changes.

I'm not sure gem_tiling_max_stride does any good since you can only use it to verify that the tested fence stride <= max fence stride. Also I ran it only on ILK,SNB and IVB, so at least the Gen2-3 code is totally untested.

#1 lore raw

PATCH 1/3 tests/gem_fenced_exec_thrash: Increase MAX_FENCES to 32

From: Ville Syrjälä <[email protected]>

IVB+ supports 32 fence registers, bump the maximum in the test.

---
 tests/gem_fenced_exec_thrash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/gem_fenced_exec_thrash.c +1 -1
index 8281449..b17eba2 100644
@@ -45,7 +45,7 @@
 
 #define BATCH_SIZE 4096
 
-#define MAX_FENCES 16
+#define MAX_FENCES 32
 
 #define MI_BATCH_BUFFER_END	(0xA<<23)
 
Signature · 6 lines
1.8.1.5

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

Re: [PATCH i-g-t 1/3] tests/gem_fenced_exec_thrash: Increase MAX_FENCES to 32

Quoted 3 lines · On Tue, Apr 09, 2013 at 03:25:37PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

IVB+ supports 32 fence registers, bump the maximum in the test.

Then again the test is only relevant for gen2/3 (and 1), and I don't forsee the use of fences for GPU surface tiling being resurrected. On the other hand, the test makes sure that future gpus ignore the old restrictions.

One feature request for the test: feed in > max_fences expect ENOSPC/EDEADLCK on gen2/3.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw

PATCH 1/1 tests/gem_fenced_exec_thrash: Test with > max fences

From: Ville Syrjälä <[email protected]>

Make sure the kernel returns EDEADLK when the number of fences is exceeded for gen2-3. For gen4+ the test makes sure the kernel ignores the EXEC_OBJECT_NEEDS_FENCE flag.

Note that I changed the code not to round the num_fences to an even number. Not sure why that was there, and if there's a reason for it, we need to add it back.

---
 tests/gem_fenced_exec_thrash.c | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)
tests/gem_fenced_exec_thrash.c +25 -13
index ca88c53..c8a2c58 100644
@@ -38,6 +38,7 @@
 #include <i915_drm.h>
 
 #include "drmtest.h"
+#include "intel_gpu_tools.h"
 
 #define WIDTH 1024
 #define HEIGHT 1024
@@ -47,8 +48,6 @@
 
 #define MAX_FENCES 32
 
-#define MI_BATCH_BUFFER_END	(0xA<<23)
-
 /*
  * Testcase: execbuf fence accounting
  *
@@ -95,7 +94,7 @@ static int get_num_fences(int fd)
 	printf ("total %d fences\n", val);
 	assert(val > 4);
 
-	return val - 2;
+	return val;
 }
 
 static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t handle)
@@ -106,23 +105,19 @@ static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t han
 	reloc->write_domain = 0;
 }
 
-int
-main(int argc, char **argv)
+static void run_test(int fd, int num_fences, int expected_errno)
 {
 	struct drm_i915_gem_execbuffer2 execbuf[2];
-	struct drm_i915_gem_exec_object2 exec[2][2*MAX_FENCES+1];
-	struct drm_i915_gem_relocation_entry reloc[2*MAX_FENCES];
+	struct drm_i915_gem_exec_object2 exec[2][2*MAX_FENCES+3];
+	struct drm_i915_gem_relocation_entry reloc[2*MAX_FENCES+2];
 
-	int fd = drm_open_any();
-	int i, n, num_fences;
+	int i, n;
 	int loop = 1000;
 
 	memset(execbuf, 0, sizeof(execbuf));
 	memset(exec, 0, sizeof(exec));
 	memset(reloc, 0, sizeof(reloc));
 
-	num_fences = get_num_fences(fd) & ~1;
-	assert(num_fences <= MAX_FENCES);
 	for (n = 0; n < 2*num_fences; n++) {
 		uint32_t handle = tiled_bo_create(fd);
 		exec[1][2*num_fences - n-1].handle = exec[0][n].handle = handle;
@@ -148,13 +143,30 @@ main(int argc, char **argv)
 		ret = drmIoctl(fd,
 			       DRM_IOCTL_I915_GEM_EXECBUFFER2,
 			       &execbuf[0]);
-		assert(ret == 0);
+		assert(expected_errno ?
+		       ret < 0 && errno == expected_errno :
+		       ret == 0);
 
 		ret = drmIoctl(fd,
 			       DRM_IOCTL_I915_GEM_EXECBUFFER2,
 			       &execbuf[1]);
-		assert(ret == 0);
+		assert(expected_errno ?
+		       ret < 0 && errno == expected_errno :
+		       ret == 0);
 	} while (--loop);
+}
+
+int
+main(int argc, char **argv)
+{
+	int fd = drm_open_any();
+	int num_fences = get_num_fences(fd);
+	uint32_t devid = intel_get_drm_devid(fd);
+
+	assert(num_fences <= MAX_FENCES);
+
+	run_test(fd, num_fences - 2, 0);
+	run_test(fd, num_fences + 1, intel_gen(devid) >= 4 ? 0 : EDEADLK);
 
 	close(fd);
 
Signature · 6 lines
1.8.1.5

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

Re: [PATCH] tests/gem_fenced_exec_thrash: Test with > max fences

Quoted 11 lines · On Thu, Apr 11, 2013 at 08:43:40PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

Make sure the kernel returns EDEADLK when the number of fences is exceeded for gen2-3. For gen4+ the test makes sure the kernel ignores the EXEC_OBJECT_NEEDS_FENCE flag.

Note that I changed the code not to round the num_fences to an even number. Not sure why that was there, and if there's a reason for it, we need to add it back.

Looks nice, merged.
-Daniel

Quoted 102 lines
---
 tests/gem_fenced_exec_thrash.c | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)
tests/gem_fenced_exec_thrash.c +25 -13
index ca88c53..c8a2c58 100644
@@ -38,6 +38,7 @@
 #include <i915_drm.h>
 
 #include "drmtest.h"
+#include "intel_gpu_tools.h"
 
 #define WIDTH 1024
 #define HEIGHT 1024
@@ -47,8 +48,6 @@
 
 #define MAX_FENCES 32
 
-#define MI_BATCH_BUFFER_END	(0xA<<23)
-
 /*
  * Testcase: execbuf fence accounting
  *
@@ -95,7 +94,7 @@ static int get_num_fences(int fd)
 	printf ("total %d fences\n", val);
 	assert(val > 4);
 
-	return val - 2;
+	return val;
 }
 
 static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t handle)
@@ -106,23 +105,19 @@ static void fill_reloc(struct drm_i915_gem_relocation_entry *reloc, uint32_t han
 	reloc->write_domain = 0;
 }
 
-int
-main(int argc, char **argv)
+static void run_test(int fd, int num_fences, int expected_errno)
 {
 	struct drm_i915_gem_execbuffer2 execbuf[2];
-	struct drm_i915_gem_exec_object2 exec[2][2*MAX_FENCES+1];
-	struct drm_i915_gem_relocation_entry reloc[2*MAX_FENCES];
+	struct drm_i915_gem_exec_object2 exec[2][2*MAX_FENCES+3];
+	struct drm_i915_gem_relocation_entry reloc[2*MAX_FENCES+2];
 
-	int fd = drm_open_any();
-	int i, n, num_fences;
+	int i, n;
 	int loop = 1000;
 
 	memset(execbuf, 0, sizeof(execbuf));
 	memset(exec, 0, sizeof(exec));
 	memset(reloc, 0, sizeof(reloc));
 
-	num_fences = get_num_fences(fd) & ~1;
-	assert(num_fences <= MAX_FENCES);
 	for (n = 0; n < 2*num_fences; n++) {
 		uint32_t handle = tiled_bo_create(fd);
 		exec[1][2*num_fences - n-1].handle = exec[0][n].handle = handle;
@@ -148,13 +143,30 @@ main(int argc, char **argv)
 		ret = drmIoctl(fd,
 			       DRM_IOCTL_I915_GEM_EXECBUFFER2,
 			       &execbuf[0]);
-		assert(ret == 0);
+		assert(expected_errno ?
+		       ret < 0 && errno == expected_errno :
+		       ret == 0);
 
 		ret = drmIoctl(fd,
 			       DRM_IOCTL_I915_GEM_EXECBUFFER2,
 			       &execbuf[1]);
-		assert(ret == 0);
+		assert(expected_errno ?
+		       ret < 0 && errno == expected_errno :
+		       ret == 0);
 	} while (--loop);
+}
+
+int
+main(int argc, char **argv)
+{
+	int fd = drm_open_any();
+	int num_fences = get_num_fences(fd);
+	uint32_t devid = intel_get_drm_devid(fd);
+
+	assert(num_fences <= MAX_FENCES);
+
+	run_test(fd, num_fences - 2, 0);
+	run_test(fd, num_fences + 1, intel_gen(devid) >= 4 ? 0 : EDEADLK);
 
 	close(fd);
 
Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#5 lore raw

PATCH 2/3 tests: Use gem_available_fences()

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

lib/drmtest.c provides gem_available_fences(). Use it where appropriate.

---
 tests/gem_fence_thrash.c       | 8 ++------
 tests/gem_fenced_exec_thrash.c | 8 ++------
 tests/gem_stress.c             | 8 ++------
 3 files changed, 6 insertions(+), 18 deletions(-)
tests/gem_fence_thrash.c +2 -6
index 01fd0f6..e1cfc4e 100644
@@ -169,19 +169,15 @@ static int run_test(int threads_per_fence, void *f, int tiling,
 		    int surfaces_per_thread)
 {
 	struct test t;
-	drm_i915_getparam_t gp;
 	pthread_t *threads;
 	int n, num_fences, num_threads;
-	int ret;
 
 	t.fd = drm_open_any();
 	t.tiling = tiling;
 	t.num_surfaces = surfaces_per_thread;
 
-	gp.param = I915_PARAM_NUM_FENCES_AVAIL;
-	gp.value = &num_fences;
-	ret = ioctl(t.fd, DRM_IOCTL_I915_GETPARAM, &gp);
-	assert (ret == 0);
+	num_fences = gem_available_fences(t.fd);
+	assert (num_fences > 0);
 
 	num_threads = threads_per_fence * num_fences;
 
tests/gem_fenced_exec_thrash.c +2 -6
index b17eba2..ca88c53 100644
@@ -88,13 +88,9 @@ batch_create (int fd)
 
 static int get_num_fences(int fd)
 {
-	drm_i915_getparam_t gp;
-	int ret, val;
+	int val;
 
-	gp.param = I915_PARAM_NUM_FENCES_AVAIL;
-	gp.value = &val;
-	ret = drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
-	assert (ret == 0);
+	val = gem_available_fences(fd);
 
 	printf ("total %d fences\n", val);
 	assert(val > 4);
tests/gem_stress.c +2 -6
index 54597af..9b31a69 100644
@@ -605,13 +605,9 @@ static void copy_tiles(unsigned *permutation)
 
 static int get_num_fences(void)
 {
-	drm_i915_getparam_t gp;
-	int ret, val;
+	int val;
 
-	gp.param = I915_PARAM_NUM_FENCES_AVAIL;
-	gp.value = &val;
-	ret = drmIoctl(drm_fd, DRM_IOCTL_I915_GETPARAM, &gp);
-	assert (ret == 0);
+	val = gem_available_fences(drm_fd);
 
 	printf ("total %d fences\n", val);
 	assert(val > 4);
Signature · 6 lines
1.8.1.5

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

PATCH 3/3 tests/gem_tiling_max_stride: Add a test for max fence stride

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

gem_tiling_max_stride writes a data pattern to an X-tiled buffer using the maximum supported stride, reads the data back as linear, and verifies that the data didn't get scrambled on the way.

---
 tests/Makefile.am             |   1 +
 tests/gem_tiling_max_stride.c | 118 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+)
 create mode 100644 tests/gem_tiling_max_stride.c
tests/Makefile.am +1 -0
index f8758cd..e147e4e 100644
@@ -99,6 +99,7 @@ TESTS_progs = \
 	gem_ctx_bad_exec \
 	gem_ctx_basic \
 	gem_reg_read \
+	gem_tiling_max_stride \
 	$(NOUVEAU_TESTS) \
 	prime_self_import \
 	prime_udl \
tests/gem_tiling_max_stride.c new file +118 -0

118 lines not on this page · raw message

Signature · 6 lines
1.8.1.5

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

Re: [PATCH i-g-t 3/3] tests/gem_tiling_max_stride: Add a test for max fence stride

Quoted 5 lines · On Tue, Apr 09, 2013 at 03:25:39PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

gem_tiling_max_stride writes a data pattern to an X-tiled buffer using the maximum supported stride, reads the data back as linear, and verifies that the data didn't get scrambled on the way.

And please also check that stride > max is rejected. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#8 lore raw

PATCH v2 1/1 tests/gem_tiling_max_stride: Add a test for max fence stride

From: Ville Syrjälä <[email protected]>

gem_tiling_max_stride writes a data pattern to an X-tiled buffer using the maximum supported stride, reads the data back as linear, and verifies that the data didn't get scrambled on the way.

The test also checks that some invalid stride values are rejected properly.

v2: Check invalid strides

---
 tests/Makefile.am             |   1 +
 tests/gem_tiling_max_stride.c | 141 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)
 create mode 100644 tests/gem_tiling_max_stride.c
tests/Makefile.am +1 -0
index f8758cd..e147e4e 100644
@@ -99,6 +99,7 @@ TESTS_progs = \
 	gem_ctx_bad_exec \
 	gem_ctx_basic \
 	gem_reg_read \
+	gem_tiling_max_stride \
 	$(NOUVEAU_TESTS) \
 	prime_self_import \
 	prime_udl \
tests/gem_tiling_max_stride.c new file +141 -0

141 lines not on this page · raw message

Signature · 6 lines
1.8.1.5

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

Re: [PATCH i-g-t v2] tests/gem_tiling_max_stride: Add a test for max fence stride

Quoted 10 lines · On Tue, Apr 09, 2013 at 04:41:42PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

gem_tiling_max_stride writes a data pattern to an X-tiled buffer using the maximum supported stride, reads the data back as linear, and verifies that the data didn't get scrambled on the way.

The test also checks that some invalid stride values are rejected properly.

v2: Check invalid strides

tile_width is 512 on gen3, and 128 on gen2 for X-tiling and the tile_height is 8 and 16 respectively.

For test_tiling(), just test both tiling modes, and include a tile_width/2 and (max-tile_width+1). Otherwise those negative tests look good.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#10 lore raw

PATCH v4 1/1 tests/gem_tiling_max_stride: Add a test for max fence stride

From: Ville Syrjälä <[email protected]>

gem_tiling_max_stride writes a data pattern to an X-tiled buffer using the maximum supported stride, reads the data back as linear, and verifies that the data didn't get scrambled on the way.

The test also checks that some invalid stride values are rejected properly.

v2: Check invalid strides
v3: Check invalid stride with Y-tiling
Include a few more invalid stride values
Fix gen3 X-tile size
v4: A few more invalid strides :)
Drop the useless memset()

---
 tests/Makefile.am             |   1 +
 tests/gem_tiling_max_stride.c | 153 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 154 insertions(+)
 create mode 100644 tests/gem_tiling_max_stride.c
tests/Makefile.am +1 -0
index f8758cd..e147e4e 100644
@@ -99,6 +99,7 @@ TESTS_progs = \
 	gem_ctx_bad_exec \
 	gem_ctx_basic \
 	gem_reg_read \
+	gem_tiling_max_stride \
 	$(NOUVEAU_TESTS) \
 	prime_self_import \
 	prime_udl \
tests/gem_tiling_max_stride.c new file +153 -0

153 lines not on this page · raw message

Signature · 6 lines
1.8.1.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v4 1/1
#11 lore raw

Re: [PATCH i-g-t v4] tests/gem_tiling_max_stride: Add a test for max fence stride

Quoted 9 lines · On Tue, Apr 09, 2013 at 05:45:37PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

gem_tiling_max_stride writes a data pattern to an X-tiled buffer using the maximum supported stride, reads the data back as linear, and verifies that the data didn't get scrambled on the way.

The test also checks that some invalid stride values are rejected properly.

Quoted 8 lines

v2: Check invalid strides
v3: Check invalid stride with Y-tiling
Include a few more invalid stride values
Fix gen3 X-tile size
v4: A few more invalid strides :)
Drop the useless memset()

I think I've exhausted my wishlist, and congrats on finding the bug, so

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#12 lore raw

Re: [PATCH i-g-t v4] tests/gem_tiling_max_stride: Add a test for max fence stride

Quoted 17 lines · Chris Wilson
Quoted 16 lines · On Tue, Apr 09, 2013 at 05:45:37PM +0300, [email protected] wrote:

From: Ville Syrjälä <[email protected]>

gem_tiling_max_stride writes a data pattern to an X-tiled buffer using the maximum supported stride, reads the data back as linear, and verifies that the data didn't get scrambled on the way.

The test also checks that some invalid stride values are rejected properly.

v2: Check invalid strides
v3: Check invalid stride with Y-tiling
Include a few more invalid stride values
Fix gen3 X-tile size
v4: A few more invalid strides :)
Drop the useless memset()

Quoted 4 lines
Quoted 1 line

I think I've exhausted my wishlist, and congrats on finding the bug, so

Merged all three patches, thanks a lot for supplying paranoid igt cases. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch