summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2021-09-10 15:38:53 -0500
committerJason Ekstrand <jason@jlekstrand.net>2021-09-10 15:40:53 -0500
commit2ef7cdb59b54dc6b0dc5d50317c1407ee75c08d9 (patch)
treedae1d4a0a721212a31454c91267ccdf43a2c2da3
parentc14967c0fda8f431ce1b03934991d45f11e485d5 (diff)
xe/vm: Test binding a BO and binding a BO several timeswip/sand
-rw-r--r--tests/xe/xe_vm.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/xe/xe_vm.c b/tests/xe/xe_vm.c
index fcaed0f4..8399a85e 100644
--- a/tests/xe/xe_vm.c
+++ b/tests/xe/xe_vm.c
@@ -217,6 +217,62 @@ test_scratch(int fd)
xe_vm_destroy(fd, vm);
}
+static void
+__test_bind_one_bo(int fd, int n_addrs, uint64_t *addrs)
+{
+ uint32_t vm = xe_vm_create(fd, 0);
+ uint32_t bo, bo_size = 4096;
+ void *map;
+ int i;
+
+ bo = xe_bo_create(fd, vm, bo_size);
+ map = xe_bo_map(fd, bo, bo_size);
+ memset(map, 0, bo_size);
+
+ for (i = 0; i < n_addrs; i++) {
+ uint64_t bind_addr = addrs[i] & ~(uint64_t)(bo_size - 1);
+
+ xe_vm_bind(fd, vm, bo, 0, bind_addr, bo_size);
+ }
+
+ write_dwords(fd, vm, n_addrs, addrs);
+
+ for (i = 0; i < n_addrs; i++) {
+ uint32_t *dw = map + (addrs[i] & (bo_size - 1));
+
+ igt_assert_eq(*dw, hash_addr(addrs[i]));
+ }
+ munmap(map, bo_size);
+
+ gem_close(fd, bo);
+ xe_vm_destroy(fd, vm);
+}
+
+static void
+test_bind_once(int fd)
+{
+ uint64_t addr = 0x7ffdb86402d8ull;
+
+ __test_bind_one_bo(fd, 1, &addr);
+}
+
+static void
+test_bind_one_bo_many_times(int fd)
+{
+ uint64_t addrs[] = {
+ 0x000000000000ull,
+ 0x0000b86402d4ull,
+ 0x0001b86402d8ull,
+ 0x7ffdb86402dcull,
+ 0x7fffffffffecull,
+ 0x800000000004ull,
+ 0x3ffdb86402e8ull,
+ 0xfffffffffffcull,
+ };
+
+ __test_bind_one_bo(fd, ARRAY_SIZE(addrs), addrs);
+}
+
igt_main
{
int fd;
@@ -224,6 +280,12 @@ igt_main
igt_fixture
fd = drm_open_driver(DRIVER_XE);
+ igt_subtest("bind-once")
+ test_bind_once(fd);
+
+ igt_subtest("bind-one-bo-many-times")
+ test_bind_one_bo_many_times(fd);
+
igt_subtest("scratch")
test_scratch(fd);