summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/drmtest.c4
-rw-r--r--lib/drmtest.h2
-rw-r--r--tests/gem_partial_pwrite_pread.c14
-rw-r--r--tests/gem_pread.c40
-rw-r--r--tests/gem_pread_after_blit.c14
-rw-r--r--tests/gem_pwrite.c40
-rw-r--r--tests/gem_pwrite_pread.c161
7 files changed, 179 insertions, 96 deletions
diff --git a/lib/drmtest.c b/lib/drmtest.c
index e1abb18c..f546784f 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -408,7 +408,7 @@ int gem_has_cacheing(int fd)
return ret == 0;
}
-void gem_set_cacheing(int fd, uint32_t handle, int cacheing)
+int gem_set_cacheing(int fd, uint32_t handle, int cacheing)
{
struct local_drm_i915_gem_cacheing arg;
int ret;
@@ -416,7 +416,7 @@ void gem_set_cacheing(int fd, uint32_t handle, int cacheing)
arg.handle = handle;
arg.cacheing = cacheing;
ret = ioctl(fd, LOCAL_DRM_IOCTL_I915_GEM_SET_CACHEING, &arg);
- assert(ret == 0);
+ return ret == 0 ? 0 : -errno;
}
int gem_get_cacheing(int fd, uint32_t handle)
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 70dbcc4e..8320dbe1 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -54,7 +54,7 @@ bool gem_has_blt(int fd);
bool gem_has_vebox(int fd);
int gem_get_num_rings(int fd);
int gem_has_cacheing(int fd);
-void gem_set_cacheing(int fd, uint32_t handle, int cacheing);
+int gem_set_cacheing(int fd, uint32_t handle, int cacheing);
int gem_get_cacheing(int fd, uint32_t handle);
uint32_t gem_flink(int fd, uint32_t handle);
uint32_t gem_open(int fd, uint32_t name);
diff --git a/tests/gem_partial_pwrite_pread.c b/tests/gem_partial_pwrite_pread.c
index eac27604..ee176b1d 100644
--- a/tests/gem_partial_pwrite_pread.c
+++ b/tests/gem_partial_pwrite_pread.c
@@ -257,8 +257,17 @@ static void do_tests(int cache_level, const char *suffix)
{
char name[80];
- if (cache_level != -1)
- gem_set_cacheing(fd, scratch_bo->handle, cache_level);
+ if (cache_level != -1) {
+ switch (gem_set_cacheing(fd, scratch_bo->handle, cache_level)) {
+ case 0: break;
+ case -EINVAL:
+ case -ENOTTY:
+ return;
+ default:
+ assert(0);
+ return;
+ }
+ }
snprintf(name, sizeof(name), "reads%s", suffix);
if (drmtest_run_subtest(name))
@@ -299,6 +308,7 @@ int main(int argc, char **argv)
/* Repeat the tests using different levels of snooping */
do_tests(0, "-uncached");
do_tests(1, "-snoop");
+ do_tests(2, "-display");
drmtest_cleanup_aperture_trashers();
drm_intel_bufmgr_destroy(bufmgr);
diff --git a/tests/gem_pread.c b/tests/gem_pread.c
index 1e755c06..7037221b 100644
--- a/tests/gem_pread.c
+++ b/tests/gem_pread.c
@@ -83,6 +83,15 @@ int main(int argc, char **argv)
uint32_t buf[20];
uint32_t *src, dst;
int fd, count;
+ const struct {
+ int level;
+ const char *name;
+ } cache[] = {
+ { 0, "uncached" },
+ { 1, "snoop" },
+ { 2, "display" },
+ { -1 },
+ }, *c;
drmtest_skip_on_simulation();
@@ -97,32 +106,35 @@ int main(int argc, char **argv)
dst = gem_create(fd, object_size);
src = malloc(object_size);
- gem_set_cacheing(fd, dst, 0);
for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end;
gettimeofday(&start, NULL);
do_gem_read(fd, dst, src, object_size, count);
gettimeofday(&end, NULL);
- printf("Time to uncached pread %d bytes x %6d: %7.3fµs, %s\n",
+ printf("Time to pread %d bytes x %6d: %7.3fµs, %s\n",
object_size, count,
elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout);
}
- gem_set_cacheing(fd, dst, 1);
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- do_gem_read(fd, dst, src, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to snooped pread %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
+ for (c = cache; c->level != -1; c++) {
+ if (gem_set_cacheing(fd, dst, c->level))
+ continue;
+
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ do_gem_read(fd, dst, src, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to %s pread %d bytes x %6d: %7.3fµs, %s\n",
+ c->name, object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
}
free(src);
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index 178357ed..dce82413 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -131,8 +131,9 @@ static void do_test(int fd, int cache_level,
int loop)
{
if (cache_level != -1) {
- gem_set_cacheing(fd, tmp[0]->handle, cache_level);
- gem_set_cacheing(fd, tmp[1]->handle, cache_level);
+ if (gem_set_cacheing(fd, tmp[0]->handle, cache_level) ||
+ gem_set_cacheing(fd, tmp[1]->handle, cache_level))
+ return;
}
do {
@@ -215,6 +216,15 @@ main(int argc, char **argv)
do_test(fd, 1, src, start, dst, 100);
drmtest_stop_signal_helper();
}
+
+ if (drmtest_run_subtest("normal-display"))
+ do_test(fd, 2, src, start, dst, 1);
+
+ if (drmtest_run_subtest("interruptible-display")) {
+ drmtest_fork_signal_helper();
+ do_test(fd, 2, src, start, dst, 100);
+ drmtest_stop_signal_helper();
+ }
drm_intel_bo_unreference(src[0]);
drm_intel_bo_unreference(src[1]);
drm_intel_bo_unreference(dst[0]);
diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c
index 9c30dbbe..447a2002 100644
--- a/tests/gem_pwrite.c
+++ b/tests/gem_pwrite.c
@@ -90,6 +90,15 @@ int main(int argc, char **argv)
uint32_t buf[20];
uint32_t *src, dst;
int fd, count;
+ const struct {
+ int level;
+ const char *name;
+ } cache[] = {
+ { 0, "uncached" },
+ { 1, "snoop" },
+ { 2, "display" },
+ { -1 },
+ }, *c;
drmtest_skip_on_simulation();
@@ -104,32 +113,35 @@ int main(int argc, char **argv)
dst = gem_create(fd, object_size);
src = malloc(object_size);
- gem_set_cacheing(fd, dst, 0);
for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end;
gettimeofday(&start, NULL);
do_gem_write(fd, dst, src, object_size, count);
gettimeofday(&end, NULL);
- printf("Time to uncached pwrite %d bytes x %6d: %7.3fµs, %s\n",
+ printf("Time to pwrite %d bytes x %6d: %7.3fµs, %s\n",
object_size, count,
elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout);
}
- gem_set_cacheing(fd, dst, 1);
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- do_gem_write(fd, dst, src, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to snooped pwrite %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
+ for (c = cache; c->level != -1; c++) {
+ if (gem_set_cacheing(fd, dst, c->level))
+ continue;
+
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ do_gem_write(fd, dst, src, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to %s pwrite %d bytes x %6d: %7.3fµs, %s\n",
+ c->level, object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
}
free(src);
diff --git a/tests/gem_pwrite_pread.c b/tests/gem_pwrite_pread.c
index 09a1f005..1f9187fc 100644
--- a/tests/gem_pwrite_pread.c
+++ b/tests/gem_pwrite_pread.c
@@ -398,75 +398,114 @@ int main(int argc, char **argv)
src = gem_create(fd, object_size);
tmp = malloc(object_size);
- gem_set_cacheing(fd, src, 0);
- gem_set_cacheing(fd, dst, 0);
- if (drmtest_run_subtest("uncached-copy-correctness"))
- test_copy(fd, src, dst, tmp, object_size);
- if (drmtest_run_subtest("uncached-copy-performance")) {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- copy(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to uncached copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
+ if (gem_set_cacheing(fd, src, 0) == 0 &&
+ gem_set_cacheing(fd, dst, 0) == 0) {
+ if (drmtest_run_subtest("uncached-copy-correctness"))
+ test_copy(fd, src, dst, tmp, object_size);
+ if (drmtest_run_subtest("uncached-copy-performance")) {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ copy(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to uncached copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
}
- }
- if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-correctness"))
- test_as_gtt_mmap(fd, src, dst, object_size);
- if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-performance")) {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- as_gtt_mmap(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("** mmap uncached copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
+ if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-correctness"))
+ test_as_gtt_mmap(fd, src, dst, object_size);
+ if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-performance")) {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ as_gtt_mmap(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("** mmap uncached copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
}
}
- gem_set_cacheing(fd, src, 1);
- gem_set_cacheing(fd, dst, 1);
- if (drmtest_run_subtest("snooped-copy-correctness"))
- test_copy(fd, src, dst, tmp, object_size);
- if (drmtest_run_subtest("snooped-copy-performance")) {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- copy(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to snooped copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
+ if (gem_set_cacheing(fd, src, 1) == 0 &&
+ gem_set_cacheing(fd, dst, 1) == 0) {
+ if (drmtest_run_subtest("snooped-copy-correctness"))
+ test_copy(fd, src, dst, tmp, object_size);
+ if (drmtest_run_subtest("snooped-copy-performance")) {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ copy(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to snooped copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
+ }
+
+ if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-correctness"))
+ test_as_cpu_mmap(fd, src, dst, object_size);
+ if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-performance")) {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ as_cpu_mmap(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("** mmap snooped copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
}
}
- if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-correctness"))
- test_as_cpu_mmap(fd, src, dst, object_size);
- if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-performance")) {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- as_cpu_mmap(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("** mmap snooped copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
+ if (gem_set_cacheing(fd, src, 2) == 0 &&
+ gem_set_cacheing(fd, dst, 2) == 0) {
+ if (drmtest_run_subtest("display-copy-correctness"))
+ test_copy(fd, src, dst, tmp, object_size);
+ if (drmtest_run_subtest("display-copy-performance")) {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ copy(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to display copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
+ }
+
+ if (drmtest_run_subtest("display-pwrite-blt-gtt_mmap-correctness"))
+ test_as_gtt_mmap(fd, src, dst, object_size);
+ if (drmtest_run_subtest("display-pwrite-blt-gtt_mmap-performance")) {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ as_gtt_mmap(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("** mmap display copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
}
}