Expand gem_set_cacheing testing to handle the proposed DISPLAY domain
authorChris Wilson <chris@chris-wilson.co.uk>
Sat, 10 Aug 2013 14:49:33 +0000 (15:49 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Sat, 10 Aug 2013 14:49:33 +0000 (15:49 +0100)
lib/drmtest.c
lib/drmtest.h
tests/gem_partial_pwrite_pread.c
tests/gem_pread.c
tests/gem_pread_after_blit.c
tests/gem_pwrite.c
tests/gem_pwrite_pread.c

index e1abb18..f546784 100644 (file)
@@ -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)
index 70dbcc4..8320dbe 100644 (file)
@@ -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);
index eac2760..ee176b1 100644 (file)
@@ -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);
index 1e755c0..7037221 100644 (file)
@@ -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);
index 178357e..dce8241 100644 (file)
@@ -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]);
index 9c30dbb..447a200 100644 (file)
@@ -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);
index 09a1f00..1f9187f 100644 (file)
@@ -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);
+                       }
                }
        }