mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-23 15:56:33 +00:00
igt/gem_ctx_create: Exercise a trivial allocation failure
Trying to allocate and use lots of contexts with execlists and !llc end ups in faliure very quickly. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
1112abe5ec
commit
fbe92a222e
@ -29,42 +29,89 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
static int __gem_context_create(int fd, struct drm_i915_gem_context_create *arg)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, arg))
|
||||||
|
ret = -errno;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ret, fd;
|
static double elapsed(const struct timespec *start,
|
||||||
struct drm_i915_gem_context_create create;
|
const struct timespec *end)
|
||||||
|
{
|
||||||
|
return (end->tv_sec - start->tv_sec) + 1e-9*(end->tv_nsec - start->tv_nsec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void active(int fd, int timeout)
|
||||||
|
{
|
||||||
|
const uint32_t bbe = MI_BATCH_BUFFER_END;
|
||||||
|
struct drm_i915_gem_execbuffer2 execbuf;
|
||||||
|
struct drm_i915_gem_exec_object2 obj;
|
||||||
|
struct timespec start, end;
|
||||||
|
unsigned count = 0;
|
||||||
|
|
||||||
|
memset(&obj, 0, sizeof(obj));
|
||||||
|
obj.handle = gem_create(fd, 4096);
|
||||||
|
gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
|
||||||
|
|
||||||
|
memset(&execbuf, 0, sizeof(execbuf));
|
||||||
|
execbuf.buffers_ptr = (uintptr_t)&obj;
|
||||||
|
execbuf.buffer_count = 1;
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||||
|
do {
|
||||||
|
do {
|
||||||
|
|
||||||
|
execbuf.rsvd1 = gem_context_create(fd);
|
||||||
|
gem_execbuf(fd, &execbuf);
|
||||||
|
gem_context_destroy(fd, execbuf.rsvd1);
|
||||||
|
} while (++count & 1023);
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||||
|
} while (elapsed(&start, &end) < timeout);
|
||||||
|
|
||||||
|
gem_sync(fd, obj.handle);
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||||
|
igt_info("Context creation + execution: %.3f us\n",
|
||||||
|
elapsed(&start, &end) / count *1e6);
|
||||||
|
|
||||||
|
gem_close(fd, obj.handle);
|
||||||
|
}
|
||||||
|
|
||||||
igt_main
|
igt_main
|
||||||
{
|
{
|
||||||
igt_fixture
|
struct drm_i915_gem_context_create create;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
igt_fixture {
|
||||||
fd = drm_open_driver_render(DRIVER_INTEL);
|
fd = drm_open_driver_render(DRIVER_INTEL);
|
||||||
|
|
||||||
|
memset(&create, 0, sizeof(create));
|
||||||
|
igt_require(__gem_context_create(fd, &create) == 0);
|
||||||
|
gem_context_destroy(fd, create.ctx_id);
|
||||||
|
}
|
||||||
|
|
||||||
igt_subtest("basic") {
|
igt_subtest("basic") {
|
||||||
|
memset(&create, 0, sizeof(create));
|
||||||
create.ctx_id = rand();
|
create.ctx_id = rand();
|
||||||
create.pad = 0;
|
create.pad = 0;
|
||||||
|
igt_assert_eq(__gem_context_create(fd, &create), 0);
|
||||||
|
|
||||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
|
|
||||||
igt_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
|
|
||||||
igt_assert(ret == 0);
|
|
||||||
igt_assert(create.ctx_id != 0);
|
igt_assert(create.ctx_id != 0);
|
||||||
|
gem_context_destroy(fd, create.ctx_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
igt_subtest("invalid-pad") {
|
igt_subtest("invalid-pad") {
|
||||||
|
memset(&create, 0, sizeof(create));
|
||||||
create.ctx_id = rand();
|
create.ctx_id = rand();
|
||||||
create.pad = 0;
|
|
||||||
|
|
||||||
ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create);
|
|
||||||
igt_skip_on(ret != 0 && (errno == ENODEV || errno == EINVAL));
|
|
||||||
igt_assert(ret == 0);
|
|
||||||
igt_assert(create.ctx_id != 0);
|
|
||||||
|
|
||||||
create.pad = 1;
|
create.pad = 1;
|
||||||
|
igt_assert_eq(__gem_context_create(fd, &create), -EINVAL);
|
||||||
igt_assert(drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create) < 0 &&
|
|
||||||
errno == EINVAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
igt_subtest("active")
|
||||||
|
active(fd, 20);
|
||||||
|
|
||||||
igt_fixture
|
igt_fixture
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user