Commit 467796ac authored by Chris Wilson's avatar Chris Wilson 🤔

Expand gem_set_cacheing testing to handle the proposed DISPLAY domain

parent dbbf2e9b
......@@ -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)
......
......@@ -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);
......
......@@ -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);
......
......@@ -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,33 +106,36 @@ 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 (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 snooped pread %d bytes x %6d: %7.3fµs, %s\n",
object_size, count,
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);
gem_close(fd, dst);
......
......@@ -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]);
......
......@@ -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,33 +113,36 @@ 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 (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 snooped pwrite %d bytes x %6d: %7.3fµs, %s\n",
object_size, count,
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);
gem_close(fd, dst);
......
......@@ -398,8 +398,8 @@ 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 (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")) {
......@@ -433,9 +433,10 @@ int main(int argc, char **argv)
fflush(stdout);
}
}
}
gem_set_cacheing(fd, src, 1);
gem_set_cacheing(fd, dst, 1);
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")) {
......@@ -469,6 +470,44 @@ int main(int argc, char **argv)
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);
}
}
}
free(tmp);
gem_close(fd, src);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment