All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] igt/gem_exec_capture: Capture many, many objects
@ 2018-10-03 10:45 ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2018-10-03 10:45 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev

Exercise O(N^2) behaviour in reading the error state, and push it to the
extreme.

Reported-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/meson.build              |   1 +
 tests/gem_exec_capture.c     | 351 ++++++++++++++++++++++++++++++++++-
 tests/intel-ci/blacklist.txt |   1 +
 3 files changed, 350 insertions(+), 3 deletions(-)

diff --git a/lib/meson.build b/lib/meson.build
index e60e5e02..ce5465b6 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -66,6 +66,7 @@ lib_deps = [
 	math,
 	realtime,
 	ssl,
+	zlib
 ]
 
 if libdrm_intel.found()
diff --git a/tests/gem_exec_capture.c b/tests/gem_exec_capture.c
index 3e4a4377..f26b4102 100644
--- a/tests/gem_exec_capture.c
+++ b/tests/gem_exec_capture.c
@@ -21,8 +21,11 @@
  * IN THE SOFTWARE.
  */
 
+#include <zlib.h>
+
 #include "igt.h"
 #include "igt_device.h"
+#include "igt_rand.h"
 #include "igt_sysfs.h"
 
 #define LOCAL_OBJECT_CAPTURE (1 << 7)
@@ -54,10 +57,11 @@ static void check_error_state(int dir, struct drm_i915_gem_exec_object2 *obj)
 		found = true;
 	}
 
+	free(error);
 	igt_assert(found);
 }
 
-static void __capture(int fd, int dir, unsigned ring, uint32_t target)
+static void __capture1(int fd, int dir, unsigned ring, uint32_t target)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
 	struct drm_i915_gem_exec_object2 obj[4];
@@ -169,10 +173,326 @@ static void capture(int fd, int dir, unsigned ring)
 	uint32_t handle;
 
 	handle = gem_create(fd, 4096);
-	__capture(fd, dir, ring, handle);
+	__capture1(fd, dir, ring, handle);
 	gem_close(fd, handle);
 }
 
+static int cmp(const void *A, const void *B)
+{
+	const uint64_t *a = A, *b = B;
+
+	if (*a < *b)
+		return -1;
+
+	if (*a > *b)
+		return 1;
+
+	return 0;
+}
+
+static struct offset {
+	uint64_t addr;
+	unsigned long idx;
+} *__captureN(int fd, int dir, unsigned ring,
+	      unsigned int size, int count,
+	      unsigned int flags)
+#define INCREMENTAL 0x1
+{
+	const int gen = intel_gen(intel_get_drm_devid(fd));
+	struct drm_i915_gem_exec_object2 *obj;
+	struct drm_i915_gem_relocation_entry reloc[2];
+	struct drm_i915_gem_execbuffer2 execbuf;
+	uint32_t *batch, *seqno;
+	struct offset *offsets;
+	int i;
+
+	offsets = calloc(count , sizeof(*offsets));
+	igt_assert(offsets);
+
+	obj = calloc(count + 2, sizeof(*obj));
+	igt_assert(obj);
+
+	obj[0].handle = gem_create(fd, 4096);
+	for (i = 0; i < count; i++) {
+		obj[i + 1].handle = gem_create(fd, size);
+		obj[i + 1].flags =
+			LOCAL_OBJECT_CAPTURE | EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+		if (flags & INCREMENTAL) {
+			uint32_t *ptr;
+
+			ptr = gem_mmap__cpu(fd, obj[i + 1].handle,
+					    0, size, PROT_WRITE);
+			for (unsigned int n = 0; n < size / sizeof(*ptr); n++)
+				ptr[n] = i * size + n;
+			munmap(ptr, size);
+		}
+	}
+
+	obj[count + 1].handle = gem_create(fd, 4096);
+	obj[count + 1].relocs_ptr = (uintptr_t)reloc;
+	obj[count + 1].relocation_count = ARRAY_SIZE(reloc);
+
+	memset(reloc, 0, sizeof(reloc));
+	reloc[0].target_handle = obj[count + 1].handle; /* recurse */
+	reloc[0].presumed_offset = 0;
+	reloc[0].offset = 5*sizeof(uint32_t);
+	reloc[0].delta = 0;
+	reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND;
+	reloc[0].write_domain = 0;
+
+	reloc[1].target_handle = obj[0].handle; /* breadcrumb */
+	reloc[1].presumed_offset = 0;
+	reloc[1].offset = sizeof(uint32_t);
+	reloc[1].delta = 0;
+	reloc[1].read_domains = I915_GEM_DOMAIN_RENDER;
+	reloc[1].write_domain = I915_GEM_DOMAIN_RENDER;
+
+	seqno = gem_mmap__wc(fd, obj[0].handle, 0, 4096, PROT_READ);
+	gem_set_domain(fd, obj[0].handle,
+			I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+
+	batch = gem_mmap__cpu(fd, obj[count + 1].handle, 0, 4096, PROT_WRITE);
+	gem_set_domain(fd, obj[count + 1].handle,
+			I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
+
+	i = 0;
+	batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
+	if (gen >= 8) {
+		batch[++i] = 0;
+		batch[++i] = 0;
+	} else if (gen >= 4) {
+		batch[++i] = 0;
+		batch[++i] = 0;
+		reloc[1].offset += sizeof(uint32_t);
+	} else {
+		batch[i]--;
+		batch[++i] = 0;
+	}
+	batch[++i] = 0xc0ffee;
+	if (gen < 4)
+		batch[++i] = MI_NOOP;
+
+	batch[++i] = MI_BATCH_BUFFER_START; /* not crashed? try again! */
+	if (gen >= 8) {
+		batch[i] |= 1 << 8 | 1;
+		batch[++i] = 0;
+		batch[++i] = 0;
+	} else if (gen >= 6) {
+		batch[i] |= 1 << 8;
+		batch[++i] = 0;
+	} else {
+		batch[i] |= 2 << 6;
+		batch[++i] = 0;
+		if (gen < 4) {
+			batch[i] |= 1;
+			reloc[0].delta = 1;
+		}
+	}
+	munmap(batch, 4096);
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = (uintptr_t)obj;
+	execbuf.buffer_count = count + 2;
+	execbuf.flags = ring;
+	if (gen > 3 && gen < 6)
+		execbuf.flags |= I915_EXEC_SECURE;
+
+	igt_assert(!READ_ONCE(*seqno));
+	gem_execbuf(fd, &execbuf);
+
+	/* Wait for the request to start */
+	while (READ_ONCE(*seqno) != 0xc0ffee)
+		igt_assert(gem_bo_busy(fd, obj[0].handle));
+	munmap(seqno, 4096);
+
+	igt_force_gpu_reset(fd);
+
+	gem_sync(fd, obj[count + 1].handle);
+	gem_close(fd, obj[count + 1].handle);
+	for (i = 0; i < count; i++) {
+		offsets[i].addr = obj[i + 1].offset;
+		offsets[i].idx = i;
+		gem_close(fd, obj[i + 1].handle);
+	}
+	gem_close(fd, obj[0].handle);
+
+	qsort(offsets, count, sizeof(*offsets), cmp);
+	igt_assert(offsets[0].addr <= offsets[count-1].addr);
+	return offsets;
+}
+
+static unsigned long zlib_inflate(uint32_t **ptr, unsigned long len)
+{
+	struct z_stream_s zstream;
+	void *out;
+
+	memset(&zstream, 0, sizeof(zstream));
+
+	zstream.next_in = (unsigned char *)*ptr;
+	zstream.avail_in = 4*len;
+
+	if (inflateInit(&zstream) != Z_OK)
+		return 0;
+
+	out = malloc(128*4096); /* approximate obj size */
+	zstream.next_out = out;
+	zstream.avail_out = 128*4096;
+
+	do {
+		switch (inflate(&zstream, Z_SYNC_FLUSH)) {
+		case Z_STREAM_END:
+			goto end;
+		case Z_OK:
+			break;
+		default:
+			inflateEnd(&zstream);
+			return 0;
+		}
+
+		if (zstream.avail_out)
+			break;
+
+		out = realloc(out, 2*zstream.total_out);
+		if (out == NULL) {
+			inflateEnd(&zstream);
+			return 0;
+		}
+
+		zstream.next_out = (unsigned char *)out + zstream.total_out;
+		zstream.avail_out = zstream.total_out;
+	} while (1);
+end:
+	inflateEnd(&zstream);
+	free(*ptr);
+	*ptr = out;
+	return zstream.total_out / 4;
+}
+
+static unsigned long
+ascii85_decode(char *in, uint32_t **out, bool inflate, char **end)
+{
+	unsigned long len = 0, size = 1024;
+
+	*out = realloc(*out, sizeof(uint32_t)*size);
+	if (*out == NULL)
+		return 0;
+
+	while (*in >= '!' && *in <= 'z') {
+		uint32_t v = 0;
+
+		if (len == size) {
+			size *= 2;
+			*out = realloc(*out, sizeof(uint32_t)*size);
+			if (*out == NULL)
+				return 0;
+		}
+
+		if (*in == 'z') {
+			in++;
+		} else {
+			v += in[0] - 33; v *= 85;
+			v += in[1] - 33; v *= 85;
+			v += in[2] - 33; v *= 85;
+			v += in[3] - 33; v *= 85;
+			v += in[4] - 33;
+			in += 5;
+		}
+		(*out)[len++] = v;
+	}
+	*end = in;
+
+	if (!inflate)
+		return len;
+
+	return zlib_inflate(out, len);
+}
+
+static void many(int fd, int dir, uint64_t size, unsigned int flags)
+{
+	uint64_t ram, gtt;
+	unsigned long count, blobs;
+	struct offset *offsets;
+	char *error, *str;
+
+	gtt = gem_aperture_size(fd) / size;
+	ram = (intel_get_avail_ram_mb() << 20) / size;
+	igt_debug("Available objects in GTT:%"PRIu64", RAM:%"PRIu64"\n",
+		  gtt, ram);
+
+	count = min(gtt, ram) / 4;
+	igt_require(count > 1);
+
+	intel_require_memory(count, size, CHECK_RAM);
+
+	offsets = __captureN(fd, dir, 0, size, count, flags);
+
+	error = igt_sysfs_get(dir, "error");
+	igt_sysfs_set(dir, "error", "Begone!");
+	igt_assert(error);
+
+	blobs = 0;
+	/* render ring --- user = 0x00000000 ffffd000 */
+	str = strstr(error, "--- user = ");
+	while (str) {
+		uint32_t *data = NULL;
+		unsigned long i, sz;
+		uint64_t addr;
+
+		if (strncmp(str, "--- user = 0x", 13))
+			break;
+
+		str += 13;
+		addr = strtoul(str, &str, 16);
+		addr <<= 32;
+		addr |= strtoul(str + 1, &str, 16);
+		igt_assert(*str++ = '\n');
+
+		if (!(*str == ':' || *str == '~'))
+			continue;
+
+		igt_debug("blob:%.64s\n", str);
+		sz = ascii85_decode(str + 1, &data, *str == ':', &str);
+		igt_assert_eq(4 * sz, size);
+		igt_assert(*str++ == '\n');
+		str = strchr(str, '-');
+
+		if (flags & INCREMENTAL) {
+			unsigned long start = 0;
+			unsigned long end = count;
+			uint32_t expect;
+
+			while (end > start) {
+				i = (end - start) / 2 + start;
+				if (offsets[i].addr < addr)
+					start = i + 1;
+				else if (offsets[i].addr > addr)
+					end = i;
+				else
+					break;
+			}
+			igt_assert(offsets[i].addr == addr);
+			igt_debug("offset:%"PRIx64", index:%ld\n",
+				  addr, offsets[i].idx);
+
+			expect = offsets[i].idx * size;
+			for (i = 0; i < sz; i++)
+				igt_assert_eq(data[i], expect++);
+		} else {
+			for (i = 0; i < sz; i++)
+				igt_assert_eq(data[i], 0);
+		}
+
+		blobs++;
+		free(data);
+	}
+	igt_info("Captured %lu %"PRId64"-blobs out of a total of %lu\n",
+		 blobs, size >> 12, count);
+	igt_assert(count);
+
+	free(error);
+	free(offsets);
+}
+
 static void userptr(int fd, int dir)
 {
 	uint32_t handle;
@@ -181,7 +501,7 @@ static void userptr(int fd, int dir)
 	igt_assert(posix_memalign(&ptr, 4096, 4096) == 0);
 	igt_require(__gem_userptr(fd, ptr, 4096, 0, 0, &handle) == 0);
 
-	__capture(fd, dir, 0, handle);
+	__capture1(fd, dir, 0, handle);
 
 	gem_close(fd, handle);
 	free(ptr);
@@ -238,6 +558,31 @@ igt_main
 		}
 	}
 
+	igt_subtest_f("many-4K-zero") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 1<<12, 0);
+	}
+
+	igt_subtest_f("many-4K-incremental") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 1<<12, INCREMENTAL);
+	}
+
+	igt_subtest_f("many-2M-zero") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 2<<20, 0);
+	}
+
+	igt_subtest_f("many-2M-incremental") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 2<<20, INCREMENTAL);
+	}
+
+	igt_subtest_f("many-256M-incremental") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 256<<20, INCREMENTAL);
+	}
+
 	/* And check we can read from different types of objects */
 
 	igt_subtest_f("userptr") {
diff --git a/tests/intel-ci/blacklist.txt b/tests/intel-ci/blacklist.txt
index 88b2fe31..fa33264d 100644
--- a/tests/intel-ci/blacklist.txt
+++ b/tests/intel-ci/blacklist.txt
@@ -28,6 +28,7 @@ igt@gem_ctx_thrash(@.*)?
 igt@gem_evict_alignment(@.*)?
 igt@gem_evict_everything(@.*)?
 igt@gem_exec_alignment@(?!.*single).*
+igt@gem_exec_capture@many-(?!4K-).*
 igt@gem_exec_fence@(?!.*basic).*
 igt@gem_exec_flush@(?!.*basic).*
 igt@gem_exec_gttfill@(?!.*basic).*
-- 
2.19.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [igt-dev] [PATCH i-g-t] igt/gem_exec_capture: Capture many, many objects
@ 2018-10-03 10:45 ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2018-10-03 10:45 UTC (permalink / raw)
  To: intel-gfx; +Cc: igt-dev, mika.kuoppala

Exercise O(N^2) behaviour in reading the error state, and push it to the
extreme.

Reported-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/meson.build              |   1 +
 tests/gem_exec_capture.c     | 351 ++++++++++++++++++++++++++++++++++-
 tests/intel-ci/blacklist.txt |   1 +
 3 files changed, 350 insertions(+), 3 deletions(-)

diff --git a/lib/meson.build b/lib/meson.build
index e60e5e02..ce5465b6 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -66,6 +66,7 @@ lib_deps = [
 	math,
 	realtime,
 	ssl,
+	zlib
 ]
 
 if libdrm_intel.found()
diff --git a/tests/gem_exec_capture.c b/tests/gem_exec_capture.c
index 3e4a4377..f26b4102 100644
--- a/tests/gem_exec_capture.c
+++ b/tests/gem_exec_capture.c
@@ -21,8 +21,11 @@
  * IN THE SOFTWARE.
  */
 
+#include <zlib.h>
+
 #include "igt.h"
 #include "igt_device.h"
+#include "igt_rand.h"
 #include "igt_sysfs.h"
 
 #define LOCAL_OBJECT_CAPTURE (1 << 7)
@@ -54,10 +57,11 @@ static void check_error_state(int dir, struct drm_i915_gem_exec_object2 *obj)
 		found = true;
 	}
 
+	free(error);
 	igt_assert(found);
 }
 
-static void __capture(int fd, int dir, unsigned ring, uint32_t target)
+static void __capture1(int fd, int dir, unsigned ring, uint32_t target)
 {
 	const int gen = intel_gen(intel_get_drm_devid(fd));
 	struct drm_i915_gem_exec_object2 obj[4];
@@ -169,10 +173,326 @@ static void capture(int fd, int dir, unsigned ring)
 	uint32_t handle;
 
 	handle = gem_create(fd, 4096);
-	__capture(fd, dir, ring, handle);
+	__capture1(fd, dir, ring, handle);
 	gem_close(fd, handle);
 }
 
+static int cmp(const void *A, const void *B)
+{
+	const uint64_t *a = A, *b = B;
+
+	if (*a < *b)
+		return -1;
+
+	if (*a > *b)
+		return 1;
+
+	return 0;
+}
+
+static struct offset {
+	uint64_t addr;
+	unsigned long idx;
+} *__captureN(int fd, int dir, unsigned ring,
+	      unsigned int size, int count,
+	      unsigned int flags)
+#define INCREMENTAL 0x1
+{
+	const int gen = intel_gen(intel_get_drm_devid(fd));
+	struct drm_i915_gem_exec_object2 *obj;
+	struct drm_i915_gem_relocation_entry reloc[2];
+	struct drm_i915_gem_execbuffer2 execbuf;
+	uint32_t *batch, *seqno;
+	struct offset *offsets;
+	int i;
+
+	offsets = calloc(count , sizeof(*offsets));
+	igt_assert(offsets);
+
+	obj = calloc(count + 2, sizeof(*obj));
+	igt_assert(obj);
+
+	obj[0].handle = gem_create(fd, 4096);
+	for (i = 0; i < count; i++) {
+		obj[i + 1].handle = gem_create(fd, size);
+		obj[i + 1].flags =
+			LOCAL_OBJECT_CAPTURE | EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+		if (flags & INCREMENTAL) {
+			uint32_t *ptr;
+
+			ptr = gem_mmap__cpu(fd, obj[i + 1].handle,
+					    0, size, PROT_WRITE);
+			for (unsigned int n = 0; n < size / sizeof(*ptr); n++)
+				ptr[n] = i * size + n;
+			munmap(ptr, size);
+		}
+	}
+
+	obj[count + 1].handle = gem_create(fd, 4096);
+	obj[count + 1].relocs_ptr = (uintptr_t)reloc;
+	obj[count + 1].relocation_count = ARRAY_SIZE(reloc);
+
+	memset(reloc, 0, sizeof(reloc));
+	reloc[0].target_handle = obj[count + 1].handle; /* recurse */
+	reloc[0].presumed_offset = 0;
+	reloc[0].offset = 5*sizeof(uint32_t);
+	reloc[0].delta = 0;
+	reloc[0].read_domains = I915_GEM_DOMAIN_COMMAND;
+	reloc[0].write_domain = 0;
+
+	reloc[1].target_handle = obj[0].handle; /* breadcrumb */
+	reloc[1].presumed_offset = 0;
+	reloc[1].offset = sizeof(uint32_t);
+	reloc[1].delta = 0;
+	reloc[1].read_domains = I915_GEM_DOMAIN_RENDER;
+	reloc[1].write_domain = I915_GEM_DOMAIN_RENDER;
+
+	seqno = gem_mmap__wc(fd, obj[0].handle, 0, 4096, PROT_READ);
+	gem_set_domain(fd, obj[0].handle,
+			I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+
+	batch = gem_mmap__cpu(fd, obj[count + 1].handle, 0, 4096, PROT_WRITE);
+	gem_set_domain(fd, obj[count + 1].handle,
+			I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
+
+	i = 0;
+	batch[i] = MI_STORE_DWORD_IMM | (gen < 6 ? 1 << 22 : 0);
+	if (gen >= 8) {
+		batch[++i] = 0;
+		batch[++i] = 0;
+	} else if (gen >= 4) {
+		batch[++i] = 0;
+		batch[++i] = 0;
+		reloc[1].offset += sizeof(uint32_t);
+	} else {
+		batch[i]--;
+		batch[++i] = 0;
+	}
+	batch[++i] = 0xc0ffee;
+	if (gen < 4)
+		batch[++i] = MI_NOOP;
+
+	batch[++i] = MI_BATCH_BUFFER_START; /* not crashed? try again! */
+	if (gen >= 8) {
+		batch[i] |= 1 << 8 | 1;
+		batch[++i] = 0;
+		batch[++i] = 0;
+	} else if (gen >= 6) {
+		batch[i] |= 1 << 8;
+		batch[++i] = 0;
+	} else {
+		batch[i] |= 2 << 6;
+		batch[++i] = 0;
+		if (gen < 4) {
+			batch[i] |= 1;
+			reloc[0].delta = 1;
+		}
+	}
+	munmap(batch, 4096);
+
+	memset(&execbuf, 0, sizeof(execbuf));
+	execbuf.buffers_ptr = (uintptr_t)obj;
+	execbuf.buffer_count = count + 2;
+	execbuf.flags = ring;
+	if (gen > 3 && gen < 6)
+		execbuf.flags |= I915_EXEC_SECURE;
+
+	igt_assert(!READ_ONCE(*seqno));
+	gem_execbuf(fd, &execbuf);
+
+	/* Wait for the request to start */
+	while (READ_ONCE(*seqno) != 0xc0ffee)
+		igt_assert(gem_bo_busy(fd, obj[0].handle));
+	munmap(seqno, 4096);
+
+	igt_force_gpu_reset(fd);
+
+	gem_sync(fd, obj[count + 1].handle);
+	gem_close(fd, obj[count + 1].handle);
+	for (i = 0; i < count; i++) {
+		offsets[i].addr = obj[i + 1].offset;
+		offsets[i].idx = i;
+		gem_close(fd, obj[i + 1].handle);
+	}
+	gem_close(fd, obj[0].handle);
+
+	qsort(offsets, count, sizeof(*offsets), cmp);
+	igt_assert(offsets[0].addr <= offsets[count-1].addr);
+	return offsets;
+}
+
+static unsigned long zlib_inflate(uint32_t **ptr, unsigned long len)
+{
+	struct z_stream_s zstream;
+	void *out;
+
+	memset(&zstream, 0, sizeof(zstream));
+
+	zstream.next_in = (unsigned char *)*ptr;
+	zstream.avail_in = 4*len;
+
+	if (inflateInit(&zstream) != Z_OK)
+		return 0;
+
+	out = malloc(128*4096); /* approximate obj size */
+	zstream.next_out = out;
+	zstream.avail_out = 128*4096;
+
+	do {
+		switch (inflate(&zstream, Z_SYNC_FLUSH)) {
+		case Z_STREAM_END:
+			goto end;
+		case Z_OK:
+			break;
+		default:
+			inflateEnd(&zstream);
+			return 0;
+		}
+
+		if (zstream.avail_out)
+			break;
+
+		out = realloc(out, 2*zstream.total_out);
+		if (out == NULL) {
+			inflateEnd(&zstream);
+			return 0;
+		}
+
+		zstream.next_out = (unsigned char *)out + zstream.total_out;
+		zstream.avail_out = zstream.total_out;
+	} while (1);
+end:
+	inflateEnd(&zstream);
+	free(*ptr);
+	*ptr = out;
+	return zstream.total_out / 4;
+}
+
+static unsigned long
+ascii85_decode(char *in, uint32_t **out, bool inflate, char **end)
+{
+	unsigned long len = 0, size = 1024;
+
+	*out = realloc(*out, sizeof(uint32_t)*size);
+	if (*out == NULL)
+		return 0;
+
+	while (*in >= '!' && *in <= 'z') {
+		uint32_t v = 0;
+
+		if (len == size) {
+			size *= 2;
+			*out = realloc(*out, sizeof(uint32_t)*size);
+			if (*out == NULL)
+				return 0;
+		}
+
+		if (*in == 'z') {
+			in++;
+		} else {
+			v += in[0] - 33; v *= 85;
+			v += in[1] - 33; v *= 85;
+			v += in[2] - 33; v *= 85;
+			v += in[3] - 33; v *= 85;
+			v += in[4] - 33;
+			in += 5;
+		}
+		(*out)[len++] = v;
+	}
+	*end = in;
+
+	if (!inflate)
+		return len;
+
+	return zlib_inflate(out, len);
+}
+
+static void many(int fd, int dir, uint64_t size, unsigned int flags)
+{
+	uint64_t ram, gtt;
+	unsigned long count, blobs;
+	struct offset *offsets;
+	char *error, *str;
+
+	gtt = gem_aperture_size(fd) / size;
+	ram = (intel_get_avail_ram_mb() << 20) / size;
+	igt_debug("Available objects in GTT:%"PRIu64", RAM:%"PRIu64"\n",
+		  gtt, ram);
+
+	count = min(gtt, ram) / 4;
+	igt_require(count > 1);
+
+	intel_require_memory(count, size, CHECK_RAM);
+
+	offsets = __captureN(fd, dir, 0, size, count, flags);
+
+	error = igt_sysfs_get(dir, "error");
+	igt_sysfs_set(dir, "error", "Begone!");
+	igt_assert(error);
+
+	blobs = 0;
+	/* render ring --- user = 0x00000000 ffffd000 */
+	str = strstr(error, "--- user = ");
+	while (str) {
+		uint32_t *data = NULL;
+		unsigned long i, sz;
+		uint64_t addr;
+
+		if (strncmp(str, "--- user = 0x", 13))
+			break;
+
+		str += 13;
+		addr = strtoul(str, &str, 16);
+		addr <<= 32;
+		addr |= strtoul(str + 1, &str, 16);
+		igt_assert(*str++ = '\n');
+
+		if (!(*str == ':' || *str == '~'))
+			continue;
+
+		igt_debug("blob:%.64s\n", str);
+		sz = ascii85_decode(str + 1, &data, *str == ':', &str);
+		igt_assert_eq(4 * sz, size);
+		igt_assert(*str++ == '\n');
+		str = strchr(str, '-');
+
+		if (flags & INCREMENTAL) {
+			unsigned long start = 0;
+			unsigned long end = count;
+			uint32_t expect;
+
+			while (end > start) {
+				i = (end - start) / 2 + start;
+				if (offsets[i].addr < addr)
+					start = i + 1;
+				else if (offsets[i].addr > addr)
+					end = i;
+				else
+					break;
+			}
+			igt_assert(offsets[i].addr == addr);
+			igt_debug("offset:%"PRIx64", index:%ld\n",
+				  addr, offsets[i].idx);
+
+			expect = offsets[i].idx * size;
+			for (i = 0; i < sz; i++)
+				igt_assert_eq(data[i], expect++);
+		} else {
+			for (i = 0; i < sz; i++)
+				igt_assert_eq(data[i], 0);
+		}
+
+		blobs++;
+		free(data);
+	}
+	igt_info("Captured %lu %"PRId64"-blobs out of a total of %lu\n",
+		 blobs, size >> 12, count);
+	igt_assert(count);
+
+	free(error);
+	free(offsets);
+}
+
 static void userptr(int fd, int dir)
 {
 	uint32_t handle;
@@ -181,7 +501,7 @@ static void userptr(int fd, int dir)
 	igt_assert(posix_memalign(&ptr, 4096, 4096) == 0);
 	igt_require(__gem_userptr(fd, ptr, 4096, 0, 0, &handle) == 0);
 
-	__capture(fd, dir, 0, handle);
+	__capture1(fd, dir, 0, handle);
 
 	gem_close(fd, handle);
 	free(ptr);
@@ -238,6 +558,31 @@ igt_main
 		}
 	}
 
+	igt_subtest_f("many-4K-zero") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 1<<12, 0);
+	}
+
+	igt_subtest_f("many-4K-incremental") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 1<<12, INCREMENTAL);
+	}
+
+	igt_subtest_f("many-2M-zero") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 2<<20, 0);
+	}
+
+	igt_subtest_f("many-2M-incremental") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 2<<20, INCREMENTAL);
+	}
+
+	igt_subtest_f("many-256M-incremental") {
+		igt_require(gem_can_store_dword(fd, 0));
+		many(fd, dir, 256<<20, INCREMENTAL);
+	}
+
 	/* And check we can read from different types of objects */
 
 	igt_subtest_f("userptr") {
diff --git a/tests/intel-ci/blacklist.txt b/tests/intel-ci/blacklist.txt
index 88b2fe31..fa33264d 100644
--- a/tests/intel-ci/blacklist.txt
+++ b/tests/intel-ci/blacklist.txt
@@ -28,6 +28,7 @@ igt@gem_ctx_thrash(@.*)?
 igt@gem_evict_alignment(@.*)?
 igt@gem_evict_everything(@.*)?
 igt@gem_exec_alignment@(?!.*single).*
+igt@gem_exec_capture@many-(?!4K-).*
 igt@gem_exec_fence@(?!.*basic).*
 igt@gem_exec_flush@(?!.*basic).*
 igt@gem_exec_gttfill@(?!.*basic).*
-- 
2.19.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [igt-dev] ✓ Fi.CI.BAT: success for igt/gem_exec_capture: Capture many, many objects (rev3)
  2018-10-03 10:45 ` [igt-dev] " Chris Wilson
  (?)
@ 2018-10-03 11:49 ` Patchwork
  -1 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2018-10-03 11:49 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: igt/gem_exec_capture: Capture many, many objects (rev3)
URL   : https://patchwork.freedesktop.org/series/46768/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4919 -> IGTPW_1899 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/46768/revisions/3/mbox/

== Known issues ==

  Here are the changes found in IGTPW_1899 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@amdgpu/amd_basic@cs-compute:
      fi-kbl-8809g:       NOTRUN -> FAIL (fdo#108094)

    igt@amdgpu/amd_prime@amd-to-i915:
      fi-kbl-8809g:       NOTRUN -> FAIL (fdo#107341)

    igt@kms_frontbuffer_tracking@basic:
      fi-byt-clapper:     NOTRUN -> FAIL (fdo#103167)

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b-frame-sequence:
      fi-byt-clapper:     NOTRUN -> FAIL (fdo#107362, fdo#103191) +1

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-bdw-samus:       NOTRUN -> INCOMPLETE (fdo#107773)

    
    ==== Possible fixes ====

    igt@gem_exec_suspend@basic-s3:
      fi-byt-clapper:     INCOMPLETE (fdo#102657) -> PASS

    igt@gem_exec_suspend@basic-s4-devices:
      fi-bdw-samus:       INCOMPLETE (fdo#107773) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-icl-u:           INCOMPLETE (fdo#107713) -> PASS

    
  fdo#102657 https://bugs.freedesktop.org/show_bug.cgi?id=102657
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#107341 https://bugs.freedesktop.org/show_bug.cgi?id=107341
  fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
  fdo#107713 https://bugs.freedesktop.org/show_bug.cgi?id=107713
  fdo#107773 https://bugs.freedesktop.org/show_bug.cgi?id=107773
  fdo#108094 https://bugs.freedesktop.org/show_bug.cgi?id=108094


== Participating hosts (49 -> 44) ==

  Additional (1): fi-glk-j4005 
  Missing    (6): fi-hsw-4200u fi-byt-squawks fi-icl-u2 fi-bsw-cyan fi-ctg-p8600 fi-hsw-4770 


== Build changes ==

    * IGT: IGT_4665 -> IGTPW_1899

  CI_DRM_4919: e489eb0296673790264b25266ef45aae7d1ab566 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1899: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1899/
  IGT_4665: 267870165d9ef66b4ab423e4efe7bacba023d75e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools



== Testlist changes ==

+igt@gem_exec_capture@many-2m-incremental
+igt@gem_exec_capture@many-2m-zero
+igt@gem_exec_capture@many-4k-incremental
+igt@gem_exec_capture@many-4k-zero
+igt@gem_exec_capture@many-256m-incremental

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1899/issues.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [igt-dev] ✗ Fi.CI.IGT: failure for igt/gem_exec_capture: Capture many, many objects (rev3)
  2018-10-03 10:45 ` [igt-dev] " Chris Wilson
  (?)
  (?)
@ 2018-10-03 17:40 ` Patchwork
  -1 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2018-10-03 17:40 UTC (permalink / raw)
  To: Chris Wilson; +Cc: igt-dev

== Series Details ==

Series: igt/gem_exec_capture: Capture many, many objects (rev3)
URL   : https://patchwork.freedesktop.org/series/46768/
State : failure

== Summary ==

= CI Bug Log - changes from IGT_4665_full -> IGTPW_1899_full =

== Summary - FAILURE ==

  Serious unknown changes coming with IGTPW_1899_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in IGTPW_1899_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/46768/revisions/3/mbox/

== Possible new issues ==

  Here are the unknown changes that may have been introduced in IGTPW_1899_full:

  === IGT changes ===

    ==== Possible regressions ====

    igt@kms_color@pipe-b-degamma:
      shard-apl:          PASS -> FAIL

    
    ==== Warnings ====

    igt@gem_tiled_swapping@non-threaded:
      shard-glk:          SKIP -> PASS
      shard-kbl:          SKIP -> PASS
      shard-apl:          SKIP -> PASS

    igt@pm_rc6_residency@rc6-accuracy:
      shard-snb:          SKIP -> PASS

    
== Known issues ==

  Here are the changes found in IGTPW_1899_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_ctx_isolation@vcs1-s3:
      shard-kbl:          PASS -> INCOMPLETE (fdo#103665) +1

    igt@gem_exec_capture@capture-blt:
      shard-glk:          PASS -> DMESG-WARN (fdo#105763, fdo#106538)

    igt@gem_ppgtt@blt-vs-render-ctx0:
      shard-kbl:          PASS -> INCOMPLETE (fdo#106023, fdo#103665)

    igt@kms_busy@extended-modeset-hang-newfb-render-a:
      shard-hsw:          PASS -> DMESG-WARN (fdo#107956)
      shard-snb:          NOTRUN -> DMESG-WARN (fdo#107956)

    igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
      shard-snb:          PASS -> DMESG-WARN (fdo#107956)

    igt@kms_color@pipe-a-legacy-gamma:
      shard-apl:          PASS -> FAIL (fdo#108145)

    igt@kms_cursor_crc@cursor-128x128-suspend:
      shard-apl:          PASS -> FAIL (fdo#103232, fdo#103191)

    igt@kms_cursor_crc@cursor-128x42-random:
      shard-glk:          PASS -> FAIL (fdo#103232) +4

    igt@kms_cursor_crc@cursor-256x85-random:
      shard-apl:          PASS -> FAIL (fdo#103232) +2

    igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
      shard-hsw:          PASS -> FAIL (fdo#105767)

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-draw-pwrite:
      shard-apl:          PASS -> FAIL (fdo#103167) +3

    igt@kms_frontbuffer_tracking@fbc-1p-rte:
      shard-apl:          PASS -> DMESG-WARN (fdo#108131, fdo#103558)

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-onoff:
      shard-glk:          PASS -> FAIL (fdo#103167) +2

    igt@kms_frontbuffer_tracking@psr-2p-scndscrn-pri-shrfb-draw-mmap-cpu:
      shard-glk:          SKIP -> INCOMPLETE (k.org#198133, fdo#103359)

    igt@kms_plane@pixel-format-pipe-a-planes:
      shard-kbl:          PASS -> FAIL (fdo#103166)

    igt@kms_plane@plane-position-covered-pipe-b-planes:
      shard-glk:          PASS -> FAIL (fdo#103166) +5

    igt@kms_plane@plane-position-covered-pipe-c-planes:
      shard-apl:          PASS -> FAIL (fdo#103166) +4

    {igt@kms_plane_alpha_blend@pipe-c-alpha-opaque-fb}:
      shard-glk:          PASS -> FAIL (fdo#108145)

    igt@perf_pmu@rc6-runtime-pm-long:
      shard-apl:          PASS -> FAIL (fdo#105010)
      shard-glk:          PASS -> FAIL (fdo#105010)
      shard-kbl:          PASS -> FAIL (fdo#105010)

    
    ==== Possible fixes ====

    igt@drv_suspend@shrink:
      shard-hsw:          INCOMPLETE (fdo#103540, fdo#106886) -> PASS

    igt@kms_available_modes_crc@available_mode_test_crc:
      shard-apl:          FAIL (fdo#106641) -> PASS

    igt@kms_busy@extended-pageflip-hang-newfb-render-c:
      shard-apl:          DMESG-WARN (fdo#107956) -> PASS

    igt@kms_ccs@pipe-a-crc-sprite-planes-basic:
      shard-glk:          FAIL (fdo#108145) -> PASS

    igt@kms_cursor_crc@cursor-128x128-random:
      shard-apl:          FAIL (fdo#103232) -> PASS +4

    igt@kms_cursor_crc@cursor-64x64-random:
      shard-kbl:          FAIL (fdo#103232) -> PASS +3

    igt@kms_cursor_crc@cursor-64x64-sliding:
      shard-glk:          FAIL (fdo#103232) -> PASS +1

    igt@kms_draw_crc@draw-method-xrgb8888-pwrite-ytiled:
      shard-glk:          FAIL -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-blt:
      shard-snb:          INCOMPLETE (fdo#105411) -> PASS

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-blt:
      shard-glk:          FAIL (fdo#103167) -> PASS +7

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-draw-pwrite:
      shard-apl:          FAIL (fdo#103167) -> PASS +2

    igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-onoff:
      shard-kbl:          FAIL (fdo#103167) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
      shard-glk:          DMESG-WARN (fdo#105763, fdo#106538) -> PASS

    igt@kms_plane@pixel-format-pipe-b-planes:
      shard-glk:          FAIL (fdo#103166) -> PASS

    igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes:
      shard-kbl:          INCOMPLETE (fdo#103665) -> PASS

    igt@kms_plane@plane-position-covered-pipe-a-planes:
      shard-apl:          FAIL (fdo#103166) -> PASS +2

    igt@kms_plane_multiple@atomic-pipe-b-tiling-yf:
      shard-kbl:          FAIL (fdo#103166) -> PASS

    igt@kms_rotation_crc@sprite-rotation-180:
      shard-snb:          FAIL (fdo#103925) -> PASS

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#103232 https://bugs.freedesktop.org/show_bug.cgi?id=103232
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
  fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
  fdo#105010 https://bugs.freedesktop.org/show_bug.cgi?id=105010
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#105763 https://bugs.freedesktop.org/show_bug.cgi?id=105763
  fdo#105767 https://bugs.freedesktop.org/show_bug.cgi?id=105767
  fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
  fdo#106538 https://bugs.freedesktop.org/show_bug.cgi?id=106538
  fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
  fdo#106886 https://bugs.freedesktop.org/show_bug.cgi?id=106886
  fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
  fdo#108131 https://bugs.freedesktop.org/show_bug.cgi?id=108131
  fdo#108145 https://bugs.freedesktop.org/show_bug.cgi?id=108145
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


== Participating hosts (6 -> 5) ==

  Missing    (1): shard-skl 


== Build changes ==

    * IGT: IGT_4665 -> IGTPW_1899
    * Linux: CI_DRM_4918 -> CI_DRM_4919

  CI_DRM_4918: f595aba3a6e2f6972bb158eb8434b58d22d0e5f0 @ git://anongit.freedesktop.org/gfx-ci/linux
  CI_DRM_4919: e489eb0296673790264b25266ef45aae7d1ab566 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGTPW_1899: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1899/
  IGT_4665: 267870165d9ef66b4ab423e4efe7bacba023d75e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1899/shards.html
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-10-03 17:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 10:45 [PATCH i-g-t] igt/gem_exec_capture: Capture many, many objects Chris Wilson
2018-10-03 10:45 ` [igt-dev] " Chris Wilson
2018-10-03 11:49 ` [igt-dev] ✓ Fi.CI.BAT: success for igt/gem_exec_capture: Capture many, many objects (rev3) Patchwork
2018-10-03 17:40 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.