mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-22 07:16:14 +00:00
tests/gem_reloc_overflow: Extract reloc_tests
I'll be adding more stuff soon ;-) Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
0a587e24b7
commit
bf6f166035
@ -153,55 +153,10 @@ static void source_offset_tests(void)
|
||||
gem_close(fd, handle);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static void reloc_tests(void)
|
||||
{
|
||||
int i;
|
||||
size_t total_actual = 0;
|
||||
unsigned int total_unsigned = 0;
|
||||
int total_signed = 0;
|
||||
igt_subtest_init(argc, argv);
|
||||
|
||||
igt_fixture {
|
||||
int ring;
|
||||
uint32_t batch_data [2] = { MI_NOOP, MI_BATCH_BUFFER_END };
|
||||
|
||||
fd = drm_open_any();
|
||||
|
||||
/* Create giant reloc buffer area. */
|
||||
num = 257;
|
||||
entries = ((1ULL << 32) / (num - 1));
|
||||
reloc_size = entries * sizeof(struct drm_i915_gem_relocation_entry);
|
||||
reloc = mmap(NULL, reloc_size, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
igt_assert(reloc != MAP_FAILED);
|
||||
|
||||
/* Allocate the handles we'll need to wrap. */
|
||||
handles = calloc(num, sizeof(*handles));
|
||||
for (i = 0; i < num; i++)
|
||||
handles[i] = gem_create(fd, 4096);
|
||||
|
||||
if (intel_gen(intel_get_drm_devid(fd)) >= 6)
|
||||
ring = I915_EXEC_BLT;
|
||||
else
|
||||
ring = 0;
|
||||
|
||||
/* Create relocation objects. */
|
||||
execobjs = calloc(num, sizeof(*execobjs));
|
||||
execbuf.buffers_ptr = (uintptr_t)execobjs;
|
||||
execbuf.batch_start_offset = 0;
|
||||
execbuf.batch_len = 8;
|
||||
execbuf.cliprects_ptr = 0;
|
||||
execbuf.num_cliprects = 0;
|
||||
execbuf.DR1 = 0;
|
||||
execbuf.DR4 = 0;
|
||||
execbuf.flags = ring;
|
||||
i915_execbuffer2_set_context_id(execbuf, 0);
|
||||
execbuf.rsvd2 = 0;
|
||||
|
||||
batch_handle = gem_create(fd, 4096);
|
||||
|
||||
gem_write(fd, batch_handle, 0, batch_data, sizeof(batch_data));
|
||||
}
|
||||
|
||||
igt_subtest("invalid-address") {
|
||||
/* Attempt unmapped single entry. */
|
||||
@ -241,8 +196,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
total_unsigned += obj->relocation_count;
|
||||
total_signed += obj->relocation_count;
|
||||
total_actual += obj->relocation_count;
|
||||
}
|
||||
execbuf.buffer_count = num;
|
||||
|
||||
@ -250,6 +203,55 @@ int main(int argc, char *argv[])
|
||||
ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
|
||||
igt_assert(errno == EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
igt_subtest_init(argc, argv);
|
||||
|
||||
igt_fixture {
|
||||
int ring;
|
||||
uint32_t batch_data [2] = { MI_NOOP, MI_BATCH_BUFFER_END };
|
||||
|
||||
fd = drm_open_any();
|
||||
|
||||
/* Create giant reloc buffer area. */
|
||||
num = 257;
|
||||
entries = ((1ULL << 32) / (num - 1));
|
||||
reloc_size = entries * sizeof(struct drm_i915_gem_relocation_entry);
|
||||
reloc = mmap(NULL, reloc_size, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
igt_assert(reloc != MAP_FAILED);
|
||||
|
||||
/* Allocate the handles we'll need to wrap. */
|
||||
handles = calloc(num, sizeof(*handles));
|
||||
for (int i = 0; i < num; i++)
|
||||
handles[i] = gem_create(fd, 4096);
|
||||
|
||||
if (intel_gen(intel_get_drm_devid(fd)) >= 6)
|
||||
ring = I915_EXEC_BLT;
|
||||
else
|
||||
ring = 0;
|
||||
|
||||
/* Create relocation objects. */
|
||||
execobjs = calloc(num, sizeof(*execobjs));
|
||||
execbuf.buffers_ptr = (uintptr_t)execobjs;
|
||||
execbuf.batch_start_offset = 0;
|
||||
execbuf.batch_len = 8;
|
||||
execbuf.cliprects_ptr = 0;
|
||||
execbuf.num_cliprects = 0;
|
||||
execbuf.DR1 = 0;
|
||||
execbuf.DR4 = 0;
|
||||
execbuf.flags = ring;
|
||||
i915_execbuffer2_set_context_id(execbuf, 0);
|
||||
execbuf.rsvd2 = 0;
|
||||
|
||||
batch_handle = gem_create(fd, 4096);
|
||||
|
||||
gem_write(fd, batch_handle, 0, batch_data, sizeof(batch_data));
|
||||
}
|
||||
|
||||
reloc_tests();
|
||||
|
||||
source_offset_tests();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user