summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-04-13 08:18:10 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2017-04-13 10:10:24 +0100
commit3bdafec92fae2d04cb69354ffc26e1e32ac60d65 (patch)
tree0315cc61e7fa53309fed2842d59bc6bdb754ae5b
parent1ace3e0210400b70c60fcac11217a5b28b20b86e (diff)
igt/gem_exec_reloc: Check interactions with WC domain
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/ioctl_wrappers.c16
-rw-r--r--lib/ioctl_wrappers.h4
-rw-r--r--tests/gem_exec_reloc.c26
3 files changed, 38 insertions, 8 deletions
diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 72fb0ebc..48bdcc56 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -702,17 +702,23 @@ bool gem_mmap__has_wc(int fd)
if (has_wc == -1) {
struct drm_i915_getparam gp;
- int val = -1;
+ int mmap_version = -1;
+ int gtt_version = -1;
has_wc = 0;
memset(&gp, 0, sizeof(gp));
- gp.param = 30; /* MMAP_VERSION */
- gp.value = &val;
+ gp.param = 40; /* MMAP_GTT_VERSION */
+ gp.value = &gtt_version;
+ ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
- /* Do we have the new mmap_ioctl? */
+ memset(&gp, 0, sizeof(gp));
+ gp.param = 30; /* MMAP_VERSION */
+ gp.value = &mmap_version;
ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
- if (val >= 1) {
+
+ /* Do we have the new mmap_ioctl with DOMAIN_WC? */
+ if (mmap_version >= 1 && gtt_version >= 2) {
struct local_i915_gem_mmap_v2 arg;
/* Does this device support wc-mmaps ? */
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 56c5d14c..d6d8bad2 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -83,6 +83,10 @@ void *gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, uns
bool gem_mmap__has_wc(int fd);
void *gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
+#ifndef I915_GEM_DOMAIN_WC
+#define I915_GEM_DOMAIN_WC 0x80
+#endif
+
void *__gem_mmap__gtt(int fd, uint32_t handle, uint64_t size, unsigned prot);
void *__gem_mmap__cpu(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
void *__gem_mmap__wc(int fd, uint32_t handle, uint64_t offset, uint64_t size, unsigned prot);
diff --git a/tests/gem_exec_reloc.c b/tests/gem_exec_reloc.c
index f3da7d0a..39b7810e 100644
--- a/tests/gem_exec_reloc.c
+++ b/tests/gem_exec_reloc.c
@@ -145,7 +145,7 @@ static void from_mmap(int fd, uint64_t size, enum mode mode)
reloc_handle = gem_create(fd, size);
relocs = gem_mmap__wc(fd, reloc_handle, 0, size, PROT_WRITE);
gem_set_domain(fd, reloc_handle,
- I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
+ I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC);
gem_close(fd, reloc_handle);
break;
}
@@ -376,6 +376,8 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags)
if (before == I915_GEM_DOMAIN_CPU)
wc = gem_mmap__cpu(fd, obj.handle, 0, OBJSZ, PROT_WRITE);
else if (before == I915_GEM_DOMAIN_GTT)
+ wc = gem_mmap__gtt(fd, obj.handle, OBJSZ, PROT_WRITE);
+ else if (before == I915_GEM_DOMAIN_WC)
wc = gem_mmap__wc(fd, obj.handle, 0, OBJSZ, PROT_WRITE);
else
igt_assert(0);
@@ -403,6 +405,8 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags)
if (after == I915_GEM_DOMAIN_CPU)
wc = gem_mmap__cpu(fd, obj.handle, 0, OBJSZ, PROT_READ);
else if (after == I915_GEM_DOMAIN_GTT)
+ wc = gem_mmap__gtt(fd, obj.handle, OBJSZ, PROT_READ);
+ else if (after == I915_GEM_DOMAIN_WC)
wc = gem_mmap__wc(fd, obj.handle, 0, OBJSZ, PROT_READ);
else
igt_assert(0);
@@ -441,6 +445,8 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags)
if (before == I915_GEM_DOMAIN_CPU)
wc = gem_mmap__cpu(fd, obj.handle, 0, OBJSZ, PROT_WRITE);
else if (before == I915_GEM_DOMAIN_GTT)
+ wc = gem_mmap__gtt(fd, obj.handle, OBJSZ, PROT_WRITE);
+ else if (before == I915_GEM_DOMAIN_WC)
wc = gem_mmap__wc(fd, obj.handle, 0, OBJSZ, PROT_WRITE);
else
igt_assert(0);
@@ -468,6 +474,8 @@ static void basic_reloc(int fd, unsigned before, unsigned after, unsigned flags)
if (after == I915_GEM_DOMAIN_CPU)
wc = gem_mmap__cpu(fd, obj.handle, 0, OBJSZ, PROT_READ);
else if (after == I915_GEM_DOMAIN_GTT)
+ wc = gem_mmap__gtt(fd, obj.handle, OBJSZ, PROT_READ);
+ else if (after == I915_GEM_DOMAIN_WC)
wc = gem_mmap__wc(fd, obj.handle, 0, OBJSZ, PROT_READ);
else
igt_assert(0);
@@ -536,12 +544,19 @@ igt_main
} modes[] = {
{ "cpu", I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU },
{ "gtt", I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT },
+ { "wc", I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_WC },
{ "cpu-gtt", I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_GTT },
{ "gtt-cpu", I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_CPU },
+ { "cpu-wc", I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_WC },
+ { "wc-cpu", I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_CPU },
+ { "gtt-wc", I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_WC },
+ { "wc-gtt", I915_GEM_DOMAIN_WC, I915_GEM_DOMAIN_GTT },
{ "cpu-read", I915_GEM_DOMAIN_CPU, 0 },
{ "gtt-read", I915_GEM_DOMAIN_GTT, 0 },
+ { "wc-read", I915_GEM_DOMAIN_WC, 0 },
{ "write-cpu", 0, I915_GEM_DOMAIN_CPU },
{ "write-gtt", 0, I915_GEM_DOMAIN_GTT },
+ { "write-wc", 0, I915_GEM_DOMAIN_WC },
{ "write-read", 0, 0 },
{ },
}, *m;
@@ -577,8 +592,11 @@ igt_main
igt_subtest_f("%s%s%s",
f->basic ? "basic-" : "",
m->name,
- f->name)
+ f->name) {
+ if ((m->before | m->after) & I915_GEM_DOMAIN_WC)
+ igt_require(gem_mmap__has_wc(fd));
basic_reloc(fd, m->before, m->after, f->flags);
+ }
}
igt_fixture {
@@ -598,8 +616,10 @@ igt_main
from_mmap(fd, size, MEM | RO);
igt_subtest_f("cpu-%u", find_last_set(size) - 1)
from_mmap(fd, size, CPU);
- igt_subtest_f("wc-%u", find_last_set(size) - 1)
+ igt_subtest_f("wc-%u", find_last_set(size) - 1) {
+ igt_require(gem_mmap__has_wc(fd));
from_mmap(fd, size, WC);
+ }
igt_subtest_f("gtt-%u", find_last_set(size) - 1)
from_mmap(fd, size, GTT);
}