Commit 4de67b26 authored by Chris Wilson's avatar Chris Wilson 😣

igt: Mass conversion to to_user_pointer()

Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 0517d877
......@@ -117,11 +117,11 @@ static uint32_t busy_blt(int fd)
igt_assert(r - reloc <= ARRAY_SIZE(reloc));
munmap(map, 4096);
object[1].relocs_ptr = (uintptr_t)reloc;
object[1].relocs_ptr = to_user_pointer(reloc);
object[1].relocation_count = r - reloc;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (unsigned long)object;
execbuf.buffers_ptr = to_user_pointer(object);
execbuf.buffer_count = 2;
if (gen >= 6)
execbuf.flags = I915_EXEC_BLT;
......@@ -149,7 +149,7 @@ static bool exec_noop(int fd,
exec[2].handle = handles[BATCH];
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)exec;
execbuf.buffers_ptr = to_user_pointer(exec);
execbuf.buffer_count = 3;
execbuf.flags = ring;
igt_debug("Queuing handle for %s on ring %d\n",
......@@ -236,7 +236,7 @@ static void one(int fd, unsigned ring, uint32_t flags, unsigned test_flags)
int i, count, timeout;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
execbuf.flags = ring | flags;
if (gen < 6)
......@@ -246,7 +246,7 @@ static void one(int fd, unsigned ring, uint32_t flags, unsigned test_flags)
obj[SCRATCH].handle = gem_create(fd, 4096);
obj[BATCH].handle = gem_create(fd, size);
obj[BATCH].relocs_ptr = (uintptr_t)store;
obj[BATCH].relocs_ptr = to_user_pointer(store);
obj[BATCH].relocation_count = ARRAY_SIZE(store);
memset(store, 0, sizeof(store));
......@@ -469,13 +469,13 @@ static bool has_extended_busy_ioctl(int fd)
int i;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
memset(&obj, 0, sizeof(obj));
obj.handle = gem_create(fd, 4096);
obj.relocs_ptr = (uintptr_t)&reloc;
obj.relocs_ptr = to_user_pointer(&reloc);
obj.relocation_count = 1;
memset(&reloc, 0, sizeof(reloc));
......@@ -533,14 +533,14 @@ static void basic(int fd, unsigned ring, unsigned flags)
bool busy;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
execbuf.flags = ring;
memset(&obj, 0, sizeof(obj));
obj.handle = gem_create(fd, 4096);
obj.relocs_ptr = (uintptr_t)&reloc;
obj.relocs_ptr = to_user_pointer(&reloc);
obj.relocation_count = 1;
memset(&reloc, 0, sizeof(reloc));
......
......@@ -104,10 +104,10 @@ static void selfcopy(int fd, uint32_t handle, int loops)
drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
gem_exec[1].handle = create.handle;
gem_exec[1].relocation_count = 2;
gem_exec[1].relocs_ptr = (uintptr_t)reloc;
gem_exec[1].relocs_ptr = to_user_pointer(reloc);
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)gem_exec;
execbuf.buffers_ptr = to_user_pointer(gem_exec);
execbuf.buffer_count = 2;
execbuf.batch_len = (b - buf) * sizeof(*b);
if (HAS_BLT_RING(devid))
......@@ -117,7 +117,7 @@ static void selfcopy(int fd, uint32_t handle, int loops)
gem_pwrite.handle = create.handle;
gem_pwrite.offset = 0;
gem_pwrite.size = sizeof(buf);
gem_pwrite.data_ptr = (uintptr_t)buf;
gem_pwrite.data_ptr = to_user_pointer(buf);
if (drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite) == 0) {
while (loops-- &&
drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf) == 0)
......
......@@ -263,7 +263,7 @@ userptr_create_bo(const struct buffers *b)
ptr = mmap(NULL, userptr.user_size,
PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
igt_assert(ptr != (void *)-1);
userptr.user_ptr = (uintptr_t)ptr;
userptr.user_ptr = to_user_pointer(ptr);
#if 0
do_or_die(drmIoctl(fd, LOCAL_IOCTL_I915_GEM_USERPTR, &userptr));
......@@ -671,9 +671,9 @@ gpu_set_bo(struct buffers *buffers, drm_intel_bo *bo, uint32_t val)
gem_exec[1].handle = gem_create(fd, 4096);
gem_exec[1].relocation_count = 1;
gem_exec[1].relocs_ptr = (uintptr_t)reloc;
gem_exec[1].relocs_ptr = to_user_pointer(reloc);
execbuf.buffers_ptr = (uintptr_t)gem_exec;
execbuf.buffers_ptr = to_user_pointer(gem_exec);
execbuf.buffer_count = 2;
execbuf.batch_len = (b - buf) * sizeof(buf[0]);
if (gen >= 6)
......@@ -957,7 +957,7 @@ static igt_hang_t all_hang(void)
gem_write(fd, obj.handle, 0, &bbe, sizeof(&bbe));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
for_each_engine(fd, engine) {
......
......@@ -90,10 +90,10 @@ static void copy(int fd, uint32_t batch, uint32_t src, uint32_t dst)
gem_exec[1].handle = dst;
gem_exec[2].handle = batch;
gem_exec[2].relocation_count = 2;
gem_exec[2].relocs_ptr = (uintptr_t)gem_reloc;
gem_exec[2].relocs_ptr = to_user_pointer(gem_reloc);
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)gem_exec;
execbuf.buffers_ptr = to_user_pointer(gem_exec);
execbuf.buffer_count = 3;
execbuf.batch_len = 4096;
execbuf.flags = use_blt;
......@@ -110,7 +110,7 @@ static void exec(int fd, uint32_t handle)
gem_exec.handle = handle;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&gem_exec;
execbuf.buffers_ptr = to_user_pointer(&gem_exec);
execbuf.buffer_count = 1;
execbuf.batch_len = 4096;
......
......@@ -135,7 +135,7 @@ static void invalid_nonaligned_size(int fd)
gem_pwrite.handle = handle;
gem_pwrite.offset = PAGE_SIZE / 2;
gem_pwrite.size = PAGE_SIZE;
gem_pwrite.data_ptr = (uintptr_t)buf;
gem_pwrite.data_ptr = to_user_pointer(buf);
/* This should fail. Hence cannot use gem_write. */
igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite));
......
......@@ -118,11 +118,11 @@ static void test_ring(unsigned ring)
/* Fill the entire gart with batches and run them. */
memset(obj, 0, sizeof(obj));
obj[1].handle = shadow.handle;
obj[1].relocs_ptr = (uintptr_t)&shadow.reloc;
obj[1].relocs_ptr = to_user_pointer(&shadow.reloc);
obj[1].relocation_count = 1;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.flags = ring;
if (gen < 6)
execbuf.flags |= I915_EXEC_SECURE;
......
......@@ -115,7 +115,7 @@ static void run_on_ring(int fd, unsigned ring_id, const char *ring_name)
obj[0].batch[0] = MI_BATCH_BUFFER_END;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&execobj;
execbuf.buffers_ptr = to_user_pointer(&execobj);
execbuf.buffer_count = 1;
execbuf.flags = ring_id;
......
......@@ -34,7 +34,7 @@ static int exec(int fd, unsigned ring)
memset(&obj, 0, sizeof(obj));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
i915_execbuffer2_set_context_id(execbuf, 1);
......
......@@ -72,7 +72,7 @@ static void files(int core, int timeout, const int ncpus)
memset(&obj, 0, sizeof(obj));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
igt_fork(child, ncpus) {
......@@ -119,7 +119,7 @@ static void active(int fd, unsigned engine, int timeout, int ncpus)
gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
execbuf.flags = engine;
......@@ -260,7 +260,7 @@ static void maximum(int fd, int ncpus, unsigned mode)
gem_write(fd, obj[1].handle, 0, &bbe, sizeof(bbe));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
igt_fork(child, ncpus) {
......
......@@ -63,7 +63,7 @@ static int exec(int fd, uint32_t handle, int ring, int ctx_id)
gem_exec.rsvd1 = 0;
gem_exec.rsvd2 = 0;
execbuf.buffers_ptr = (uintptr_t)&gem_exec;
execbuf.buffers_ptr = to_user_pointer(&gem_exec);
execbuf.buffer_count = 1;
execbuf.batch_start_offset = 0;
execbuf.batch_len = 8;
......@@ -103,7 +103,7 @@ static void big_exec(int fd, uint32_t handle, int ring)
gem_exec[0].handle = handle;
execbuf.buffers_ptr = (uintptr_t)gem_exec;
execbuf.buffers_ptr = to_user_pointer(gem_exec);
execbuf.buffer_count = num_buffers + 1;
execbuf.batch_start_offset = 0;
execbuf.batch_len = 8;
......
......@@ -92,12 +92,12 @@ static void single(int fd, uint32_t handle,
memset(&reloc, 0, sizeof(reloc));
reloc.offset = 1024;
reloc.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
obj.relocs_ptr = (uintptr_t)&reloc;
obj.relocs_ptr = to_user_pointer(&reloc);
obj.relocation_count = 1;
}
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
execbuf.rsvd1 = contexts[0];
execbuf.flags = e->exec_id | e->flags;
......
......@@ -113,7 +113,7 @@ static int has_engine(int fd, const struct intel_execution_engine *e, uint32_t c
gem_write(fd, exec.handle, 0, &bbe, sizeof(bbe));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&exec;
execbuf.buffers_ptr = to_user_pointer(&exec);
execbuf.buffer_count = 1;
execbuf.flags = e->exec_id | e->flags;
execbuf.rsvd1 = ctx;
......@@ -185,7 +185,7 @@ static void single(const char *name, bool all_engines)
if (gen >= 4 && gen < 8)
reloc[n].offset += sizeof(uint32_t);
obj[2*n + 1].relocs_ptr = (uintptr_t)&reloc[n];
obj[2*n + 1].relocs_ptr = to_user_pointer(&reloc[n]);
obj[2*n + 1].relocation_count = 1;
}
......@@ -225,7 +225,7 @@ static void single(const char *name, bool all_engines)
obj[2*r + 1].handle = handle;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj[2*r];
execbuf.buffers_ptr = to_user_pointer(&obj[2*r]);
execbuf.buffer_count = 2;
execbuf.flags = engines[n % num_engines];
execbuf.rsvd1 = all[n];
......@@ -319,7 +319,7 @@ static void processes(void)
memset(&obj, 0, sizeof(obj));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
igt_permute_array(fds, num_ctx, xchg_int);
......@@ -356,7 +356,7 @@ static void *thread(void *data)
obj.handle = t->batch;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
ctx = malloc(t->num_ctx * sizeof(uint32_t));
......
......@@ -110,7 +110,7 @@ static void test_execbuf(int fd)
exec.handle = gem_create(fd, 4096);
gem_write(fd, exec.handle, 0, tmp, sizeof(tmp));
execbuf.buffers_ptr = (uintptr_t)&exec;
execbuf.buffers_ptr = to_user_pointer(&exec);
execbuf.buffer_count = 1;
wedge_gpu(fd);
......@@ -207,7 +207,7 @@ static void test_inflight(int fd)
gem_write(fd, obj[1].handle, 0, &bbe, sizeof(bbe));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
gem_execbuf(fd, &execbuf);
......
......@@ -108,9 +108,9 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo,
}
obj[n].handle = handle;
obj[n].relocation_count = 2;
obj[n].relocs_ptr = (uintptr_t)reloc;
obj[n].relocs_ptr = to_user_pointer(reloc);
exec.buffers_ptr = (uintptr_t)obj;
exec.buffers_ptr = to_user_pointer(obj);
exec.buffer_count = n_bo + 1;
exec.batch_start_offset = 0;
exec.batch_len = i * 4;
......
......@@ -107,10 +107,10 @@ copy(int fd, uint32_t dst, uint32_t src, uint32_t *all_bo, int n_bo)
obj[n].handle = all_bo[n];
obj[n].handle = handle;
obj[n].relocation_count = 2;
obj[n].relocs_ptr = (uintptr_t)reloc;
obj[n].relocs_ptr = to_user_pointer(reloc);
memset(&exec, 0, sizeof(exec));
exec.buffers_ptr = (uintptr_t)obj;
exec.buffers_ptr = to_user_pointer(obj);
exec.buffer_count = n_bo + 1;
if (HAS_BLT_RING(intel_get_drm_devid(fd)))
exec.flags |= I915_EXEC_BLT;
......
......@@ -108,7 +108,7 @@ static void many(int fd)
gem_write(fd, execobj[i].handle, 0, &bbe, sizeof(bbe));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)execobj;
execbuf.buffers_ptr = to_user_pointer(execobj);
execbuf.buffer_count = count + 1;
igt_require(__gem_execbuf(fd, &execbuf) == 0);
......@@ -119,7 +119,7 @@ static void many(int fd)
uint64_t factor = alignment / max_alignment;
execbuf.buffer_count = 2*count / factor;
execbuf.buffers_ptr =
(uintptr_t)(execobj + count - execbuf.buffer_count + 1);
to_user_pointer(execobj + count - execbuf.buffer_count + 1);
}
igt_debug("testing %lld x alignment=%#llx [%db]\n",
......@@ -153,7 +153,7 @@ static void single(int fd)
gem_write(fd, execobj.handle, 0, &batch, sizeof(batch));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&execobj;
execbuf.buffers_ptr = to_user_pointer(&execobj);
execbuf.buffer_count = 1;
gtt_size = gem_aperture_size(fd);
......
......@@ -39,7 +39,7 @@ static void store_dword(int fd, unsigned ring,
int i;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
execbuf.flags = ring;
if (gen < 6)
......@@ -57,7 +57,7 @@ static void store_dword(int fd, unsigned ring,
reloc.delta = offset;
reloc.read_domains = I915_GEM_DOMAIN_INSTRUCTION;
reloc.write_domain = I915_GEM_DOMAIN_INSTRUCTION;
obj[1].relocs_ptr = (uintptr_t)&reloc;
obj[1].relocs_ptr = to_user_pointer(&reloc);
obj[1].relocation_count = 1;
i = 0;
......@@ -100,7 +100,7 @@ static void one(int fd, unsigned ring, uint32_t flags)
obj[SCRATCH].handle = gem_create(fd, 4096);
obj[BATCH].handle = gem_create(fd, 4096);
obj[BATCH].relocs_ptr = (uintptr_t)&reloc;
obj[BATCH].relocs_ptr = to_user_pointer(&reloc);
obj[BATCH].relocation_count = 1;
memset(&reloc, 0, sizeof(reloc));
......@@ -135,7 +135,7 @@ static void one(int fd, unsigned ring, uint32_t flags)
i++;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
execbuf.flags = ring | flags;
igt_require(__gem_execbuf(fd, &execbuf) == 0);
......
......@@ -111,7 +111,7 @@ static void multi_write_domain(int fd)
exec[1].handle = handle;
exec[1].relocation_count = 1;
exec[1].relocs_ptr = (uintptr_t) reloc;
exec[1].relocs_ptr = to_user_pointer(reloc);
exec[1].alignment = 0;
exec[1].offset = 0;
exec[1].flags = 0;
......@@ -125,7 +125,7 @@ static void multi_write_domain(int fd)
reloc[0].write_domain = I915_GEM_DOMAIN_RENDER | I915_GEM_DOMAIN_INSTRUCTION;
reloc[0].presumed_offset = 0;
execbuf.buffers_ptr = (uintptr_t)exec;
execbuf.buffers_ptr = to_user_pointer(exec);
execbuf.buffer_count = 2;
execbuf.batch_start_offset = 0;
execbuf.batch_len = 8;
......
......@@ -38,7 +38,7 @@ static void noop(int fd, unsigned ring)
gem_write(fd, exec.handle, 0, &bbe, sizeof(bbe));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&exec;
execbuf.buffers_ptr = to_user_pointer(&exec);
execbuf.buffer_count = 1;
execbuf.flags = ring;
gem_execbuf(fd, &execbuf);
......@@ -60,7 +60,7 @@ static void readonly(int fd, unsigned ring)
execbuf = mmap(NULL, 4096, PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
igt_assert(execbuf != NULL);
execbuf->buffers_ptr = (uintptr_t)&exec;
execbuf->buffers_ptr = to_user_pointer(&exec);
execbuf->buffer_count = 1;
execbuf->flags = ring;
igt_assert(mprotect(execbuf, 4096, PROT_READ) == 0);
......@@ -89,7 +89,7 @@ static void gtt(int fd, unsigned ring)
exec->handle = gem_create(fd, 4096);
gem_write(fd, exec->handle, 0, &bbe, sizeof(bbe));
execbuf->buffers_ptr = (uintptr_t)exec;
execbuf->buffers_ptr = to_user_pointer(exec);
execbuf->buffer_count = 1;
execbuf->flags = ring;
......
......@@ -68,14 +68,14 @@ static void exec1(int fd, uint32_t handle, uint64_t reloc_ofs, unsigned flags, c
gem_exec[0].handle = handle;
gem_exec[0].relocation_count = 1;
gem_exec[0].relocs_ptr = (uintptr_t) gem_reloc;
gem_exec[0].relocs_ptr = to_user_pointer(gem_reloc);
gem_exec[0].alignment = 0;
gem_exec[0].offset = 0;
gem_exec[0].flags = 0;
gem_exec[0].rsvd1 = 0;
gem_exec[0].rsvd2 = 0;
execbuf.buffers_ptr = (uintptr_t)gem_exec;
execbuf.buffers_ptr = to_user_pointer(gem_exec);
execbuf.buffer_count = 1;
execbuf.batch_start_offset = 0;
execbuf.batch_len = 8;
......@@ -153,10 +153,10 @@ static void execN(int fd, uint32_t handle, uint64_t batch_size, unsigned flags,
memset(gem_exec, 0, sizeof(gem_exec));
gem_exec[0].handle = handle;
gem_exec[0].relocation_count = nreloc;
gem_exec[0].relocs_ptr = (uintptr_t)gem_reloc;
gem_exec[0].relocs_ptr = to_user_pointer(gem_reloc);
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)gem_exec;
execbuf.buffers_ptr = to_user_pointer(gem_exec);
execbuf.buffer_count = 1;
execbuf.batch_start_offset = 0;
execbuf.batch_len = 8;
......
......@@ -212,14 +212,14 @@ static void run(int object_size, bool dumb)
exec[2].relocation_count = len > 56 ? 4 : 2;
else
exec[2].relocation_count = len > 40 ? 4 : 2;
exec[2].relocs_ptr = (uintptr_t)reloc;
exec[2].relocs_ptr = to_user_pointer(reloc);
ring = 0;
if (HAS_BLT_RING(intel_get_drm_devid(fd)))
ring = I915_EXEC_BLT;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)exec;
execbuf.buffers_ptr = to_user_pointer(exec);
execbuf.buffer_count = 3;
execbuf.batch_len = len;
execbuf.flags = ring;
......
......@@ -90,7 +90,7 @@ static void all(int fd, unsigned flags, int timeout, int ncpus)
gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
......
......@@ -209,7 +209,7 @@ static void run(int object_size)
else
exec[2].relocation_count = len > 40 ? 4 : 2;
/* A newly mmap gtt bo will fault on first access. */
exec[2].relocs_ptr = (uintptr_t)gtt_relocs;
exec[2].relocs_ptr = to_user_pointer(gtt_relocs);
exec[2].alignment = 0;
exec[2].offset = 0;
exec[2].flags = 0;
......@@ -220,7 +220,7 @@ static void run(int object_size)
if (HAS_BLT_RING(devid))
ring = I915_EXEC_BLT;
execbuf.buffers_ptr = (uintptr_t)exec;
execbuf.buffers_ptr = to_user_pointer(exec);
execbuf.buffer_count = 3;
execbuf.batch_start_offset = 0;
execbuf.batch_len = len;
......
......@@ -50,7 +50,7 @@ static void store(int fd, unsigned ring, int fence, uint32_t target, unsigned of
int i;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
execbuf.flags = ring | LOCAL_EXEC_FENCE_IN;
execbuf.rsvd2 = fence;
......@@ -61,7 +61,7 @@ static void store(int fd, unsigned ring, int fence, uint32_t target, unsigned of
obj[SCRATCH].handle = target;
obj[BATCH].handle = gem_create(fd, 4096);
obj[BATCH].relocs_ptr = (uintptr_t)&reloc;
obj[BATCH].relocs_ptr = to_user_pointer(&reloc);
obj[BATCH].relocation_count = 1;
memset(&reloc, 0, sizeof(reloc));
......@@ -127,14 +127,14 @@ static void test_fence_busy(int fd, unsigned ring, unsigned flags)
gem_quiescent_gpu(fd);
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
execbuf.flags = ring | LOCAL_EXEC_FENCE_OUT;
memset(&obj, 0, sizeof(obj));
obj.handle = gem_create(fd, 4096);
obj.relocs_ptr = (uintptr_t)&reloc;
obj.relocs_ptr = to_user_pointer(&reloc);
obj.relocation_count = 1;
memset(&reloc, 0, sizeof(reloc));
......@@ -213,14 +213,14 @@ static void test_fence_await(int fd, unsigned ring, unsigned flags)
int fence, i;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)&obj;
execbuf.buffers_ptr = to_user_pointer(&obj);
execbuf.buffer_count = 1;
execbuf.flags = ring | LOCAL_EXEC_FENCE_OUT;
memset(&obj, 0, sizeof(obj));
obj.handle = gem_create(fd, 4096);
obj.relocs_ptr = (uintptr_t)&reloc;
obj.relocs_ptr = to_user_pointer(&reloc);
obj.relocation_count = 1;
memset(&reloc, 0, sizeof(reloc));
......
......@@ -160,7 +160,7 @@ static void run(int fd, unsigned ring, int nchild, int timeout,
}
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 3;
execbuf.flags = ring | (1 << 11) | (1<<12);
if (gen < 6)
......@@ -248,8 +248,8 @@ static void run(int fd, unsigned ring, int nchild, int timeout,
/* Inspect a different cacheline each iteration */
i = 16 * (idx % 64) + (idx / 64);
obj[1].relocs_ptr = (uintptr_t)&reloc0[i];
obj[2].relocs_ptr = (uintptr_t)&reloc1[i];
obj[1].relocs_ptr = to_user_pointer(&reloc0[i]);
obj[2].relocs_ptr = to_user_pointer(&reloc1[i]);
igt_assert_eq_u64(reloc0[i].presumed_offset, obj[0].offset);
igt_assert_eq_u64(reloc1[i].presumed_offset, obj[0].offset);
execbuf.batch_start_offset = 64*i;
......@@ -392,7 +392,7 @@ static void batch(int fd, unsigned ring, int nchild, int timeout,
map[i] = 0xabcdabcd;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
execbuf.flags = ring | (1 << 11) | (1<<12);
if (gen < 6)
......@@ -403,7 +403,7 @@ static void batch(int fd, unsigned ring, int nchild, int timeout,
igt_require(__gem_execbuf(fd, &execbuf) == 0);
obj[1].relocation_count = 1;
obj[1].relocs_ptr = (uintptr_t)&reloc;
obj[1].relocs_ptr = to_user_pointer(&reloc);
switch (mode) {
case BATCH_CPU:
......
......@@ -65,7 +65,7 @@ static void submit(int fd, int gen,
unsigned n;
memset(&obj, 0, sizeof(obj));
obj.relocs_ptr = (uintptr_t)reloc;
obj.relocs_ptr = to_user_pointer(reloc);
obj.relocation_count = 2;
memset(reloc, 0, 2*sizeof(*reloc));
......@@ -97,7 +97,7 @@ static void submit(int fd, int gen,
batch[++n] = 0; /* upper_32_bits(value) / nop */
batch[++n] = MI_BATCH_BUFFER_END;
eb->buffers_ptr = (uintptr_t)&obj;
eb->buffers_ptr = to_user_pointer(&obj);
for (unsigned i = 0; i < count; i++) {
obj.handle = handles[i];
reloc[0].target_handle = obj.handle;
......
......@@ -63,7 +63,7 @@ static void latency_on_ring(int fd, unsigned ring, const char *name)
reg = (volatile uint32_t *)((volatile char *)igt_global_mmio + RCS_TIMESTAMP);
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
execbuf.flags = ring;
execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC | LOCAL_I915_EXEC_HANDLE_LUT;
......@@ -83,7 +83,7 @@ static void latency_on_ring(int fd, unsigned ring, const char *name)
memset(&reloc,0, sizeof(reloc));
obj[1].relocation_count = 1;
obj[1].relocs_ptr = (uintptr_t)&reloc;
obj[1].relocs_ptr = to_user_pointer(&reloc);
gem_set_domain(fd, obj[1].handle,
I915_GEM_DOMAIN_GTT,
......@@ -181,7 +181,7 @@ static void latency_from_ring(int fd, unsigned ring, const char *name)
int i, j;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)obj;
execbuf.buffers_ptr = to_user_pointer(obj);
execbuf.buffer_count = 2;
execbuf.flags = ring;
execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC | LOCAL_I915_EXEC_HANDLE_LUT;
......@@ -201,7 +201,7 @@ static void latency_from_ring(int fd, unsigned ring, const char *name)
memset(&reloc,0, sizeof(reloc));
obj[1].relocation_count = 1;
obj[1].relocs_ptr = (uintptr_t)&reloc;
obj[1].relocs_ptr = to_user_pointer(&reloc);
gem_set_domain(fd, obj[1].handle,
I915_GEM_DOMAIN_GTT,
......
......@@ -73,7 +73,7 @@ static int has_exec_lut(int fd)
struct drm_i915_gem_execbuffer2 execbuf;
memset(&execbuf, 0, sizeof(execbuf));
execbuf.buffers_ptr = (uintptr_t)(gem_exec + MAX_NUM_EXEC);
execbuf.buffers_ptr = to_user_pointer((gem_exec + MAX_NUM_EXEC));
execbuf.buffer_count = 1;
execbuf.flags = LOCAL_I915_EXEC_HANDLE_LUT;
......@@ -152,11 +152,11 @@ igt_simple_main
reloc = mem_reloc;
gem_exec[MAX_NUM_EXEC].relocation_count = m;
gem_exec[MAX_NUM_EXEC].relocs_ptr = (uintptr_t)reloc;
gem_exec[MAX_NUM_EXEC].relocs_ptr = to_user_pointer(reloc);
objects = gem_exec + MAX_NUM_EXEC - n;
memset(&execbuf, 0, sizeof(execbuf));