summaryrefslogtreecommitdiff
path: root/tests/gem_ctx_create.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-03-02 09:19:28 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2016-03-02 09:46:18 +0000
commit02befb8b03f8c052394670f9988571429d13b227 (patch)
tree3353b0030813ca8992ab8a40034312cb427cdd52 /tests/gem_ctx_create.c
parentfbe92a222ecffbb848147509674b4c12377d7a4d (diff)
igt/gem_ctx_create: Exercise implicit per-fd context creation
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/gem_ctx_create.c')
-rw-r--r--tests/gem_ctx_create.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index 0418bf8b..930b30f7 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -45,6 +45,43 @@ static double elapsed(const struct timespec *start,
return (end->tv_sec - start->tv_sec) + 1e-9*(end->tv_nsec - start->tv_nsec);
}
+static void files(int core, 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;
+ uint32_t batch, name;
+ unsigned count = 0;
+
+ batch = gem_create(core, 4096);
+ gem_write(core, batch, 0, &bbe, sizeof(bbe));
+ name = gem_flink(core, batch);
+
+ memset(&obj, 0, sizeof(obj));
+ memset(&execbuf, 0, sizeof(execbuf));
+ execbuf.buffers_ptr = (uintptr_t)&obj;
+ execbuf.buffer_count = 1;
+
+ clock_gettime(CLOCK_MONOTONIC, &start);
+ do {
+ do {
+ int fd = drm_open_driver(DRIVER_INTEL);
+ obj.handle = gem_open(fd, name);
+ gem_execbuf(fd, &execbuf);
+ close(fd);
+ } while (++count & 1023);
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ } while (elapsed(&start, &end) < timeout);
+
+ gem_sync(core, batch);
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ igt_info("File creation + execution: %.3f us\n",
+ elapsed(&start, &end) / count *1e6);
+
+ gem_close(core, batch);
+}
+
static void active(int fd, int timeout)
{
const uint32_t bbe = MI_BATCH_BUFFER_END;
@@ -64,7 +101,6 @@ static void active(int fd, int timeout)
clock_gettime(CLOCK_MONOTONIC, &start);
do {
do {
-
execbuf.rsvd1 = gem_context_create(fd);
gem_execbuf(fd, &execbuf);
gem_context_destroy(fd, execbuf.rsvd1);
@@ -86,7 +122,7 @@ igt_main
int fd;
igt_fixture {
- fd = drm_open_driver_render(DRIVER_INTEL);
+ fd = drm_open_driver(DRIVER_INTEL);
memset(&create, 0, sizeof(create));
igt_require(__gem_context_create(fd, &create) == 0);
@@ -109,6 +145,9 @@ igt_main
igt_assert_eq(__gem_context_create(fd, &create), -EINVAL);
}
+ igt_subtest("files")
+ files(fd, 20);
+
igt_subtest("active")
active(fd, 20);