blob: 5d0d4957545ee9c6e1c5b529c099cf5c07f5c31d [file] [log] [blame]
Chris Wilson07d59b32011-01-20 22:10:10 +00001/*
2 * Copyright © 2011 Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Authors:
24 * Chris Wilson <chris@chris-wilson.co.uk>
25 *
26 */
27
Thomas Wood804e11f2015-08-17 17:57:43 +010028#include "igt.h"
Chris Wilson9fbf72b2017-01-22 18:24:37 +000029#include "igt_rand.h"
Chris Wilsonc6e26e42016-07-22 12:58:54 +010030#include "igt_sysfs.h"
Chris Wilson9fbf72b2017-01-22 18:24:37 +000031
Chris Wilson07d59b32011-01-20 22:10:10 +000032#include <unistd.h>
33#include <stdlib.h>
34#include <stdint.h>
35#include <stdio.h>
36#include <string.h>
Chris Wilson07d59b32011-01-20 22:10:10 +000037#include <fcntl.h>
38#include <inttypes.h>
39#include <errno.h>
40#include <sys/stat.h>
41#include <sys/ioctl.h>
Chris Wilson07d59b32011-01-20 22:10:10 +000042#include <sys/time.h>
Chris Wilsonb4307092015-07-01 13:53:07 +010043#include <time.h>
Chris Wilson07d59b32011-01-20 22:10:10 +000044#include "drm.h"
Chris Wilson07d59b32011-01-20 22:10:10 +000045
Chris Wilsoncd8d3802015-03-24 09:15:12 +000046#define LOCAL_I915_EXEC_NO_RELOC (1<<11)
47#define LOCAL_I915_EXEC_HANDLE_LUT (1<<12)
48
Chris Wilson3a7325e2016-03-08 11:43:31 +000049#define LOCAL_I915_EXEC_BSD_SHIFT (13)
50#define LOCAL_I915_EXEC_BSD_MASK (3 << LOCAL_I915_EXEC_BSD_SHIFT)
Daniel Vetter51f08302012-12-05 19:29:11 +010051
Chris Wilson3a7325e2016-03-08 11:43:31 +000052#define ENGINE_FLAGS (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK)
Chris Wilson2659cbb2015-03-26 12:09:57 +000053
Chris Wilson9fbf72b2017-01-22 18:24:37 +000054#define FORKED 1
55#define CHAINED 2
56#define CONTEXT 4
57
Chris Wilson3a7325e2016-03-08 11:43:31 +000058static double elapsed(const struct timespec *start, const struct timespec *end)
59{
60 return ((end->tv_sec - start->tv_sec) +
61 (end->tv_nsec - start->tv_nsec)*1e-9);
62}
63
Chris Wilson870c7742016-03-28 15:29:46 +010064static double nop_on_ring(int fd, uint32_t handle, unsigned ring_id,
65 int timeout, unsigned long *out)
Chris Wilson07d59b32011-01-20 22:10:10 +000066{
67 struct drm_i915_gem_execbuffer2 execbuf;
Chris Wilson3a7325e2016-03-08 11:43:31 +000068 struct drm_i915_gem_exec_object2 obj;
69 struct timespec start, now;
Chris Wilson870c7742016-03-28 15:29:46 +010070 unsigned long count;
Daniel Vetter8f5387e2013-08-13 13:20:58 +020071
Chris Wilson3a7325e2016-03-08 11:43:31 +000072 memset(&obj, 0, sizeof(obj));
73 obj.handle = handle;
Chris Wilson07d59b32011-01-20 22:10:10 +000074
Chris Wilsoncd8d3802015-03-24 09:15:12 +000075 memset(&execbuf, 0, sizeof(execbuf));
Chris Wilson4de67b22017-01-02 11:05:21 +000076 execbuf.buffers_ptr = to_user_pointer(&obj);
Chris Wilsoncd8d3802015-03-24 09:15:12 +000077 execbuf.buffer_count = 1;
78 execbuf.flags = ring_id;
79 execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
80 execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
Chris Wilson3e2443f2016-03-10 11:50:53 +000081 if (__gem_execbuf(fd, &execbuf)) {
Chris Wilsoncd8d3802015-03-24 09:15:12 +000082 execbuf.flags = ring_id;
Chris Wilson3a7325e2016-03-08 11:43:31 +000083 gem_execbuf(fd, &execbuf);
Chris Wilsoncd8d3802015-03-24 09:15:12 +000084 }
Chris Wilson71f41532016-04-22 16:55:29 +010085 intel_detect_and_clear_missed_interrupts(fd);
Chris Wilsoncd8d3802015-03-24 09:15:12 +000086
Chris Wilson870c7742016-03-28 15:29:46 +010087 count = 0;
Chris Wilson3a7325e2016-03-08 11:43:31 +000088 clock_gettime(CLOCK_MONOTONIC, &start);
89 do {
Chris Wilson870c7742016-03-28 15:29:46 +010090 for (int loop = 0; loop < 1024; loop++)
Chris Wilson3a7325e2016-03-08 11:43:31 +000091 gem_execbuf(fd, &execbuf);
Chris Wilson870c7742016-03-28 15:29:46 +010092
93 count += 1024;
Chris Wilson3a7325e2016-03-08 11:43:31 +000094 clock_gettime(CLOCK_MONOTONIC, &now);
Chris Wilson870c7742016-03-28 15:29:46 +010095 } while (elapsed(&start, &now) < timeout);
Chris Wilson71f41532016-04-22 16:55:29 +010096 igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
Chris Wilson3a7325e2016-03-08 11:43:31 +000097
Chris Wilson870c7742016-03-28 15:29:46 +010098 *out = count;
99 return elapsed(&start, &now);
100}
101
102static void single(int fd, uint32_t handle,
103 unsigned ring_id, const char *ring_name)
104{
105 double time;
106 unsigned long count;
107
108 gem_require_ring(fd, ring_id);
109
110 time = nop_on_ring(fd, handle, ring_id, 20, &count);
111 igt_info("%s: %'lu cycles: %.3fus\n",
112 ring_name, count, time*1e6 / count);
Chris Wilson3a7325e2016-03-08 11:43:31 +0000113}
114
Chris Wilson0aacdac2016-03-09 21:06:16 +0000115static bool ignore_engine(int fd, unsigned engine)
116{
117 if (engine == 0)
118 return true;
119
120 if (gem_has_bsd2(fd) && engine == I915_EXEC_BSD)
121 return true;
122
123 return false;
124}
125
Chris Wilson4cce7152016-09-08 13:43:17 +0100126static void parallel(int fd, uint32_t handle, int timeout)
127{
128 struct drm_i915_gem_execbuffer2 execbuf;
129 struct drm_i915_gem_exec_object2 obj;
Chris Wilson4cce7152016-09-08 13:43:17 +0100130 unsigned engines[16];
131 const char *names[16];
132 unsigned nengine;
133 unsigned engine;
134 unsigned long count;
135 double time, sum;
136
137 sum = 0;
138 nengine = 0;
139 for_each_engine(fd, engine) {
140 if (ignore_engine(fd, engine))
141 continue;
142
143 engines[nengine] = engine;
144 names[nengine] = e__->name;
145 nengine++;
146
147 time = nop_on_ring(fd, handle, engine, 1, &count) / count;
148 sum += time;
149 igt_debug("%s: %.3fus\n", e__->name, 1e6*time);
150 }
151 igt_require(nengine);
152 igt_info("average (individually): %.3fus\n", sum/nengine*1e6);
153
154 memset(&obj, 0, sizeof(obj));
155 obj.handle = handle;
156
157 memset(&execbuf, 0, sizeof(execbuf));
Chris Wilson4de67b22017-01-02 11:05:21 +0000158 execbuf.buffers_ptr = to_user_pointer(&obj);
Chris Wilson4cce7152016-09-08 13:43:17 +0100159 execbuf.buffer_count = 1;
160 execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
161 execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
162 if (__gem_execbuf(fd, &execbuf)) {
163 execbuf.flags = 0;
164 gem_execbuf(fd, &execbuf);
165 }
Chris Wilson4cce7152016-09-08 13:43:17 +0100166 intel_detect_and_clear_missed_interrupts(fd);
167
168 igt_fork(child, nengine) {
Chris Wilsonf565b6c2016-09-08 20:59:55 +0100169 struct timespec start, now;
170
Chris Wilson4cce7152016-09-08 13:43:17 +0100171 execbuf.flags &= ~ENGINE_FLAGS;
172 execbuf.flags |= engines[child];
173
174 count = 0;
175 clock_gettime(CLOCK_MONOTONIC, &start);
176 do {
177 for (int loop = 0; loop < 1024; loop++)
178 gem_execbuf(fd, &execbuf);
179 count += 1024;
180 clock_gettime(CLOCK_MONOTONIC, &now);
181 } while (elapsed(&start, &now) < timeout);
Chris Wilson4cce7152016-09-08 13:43:17 +0100182 time = elapsed(&start, &now) / count;
183 igt_info("%s: %ld cycles, %.3fus\n", names[child], count, 1e6*time);
184 }
185
186 igt_waitchildren();
187 igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
188
189}
190
191static void series(int fd, uint32_t handle, int timeout)
Chris Wilson3a7325e2016-03-08 11:43:31 +0000192{
193 struct drm_i915_gem_execbuffer2 execbuf;
194 struct drm_i915_gem_exec_object2 obj;
Chris Wilsonf565b6c2016-09-08 20:59:55 +0100195 struct timespec start, now, sync;
Chris Wilson3a7325e2016-03-08 11:43:31 +0000196 unsigned engines[16];
197 unsigned nengine;
198 unsigned engine;
Chris Wilson870c7742016-03-28 15:29:46 +0100199 unsigned long count;
Chris Wilson41a26b52016-03-28 16:26:01 +0100200 double time, max = 0, min = HUGE_VAL, sum = 0;
Chris Wilson870c7742016-03-28 15:29:46 +0100201 const char *name;
Chris Wilson3a7325e2016-03-08 11:43:31 +0000202
203 nengine = 0;
Chris Wilson870c7742016-03-28 15:29:46 +0100204 for_each_engine(fd, engine) {
205 if (ignore_engine(fd, engine))
206 continue;
207
208 time = nop_on_ring(fd, handle, engine, 1, &count) / count;
209 if (time > max) {
210 name = e__->name;
211 max = time;
212 }
Chris Wilson41a26b52016-03-28 16:26:01 +0100213 if (time < min)
214 min = time;
Chris Wilson870c7742016-03-28 15:29:46 +0100215 sum += time;
216 engines[nengine++] = engine;
217 }
Chris Wilson0aacdac2016-03-09 21:06:16 +0000218 igt_require(nengine);
Chris Wilsonf565b6c2016-09-08 20:59:55 +0100219 igt_info("Maximum execution latency on %s, %.3fus, min %.3fus, total %.3fus per cycle, average %.3fus\n",
220 name, max*1e6, min*1e6, sum*1e6, sum/nengine*1e6);
Chris Wilson3a7325e2016-03-08 11:43:31 +0000221
222 memset(&obj, 0, sizeof(obj));
223 obj.handle = handle;
224
225 memset(&execbuf, 0, sizeof(execbuf));
Chris Wilson4de67b22017-01-02 11:05:21 +0000226 execbuf.buffers_ptr = to_user_pointer(&obj);
Chris Wilson3a7325e2016-03-08 11:43:31 +0000227 execbuf.buffer_count = 1;
228 execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
229 execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
Chris Wilson3e2443f2016-03-10 11:50:53 +0000230 if (__gem_execbuf(fd, &execbuf)) {
Chris Wilson3a7325e2016-03-08 11:43:31 +0000231 execbuf.flags = 0;
232 gem_execbuf(fd, &execbuf);
Chris Wilson07d59b32011-01-20 22:10:10 +0000233 }
Chris Wilson71f41532016-04-22 16:55:29 +0100234 intel_detect_and_clear_missed_interrupts(fd);
Chris Wilson3a7325e2016-03-08 11:43:31 +0000235
Chris Wilson870c7742016-03-28 15:29:46 +0100236 count = 0;
Chris Wilson3a7325e2016-03-08 11:43:31 +0000237 clock_gettime(CLOCK_MONOTONIC, &start);
238 do {
239 for (int loop = 0; loop < 1024; loop++) {
240 for (int n = 0; n < nengine; n++) {
241 execbuf.flags &= ~ENGINE_FLAGS;
242 execbuf.flags |= engines[n];
243 gem_execbuf(fd, &execbuf);
244 }
245 }
246 count += nengine * 1024;
247 clock_gettime(CLOCK_MONOTONIC, &now);
Chris Wilson772393e2016-03-14 14:31:36 +0000248 } while (elapsed(&start, &now) < timeout); /* Hang detection ~120s */
Chris Wilson3a7325e2016-03-08 11:43:31 +0000249 gem_sync(fd, handle);
Chris Wilsonf565b6c2016-09-08 20:59:55 +0100250 clock_gettime(CLOCK_MONOTONIC, &sync);
251 igt_debug("sync time: %.3fus\n", elapsed(&now, &sync)*1e6);
Chris Wilson71f41532016-04-22 16:55:29 +0100252 igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
Chris Wilson3a7325e2016-03-08 11:43:31 +0000253
Chris Wilson870c7742016-03-28 15:29:46 +0100254 time = elapsed(&start, &now) / count;
Chris Wilsonf565b6c2016-09-08 20:59:55 +0100255 igt_info("All (%d engines): %'lu cycles, average %.3fus per cycle [expected %.3fus]\n",
Chris Wilson61b19a42016-09-08 14:50:32 +0100256 nengine, count, 1e6*time, 1e6*((max-min)/nengine+min));
Chris Wilson41a26b52016-03-28 16:26:01 +0100257
Chris Wilsona0eebbd2016-09-08 13:29:31 +0100258 /* The rate limiting step should be how fast the slowest engine can
259 * execute its queue of requests, as when we wait upon a full ring all
260 * dispatch is frozen. So in general we cannot go faster than the
261 * slowest engine (but as all engines are in lockstep, they should all
262 * be executing in parallel and so the average should be max/nengines),
263 * but we should equally not go any slower.
264 *
265 * However, that depends upon being able to submit fast enough, and
266 * that in turns depends upon debugging turned off and no bottlenecks
267 * within the driver. We cannot assert that we hit ideal conditions
268 * across all engines, so we only look for an outrageous error
269 * condition.
Chris Wilson41a26b52016-03-28 16:26:01 +0100270 */
Chris Wilsona0eebbd2016-09-08 13:29:31 +0100271 igt_assert_f(time < 2*sum,
272 "Average time (%.3fus) exceeds expectation for parallel execution (min %.3fus, max %.3fus; limit set at %.3fus)\n",
273 1e6*time, 1e6*min, 1e6*max, 1e6*sum*2);
Daniel Vetterd9d95782012-12-04 17:13:05 +0100274}
Daniel Vetter8f5387e2013-08-13 13:20:58 +0200275
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000276static void xchg(void *array, unsigned i, unsigned j)
Chris Wilson817d57f2017-01-20 17:17:42 +0000277{
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000278 unsigned *u = array;
279 unsigned tmp = u[i];
280 u[i] = u[j];
281 u[j] = tmp;
282}
283
284static int __gem_context_create(int fd, uint32_t *ctx_id)
285{
286 struct drm_i915_gem_context_create arg;
287 int ret = 0;
288
289 memset(&arg, 0, sizeof(arg));
290 if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg))
291 ret = -errno;
292
293 *ctx_id = arg.ctx_id;
294 return ret;
295}
296static void sequential(int fd, uint32_t handle, unsigned flags, int timeout)
297{
298 const int ncpus = flags & FORKED ? sysconf(_SC_NPROCESSORS_ONLN) : 1;
Chris Wilson817d57f2017-01-20 17:17:42 +0000299 struct drm_i915_gem_execbuffer2 execbuf;
300 struct drm_i915_gem_exec_object2 obj[2];
Chris Wilson817d57f2017-01-20 17:17:42 +0000301 unsigned engines[16];
302 unsigned nengine;
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000303 double *results;
Chris Wilson817d57f2017-01-20 17:17:42 +0000304 double time, sum;
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000305 unsigned n;
306
307 results = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0);
308 igt_assert(results != MAP_FAILED);
Chris Wilson817d57f2017-01-20 17:17:42 +0000309
310 nengine = 0;
311 sum = 0;
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000312 for_each_engine(fd, n) {
313 unsigned long count;
314
315 if (ignore_engine(fd, n))
Chris Wilson817d57f2017-01-20 17:17:42 +0000316 continue;
317
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000318 time = nop_on_ring(fd, handle, n, 1, &count) / count;
Chris Wilson817d57f2017-01-20 17:17:42 +0000319 sum += time;
320 igt_debug("%s: %.3fus\n", e__->name, 1e6*time);
321
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000322 engines[nengine++] = n;
Chris Wilson817d57f2017-01-20 17:17:42 +0000323 }
324 igt_require(nengine);
325 igt_info("Total (individual) execution latency %.3fus per cycle\n",
326 1e6*sum);
327
328 memset(obj, 0, sizeof(obj));
329 obj[0].handle = gem_create(fd, 4096);
330 obj[0].flags = EXEC_OBJECT_WRITE;
331 obj[1].handle = handle;
332
333 memset(&execbuf, 0, sizeof(execbuf));
334 execbuf.buffers_ptr = to_user_pointer(obj);
335 execbuf.buffer_count = 2;
336 execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT;
337 execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC;
338 igt_require(__gem_execbuf(fd, &execbuf) == 0);
339
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000340 if (flags & CONTEXT) {
341 uint32_t id;
342
343 igt_require(__gem_context_create(fd, &id) == 0);
344 execbuf.rsvd1 = id;
345 }
346
347 for (n = 0; n < nengine; n++) {
348 execbuf.flags &= ~ENGINE_FLAGS;
349 execbuf.flags |= engines[n];
350 igt_require(__gem_execbuf(fd, &execbuf) == 0);
351 }
352
Chris Wilson817d57f2017-01-20 17:17:42 +0000353 intel_detect_and_clear_missed_interrupts(fd);
354
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000355 igt_fork(child, ncpus) {
356 struct timespec start, now;
357 unsigned long count;
358
359 obj[0].handle = gem_create(fd, 4096);
360 gem_execbuf(fd, &execbuf);
361
362 if (flags & CONTEXT)
363 execbuf.rsvd1 = gem_context_create(fd);
364
365 hars_petruska_f54_1_random_perturb(child);
366
367 count = 0;
368 clock_gettime(CLOCK_MONOTONIC, &start);
369 do {
370 igt_permute_array(engines, nengine, xchg);
371 if (flags & CHAINED) {
372 for (n = 0; n < nengine; n++) {
373 execbuf.flags &= ~ENGINE_FLAGS;
374 execbuf.flags |= engines[n];
375 for (int loop = 0; loop < 1024; loop++)
376 gem_execbuf(fd, &execbuf);
377 }
378 } else {
379 for (int loop = 0; loop < 1024; loop++) {
380 for (n = 0; n < nengine; n++) {
381 execbuf.flags &= ~ENGINE_FLAGS;
382 execbuf.flags |= engines[n];
383 gem_execbuf(fd, &execbuf);
384 }
385 }
Chris Wilson817d57f2017-01-20 17:17:42 +0000386 }
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000387 count += 1024;
388 clock_gettime(CLOCK_MONOTONIC, &now);
389 } while (elapsed(&start, &now) < timeout); /* Hang detection ~120s */
Chris Wilsone7a0d062017-03-21 13:12:07 +0000390
391 gem_sync(fd, obj[0].handle);
392 clock_gettime(CLOCK_MONOTONIC, &now);
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000393 results[child] = elapsed(&start, &now) / count;
394
395 if (flags & CONTEXT)
396 gem_context_destroy(fd, execbuf.rsvd1);
397
398 gem_close(fd, obj[0].handle);
399 }
400 igt_waitchildren();
Chris Wilson817d57f2017-01-20 17:17:42 +0000401 igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
402
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000403 results[ncpus] = 0;
404 for (n = 0; n < ncpus; n++)
405 results[ncpus] += results[n];
406 results[ncpus] /= ncpus;
407
408 igt_info("Sequential (%d engines, %d processes): average %.3fus per cycle [expected %.3fus]\n",
409 nengine, ncpus, 1e6*results[ncpus], 1e6*sum*ncpus);
410
411 if (flags & CONTEXT)
412 gem_context_destroy(fd, execbuf.rsvd1);
Chris Wilson817d57f2017-01-20 17:17:42 +0000413
414 gem_close(fd, obj[0].handle);
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000415 munmap(results, 4096);
Chris Wilson817d57f2017-01-20 17:17:42 +0000416}
417
Chris Wilsonc6e26e42016-07-22 12:58:54 +0100418static void print_welcome(int fd)
419{
420 bool active;
Chris Wilsonc6e26e42016-07-22 12:58:54 +0100421 int dir;
422
423 dir = igt_sysfs_open_parameters(fd);
424 if (dir < 0)
425 return;
426
Chris Wilsonb64d10c2016-07-22 17:53:51 +0100427 active = igt_sysfs_get_boolean(dir, "enable_guc_submission");
Chris Wilsonc6e26e42016-07-22 12:58:54 +0100428 if (active) {
429 igt_info("Using GuC submission\n");
430 goto out;
431 }
432
Chris Wilsonb64d10c2016-07-22 17:53:51 +0100433 active = igt_sysfs_get_boolean(dir, "enable_execlists");
Chris Wilsonc6e26e42016-07-22 12:58:54 +0100434 if (active) {
435 igt_info("Using Execlists submission\n");
436 goto out;
437 }
438
Chris Wilsonb64d10c2016-07-22 17:53:51 +0100439 active = igt_sysfs_get_boolean(dir, "semaphores");
Chris Wilsonf565b6c2016-09-08 20:59:55 +0100440 igt_info("Using Legacy submission%s\n",
Chris Wilsonc6e26e42016-07-22 12:58:54 +0100441 active ? ", with semaphores" : "");
442
443out:
444 close(dir);
445}
446
Daniel Vetter071e9ca2013-10-31 16:23:26 +0100447igt_main
Daniel Vetterd9d95782012-12-04 17:13:05 +0100448{
Chris Wilson7e0853c2016-01-27 14:17:53 +0000449 const struct intel_execution_engine *e;
Chris Wilson2659cbb2015-03-26 12:09:57 +0000450 uint32_t handle = 0;
Chris Wilson3a7325e2016-03-08 11:43:31 +0000451 int device = -1;
Daniel Vetterd9d95782012-12-04 17:13:05 +0100452
Chris Wilson2659cbb2015-03-26 12:09:57 +0000453 igt_fixture {
Chris Wilson3a7325e2016-03-08 11:43:31 +0000454 const uint32_t bbe = MI_BATCH_BUFFER_END;
455
Micah Fedkec81d2932015-07-22 21:54:02 +0000456 device = drm_open_driver(DRIVER_INTEL);
Chris Wilson9518cb52017-02-22 15:24:54 +0000457 igt_require_gem(device);
Chris Wilsonc6e26e42016-07-22 12:58:54 +0100458 print_welcome(device);
459
Chris Wilson2659cbb2015-03-26 12:09:57 +0000460 handle = gem_create(device, 4096);
Chris Wilson3a7325e2016-03-08 11:43:31 +0000461 gem_write(device, handle, 0, &bbe, sizeof(bbe));
Daniel Vetterd9d95782012-12-04 17:13:05 +0100462
Daniel Vetterbe21fc02016-06-17 16:04:09 +0200463 igt_fork_hang_detector(device);
464 }
Chris Wilson9d61a682016-03-25 18:22:54 +0000465
Chris Wilson4cce7152016-09-08 13:43:17 +0100466 igt_subtest("basic-series")
Chris Wilson69b29f82016-10-18 10:23:49 +0100467 series(device, handle, 5);
Chris Wilson4cce7152016-09-08 13:43:17 +0100468
469 igt_subtest("basic-parallel")
Chris Wilson69b29f82016-10-18 10:23:49 +0100470 parallel(device, handle, 5);
Chris Wilson772393e2016-03-14 14:31:36 +0000471
Chris Wilson817d57f2017-01-20 17:17:42 +0000472 igt_subtest("basic-sequential")
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000473 sequential(device, handle, 0, 5);
Chris Wilson817d57f2017-01-20 17:17:42 +0000474
Chris Wilson7e0853c2016-01-27 14:17:53 +0000475 for (e = intel_execution_engines; e->name; e++)
476 igt_subtest_f("%s", e->name)
Chris Wilson3a7325e2016-03-08 11:43:31 +0000477 single(device, handle, e->exec_id | e->flags, e->name);
478
Chris Wilson4cce7152016-09-08 13:43:17 +0100479 igt_subtest("series")
480 series(device, handle, 150);
481
482 igt_subtest("parallel")
483 parallel(device, handle, 150);
Daniel Vetterd9d95782012-12-04 17:13:05 +0100484
Chris Wilson817d57f2017-01-20 17:17:42 +0000485 igt_subtest("sequential")
Chris Wilson9fbf72b2017-01-22 18:24:37 +0000486 sequential(device, handle, 0, 150);
487
488 igt_subtest("forked-sequential")
489 sequential(device, handle, FORKED, 150);
490
491 igt_subtest("chained-sequential")
492 sequential(device, handle, FORKED | CHAINED, 150);
493
494 igt_subtest("context-sequential")
495 sequential(device, handle, FORKED | CONTEXT, 150);
Chris Wilson817d57f2017-01-20 17:17:42 +0000496
Daniel Vetterb3880d32013-08-14 18:02:46 +0200497 igt_fixture {
Daniel Vetterbe21fc02016-06-17 16:04:09 +0200498 igt_stop_hang_detector();
Chris Wilson2659cbb2015-03-26 12:09:57 +0000499 gem_close(device, handle);
Chris Wilson2659cbb2015-03-26 12:09:57 +0000500 close(device);
Daniel Vetterb3880d32013-08-14 18:02:46 +0200501 }
Chris Wilson07d59b32011-01-20 22:10:10 +0000502}