Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 1 | /* |
| 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 Wood | 804e11f | 2015-08-17 17:57:43 +0100 | [diff] [blame] | 28 | #include "igt.h" |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 29 | #include "igt_rand.h" |
Chris Wilson | c6e26e4 | 2016-07-22 12:58:54 +0100 | [diff] [blame] | 30 | #include "igt_sysfs.h" |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 31 | |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 32 | #include <unistd.h> |
| 33 | #include <stdlib.h> |
| 34 | #include <stdint.h> |
| 35 | #include <stdio.h> |
| 36 | #include <string.h> |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 37 | #include <fcntl.h> |
| 38 | #include <inttypes.h> |
| 39 | #include <errno.h> |
| 40 | #include <sys/stat.h> |
| 41 | #include <sys/ioctl.h> |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 42 | #include <sys/poll.h> |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 43 | #include <sys/time.h> |
Chris Wilson | b430709 | 2015-07-01 13:53:07 +0100 | [diff] [blame] | 44 | #include <time.h> |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 45 | #include "drm.h" |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 46 | |
Chris Wilson | cf3e683 | 2017-09-28 18:24:26 +0100 | [diff] [blame] | 47 | #define BIT(x) (1ul << (x)) |
| 48 | |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 49 | #define LOCAL_I915_EXEC_NO_RELOC (1<<11) |
| 50 | #define LOCAL_I915_EXEC_HANDLE_LUT (1<<12) |
| 51 | |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 52 | #define LOCAL_I915_EXEC_BSD_SHIFT (13) |
| 53 | #define LOCAL_I915_EXEC_BSD_MASK (3 << LOCAL_I915_EXEC_BSD_SHIFT) |
Daniel Vetter | 51f0830 | 2012-12-05 19:29:11 +0100 | [diff] [blame] | 54 | |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 55 | #define ENGINE_FLAGS (I915_EXEC_RING_MASK | LOCAL_I915_EXEC_BSD_MASK) |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 56 | |
Chris Wilson | cf3e683 | 2017-09-28 18:24:26 +0100 | [diff] [blame] | 57 | #define LOCAL_PARAM_HAS_SCHEDULER 41 |
| 58 | #define HAS_SCHEDULER BIT(0) |
| 59 | #define HAS_PRIORITY BIT(1) |
| 60 | #define HAS_PREEMPTION BIT(2) |
| 61 | #define LOCAL_CONTEXT_PARAM_PRIORITY 6 |
| 62 | #define MAX_PRIO 1023 |
| 63 | #define MIN_PRIO -1023 |
| 64 | |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 65 | #define FORKED 1 |
| 66 | #define CHAINED 2 |
| 67 | #define CONTEXT 4 |
| 68 | |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 69 | static double elapsed(const struct timespec *start, const struct timespec *end) |
| 70 | { |
| 71 | return ((end->tv_sec - start->tv_sec) + |
| 72 | (end->tv_nsec - start->tv_nsec)*1e-9); |
| 73 | } |
| 74 | |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 75 | static double nop_on_ring(int fd, uint32_t handle, unsigned ring_id, |
| 76 | int timeout, unsigned long *out) |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 77 | { |
| 78 | struct drm_i915_gem_execbuffer2 execbuf; |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 79 | struct drm_i915_gem_exec_object2 obj; |
| 80 | struct timespec start, now; |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 81 | unsigned long count; |
Daniel Vetter | 8f5387e | 2013-08-13 13:20:58 +0200 | [diff] [blame] | 82 | |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 83 | memset(&obj, 0, sizeof(obj)); |
| 84 | obj.handle = handle; |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 85 | |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 86 | memset(&execbuf, 0, sizeof(execbuf)); |
Chris Wilson | 4de67b2 | 2017-01-02 11:05:21 +0000 | [diff] [blame] | 87 | execbuf.buffers_ptr = to_user_pointer(&obj); |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 88 | execbuf.buffer_count = 1; |
| 89 | execbuf.flags = ring_id; |
| 90 | execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; |
| 91 | execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; |
Chris Wilson | 3e2443f | 2016-03-10 11:50:53 +0000 | [diff] [blame] | 92 | if (__gem_execbuf(fd, &execbuf)) { |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 93 | execbuf.flags = ring_id; |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 94 | gem_execbuf(fd, &execbuf); |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 95 | } |
Chris Wilson | 71f4153 | 2016-04-22 16:55:29 +0100 | [diff] [blame] | 96 | intel_detect_and_clear_missed_interrupts(fd); |
Chris Wilson | cd8d380 | 2015-03-24 09:15:12 +0000 | [diff] [blame] | 97 | |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 98 | count = 0; |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 99 | clock_gettime(CLOCK_MONOTONIC, &start); |
| 100 | do { |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 101 | for (int loop = 0; loop < 1024; loop++) |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 102 | gem_execbuf(fd, &execbuf); |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 103 | |
| 104 | count += 1024; |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 105 | clock_gettime(CLOCK_MONOTONIC, &now); |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 106 | } while (elapsed(&start, &now) < timeout); |
Chris Wilson | 71f4153 | 2016-04-22 16:55:29 +0100 | [diff] [blame] | 107 | igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 108 | |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 109 | *out = count; |
| 110 | return elapsed(&start, &now); |
| 111 | } |
| 112 | |
| 113 | static void single(int fd, uint32_t handle, |
| 114 | unsigned ring_id, const char *ring_name) |
| 115 | { |
| 116 | double time; |
| 117 | unsigned long count; |
| 118 | |
| 119 | gem_require_ring(fd, ring_id); |
| 120 | |
| 121 | time = nop_on_ring(fd, handle, ring_id, 20, &count); |
| 122 | igt_info("%s: %'lu cycles: %.3fus\n", |
| 123 | ring_name, count, time*1e6 / count); |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 124 | } |
| 125 | |
Tvrtko Ursulin | 8e4cfb2 | 2017-04-13 14:11:05 +0100 | [diff] [blame] | 126 | static double |
| 127 | stable_nop_on_ring(int fd, uint32_t handle, unsigned int engine, |
| 128 | int timeout, int reps) |
| 129 | { |
| 130 | igt_stats_t s; |
| 131 | double n; |
| 132 | |
| 133 | igt_assert(reps >= 5); |
| 134 | |
| 135 | igt_stats_init_with_size(&s, reps); |
| 136 | s.is_float = true; |
| 137 | |
| 138 | while (reps--) { |
| 139 | unsigned long count; |
| 140 | double time; |
| 141 | |
| 142 | time = nop_on_ring(fd, handle, engine, timeout, &count); |
| 143 | igt_stats_push_float(&s, time / count); |
| 144 | } |
| 145 | |
| 146 | n = igt_stats_get_median(&s); |
| 147 | igt_stats_fini(&s); |
| 148 | |
| 149 | return n; |
| 150 | } |
| 151 | |
Arkadiusz Hiler | 21bfc9f | 2017-04-19 12:50:06 +0200 | [diff] [blame] | 152 | #if !defined(ANDROID) || ANDROID_HAS_CAIRO |
Tvrtko Ursulin | 8e4cfb2 | 2017-04-13 14:11:05 +0100 | [diff] [blame] | 153 | #define assert_within_epsilon(x, ref, tolerance) \ |
| 154 | igt_assert_f((x) <= (1.0 + tolerance) * ref && \ |
| 155 | (x) >= (1.0 - tolerance) * ref, \ |
| 156 | "'%s' != '%s' (%f not within %f%% tolerance of %f)\n",\ |
| 157 | #x, #ref, x, tolerance * 100.0, ref) |
| 158 | |
| 159 | static void headless(int fd, uint32_t handle) |
| 160 | { |
| 161 | unsigned int nr_connected = 0; |
| 162 | drmModeConnector *connector; |
| 163 | drmModeRes *res; |
| 164 | double n_display, n_headless; |
| 165 | |
| 166 | res = drmModeGetResources(fd); |
| 167 | igt_assert(res); |
| 168 | |
| 169 | /* require at least one connected connector for the test */ |
| 170 | for (int i = 0; i < res->count_connectors; i++) { |
| 171 | connector = drmModeGetConnectorCurrent(fd, res->connectors[i]); |
| 172 | if (connector->connection == DRM_MODE_CONNECTED) |
| 173 | nr_connected++; |
| 174 | drmModeFreeConnector(connector); |
| 175 | } |
| 176 | igt_require(nr_connected > 0); |
| 177 | |
| 178 | /* set graphics mode to prevent blanking */ |
| 179 | kmstest_set_vt_graphics_mode(); |
| 180 | |
| 181 | /* benchmark nops */ |
| 182 | n_display = stable_nop_on_ring(fd, handle, I915_EXEC_DEFAULT, 1, 5); |
Chris Wilson | f6a31ad | 2017-04-19 13:38:32 +0100 | [diff] [blame] | 183 | igt_info("With one display connected: %.2fus\n", |
| 184 | n_display * 1e6); |
Tvrtko Ursulin | 8e4cfb2 | 2017-04-13 14:11:05 +0100 | [diff] [blame] | 185 | |
| 186 | /* force all connectors off */ |
| 187 | kmstest_unset_all_crtcs(fd, res); |
| 188 | |
| 189 | /* benchmark nops again */ |
| 190 | n_headless = stable_nop_on_ring(fd, handle, I915_EXEC_DEFAULT, 1, 5); |
Chris Wilson | f6a31ad | 2017-04-19 13:38:32 +0100 | [diff] [blame] | 191 | igt_info("Without a display connected (headless): %.2fus\n", |
| 192 | n_headless * 1e6); |
Tvrtko Ursulin | 8e4cfb2 | 2017-04-13 14:11:05 +0100 | [diff] [blame] | 193 | |
| 194 | /* check that the two execution speeds are roughly the same */ |
| 195 | assert_within_epsilon(n_headless, n_display, 0.1f); |
| 196 | } |
Arkadiusz Hiler | 21bfc9f | 2017-04-19 12:50:06 +0200 | [diff] [blame] | 197 | #endif |
Tvrtko Ursulin | 8e4cfb2 | 2017-04-13 14:11:05 +0100 | [diff] [blame] | 198 | |
Chris Wilson | 0aacdac | 2016-03-09 21:06:16 +0000 | [diff] [blame] | 199 | static bool ignore_engine(int fd, unsigned engine) |
| 200 | { |
| 201 | if (engine == 0) |
| 202 | return true; |
| 203 | |
| 204 | if (gem_has_bsd2(fd) && engine == I915_EXEC_BSD) |
| 205 | return true; |
| 206 | |
| 207 | return false; |
| 208 | } |
| 209 | |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 210 | static void parallel(int fd, uint32_t handle, int timeout) |
| 211 | { |
| 212 | struct drm_i915_gem_execbuffer2 execbuf; |
| 213 | struct drm_i915_gem_exec_object2 obj; |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 214 | unsigned engines[16]; |
| 215 | const char *names[16]; |
| 216 | unsigned nengine; |
| 217 | unsigned engine; |
| 218 | unsigned long count; |
| 219 | double time, sum; |
| 220 | |
| 221 | sum = 0; |
| 222 | nengine = 0; |
| 223 | for_each_engine(fd, engine) { |
| 224 | if (ignore_engine(fd, engine)) |
| 225 | continue; |
| 226 | |
| 227 | engines[nengine] = engine; |
| 228 | names[nengine] = e__->name; |
| 229 | nengine++; |
| 230 | |
| 231 | time = nop_on_ring(fd, handle, engine, 1, &count) / count; |
| 232 | sum += time; |
| 233 | igt_debug("%s: %.3fus\n", e__->name, 1e6*time); |
| 234 | } |
| 235 | igt_require(nengine); |
| 236 | igt_info("average (individually): %.3fus\n", sum/nengine*1e6); |
| 237 | |
| 238 | memset(&obj, 0, sizeof(obj)); |
| 239 | obj.handle = handle; |
| 240 | |
| 241 | memset(&execbuf, 0, sizeof(execbuf)); |
Chris Wilson | 4de67b2 | 2017-01-02 11:05:21 +0000 | [diff] [blame] | 242 | execbuf.buffers_ptr = to_user_pointer(&obj); |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 243 | execbuf.buffer_count = 1; |
| 244 | execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; |
| 245 | execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; |
| 246 | if (__gem_execbuf(fd, &execbuf)) { |
| 247 | execbuf.flags = 0; |
| 248 | gem_execbuf(fd, &execbuf); |
| 249 | } |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 250 | intel_detect_and_clear_missed_interrupts(fd); |
| 251 | |
| 252 | igt_fork(child, nengine) { |
Chris Wilson | f565b6c | 2016-09-08 20:59:55 +0100 | [diff] [blame] | 253 | struct timespec start, now; |
| 254 | |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 255 | execbuf.flags &= ~ENGINE_FLAGS; |
| 256 | execbuf.flags |= engines[child]; |
| 257 | |
| 258 | count = 0; |
| 259 | clock_gettime(CLOCK_MONOTONIC, &start); |
| 260 | do { |
| 261 | for (int loop = 0; loop < 1024; loop++) |
| 262 | gem_execbuf(fd, &execbuf); |
| 263 | count += 1024; |
| 264 | clock_gettime(CLOCK_MONOTONIC, &now); |
| 265 | } while (elapsed(&start, &now) < timeout); |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 266 | time = elapsed(&start, &now) / count; |
| 267 | igt_info("%s: %ld cycles, %.3fus\n", names[child], count, 1e6*time); |
| 268 | } |
| 269 | |
| 270 | igt_waitchildren(); |
| 271 | igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); |
| 272 | |
| 273 | } |
| 274 | |
| 275 | static void series(int fd, uint32_t handle, int timeout) |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 276 | { |
| 277 | struct drm_i915_gem_execbuffer2 execbuf; |
| 278 | struct drm_i915_gem_exec_object2 obj; |
Chris Wilson | f565b6c | 2016-09-08 20:59:55 +0100 | [diff] [blame] | 279 | struct timespec start, now, sync; |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 280 | unsigned engines[16]; |
| 281 | unsigned nengine; |
| 282 | unsigned engine; |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 283 | unsigned long count; |
Chris Wilson | 41a26b5 | 2016-03-28 16:26:01 +0100 | [diff] [blame] | 284 | double time, max = 0, min = HUGE_VAL, sum = 0; |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 285 | const char *name; |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 286 | |
| 287 | nengine = 0; |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 288 | for_each_engine(fd, engine) { |
| 289 | if (ignore_engine(fd, engine)) |
| 290 | continue; |
| 291 | |
| 292 | time = nop_on_ring(fd, handle, engine, 1, &count) / count; |
| 293 | if (time > max) { |
| 294 | name = e__->name; |
| 295 | max = time; |
| 296 | } |
Chris Wilson | 41a26b5 | 2016-03-28 16:26:01 +0100 | [diff] [blame] | 297 | if (time < min) |
| 298 | min = time; |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 299 | sum += time; |
| 300 | engines[nengine++] = engine; |
| 301 | } |
Chris Wilson | 0aacdac | 2016-03-09 21:06:16 +0000 | [diff] [blame] | 302 | igt_require(nengine); |
Chris Wilson | f565b6c | 2016-09-08 20:59:55 +0100 | [diff] [blame] | 303 | igt_info("Maximum execution latency on %s, %.3fus, min %.3fus, total %.3fus per cycle, average %.3fus\n", |
| 304 | name, max*1e6, min*1e6, sum*1e6, sum/nengine*1e6); |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 305 | |
| 306 | memset(&obj, 0, sizeof(obj)); |
| 307 | obj.handle = handle; |
| 308 | |
| 309 | memset(&execbuf, 0, sizeof(execbuf)); |
Chris Wilson | 4de67b2 | 2017-01-02 11:05:21 +0000 | [diff] [blame] | 310 | execbuf.buffers_ptr = to_user_pointer(&obj); |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 311 | execbuf.buffer_count = 1; |
| 312 | execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; |
| 313 | execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; |
Chris Wilson | 3e2443f | 2016-03-10 11:50:53 +0000 | [diff] [blame] | 314 | if (__gem_execbuf(fd, &execbuf)) { |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 315 | execbuf.flags = 0; |
| 316 | gem_execbuf(fd, &execbuf); |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 317 | } |
Chris Wilson | 71f4153 | 2016-04-22 16:55:29 +0100 | [diff] [blame] | 318 | intel_detect_and_clear_missed_interrupts(fd); |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 319 | |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 320 | count = 0; |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 321 | clock_gettime(CLOCK_MONOTONIC, &start); |
| 322 | do { |
| 323 | for (int loop = 0; loop < 1024; loop++) { |
| 324 | for (int n = 0; n < nengine; n++) { |
| 325 | execbuf.flags &= ~ENGINE_FLAGS; |
| 326 | execbuf.flags |= engines[n]; |
| 327 | gem_execbuf(fd, &execbuf); |
| 328 | } |
| 329 | } |
| 330 | count += nengine * 1024; |
| 331 | clock_gettime(CLOCK_MONOTONIC, &now); |
Chris Wilson | 772393e | 2016-03-14 14:31:36 +0000 | [diff] [blame] | 332 | } while (elapsed(&start, &now) < timeout); /* Hang detection ~120s */ |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 333 | gem_sync(fd, handle); |
Chris Wilson | f565b6c | 2016-09-08 20:59:55 +0100 | [diff] [blame] | 334 | clock_gettime(CLOCK_MONOTONIC, &sync); |
| 335 | igt_debug("sync time: %.3fus\n", elapsed(&now, &sync)*1e6); |
Chris Wilson | 71f4153 | 2016-04-22 16:55:29 +0100 | [diff] [blame] | 336 | igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 337 | |
Chris Wilson | 870c774 | 2016-03-28 15:29:46 +0100 | [diff] [blame] | 338 | time = elapsed(&start, &now) / count; |
Chris Wilson | f565b6c | 2016-09-08 20:59:55 +0100 | [diff] [blame] | 339 | igt_info("All (%d engines): %'lu cycles, average %.3fus per cycle [expected %.3fus]\n", |
Chris Wilson | 61b19a4 | 2016-09-08 14:50:32 +0100 | [diff] [blame] | 340 | nengine, count, 1e6*time, 1e6*((max-min)/nengine+min)); |
Chris Wilson | 41a26b5 | 2016-03-28 16:26:01 +0100 | [diff] [blame] | 341 | |
Chris Wilson | a0eebbd | 2016-09-08 13:29:31 +0100 | [diff] [blame] | 342 | /* The rate limiting step should be how fast the slowest engine can |
| 343 | * execute its queue of requests, as when we wait upon a full ring all |
| 344 | * dispatch is frozen. So in general we cannot go faster than the |
| 345 | * slowest engine (but as all engines are in lockstep, they should all |
| 346 | * be executing in parallel and so the average should be max/nengines), |
| 347 | * but we should equally not go any slower. |
| 348 | * |
| 349 | * However, that depends upon being able to submit fast enough, and |
| 350 | * that in turns depends upon debugging turned off and no bottlenecks |
| 351 | * within the driver. We cannot assert that we hit ideal conditions |
| 352 | * across all engines, so we only look for an outrageous error |
| 353 | * condition. |
Chris Wilson | 41a26b5 | 2016-03-28 16:26:01 +0100 | [diff] [blame] | 354 | */ |
Chris Wilson | a0eebbd | 2016-09-08 13:29:31 +0100 | [diff] [blame] | 355 | igt_assert_f(time < 2*sum, |
| 356 | "Average time (%.3fus) exceeds expectation for parallel execution (min %.3fus, max %.3fus; limit set at %.3fus)\n", |
| 357 | 1e6*time, 1e6*min, 1e6*max, 1e6*sum*2); |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 358 | } |
Daniel Vetter | 8f5387e | 2013-08-13 13:20:58 +0200 | [diff] [blame] | 359 | |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 360 | static void xchg(void *array, unsigned i, unsigned j) |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 361 | { |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 362 | unsigned *u = array; |
| 363 | unsigned tmp = u[i]; |
| 364 | u[i] = u[j]; |
| 365 | u[j] = tmp; |
| 366 | } |
| 367 | |
| 368 | static int __gem_context_create(int fd, uint32_t *ctx_id) |
| 369 | { |
| 370 | struct drm_i915_gem_context_create arg; |
| 371 | int ret = 0; |
| 372 | |
| 373 | memset(&arg, 0, sizeof(arg)); |
| 374 | if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &arg)) |
| 375 | ret = -errno; |
| 376 | |
| 377 | *ctx_id = arg.ctx_id; |
| 378 | return ret; |
| 379 | } |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 380 | |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 381 | static void sequential(int fd, uint32_t handle, unsigned flags, int timeout) |
| 382 | { |
| 383 | const int ncpus = flags & FORKED ? sysconf(_SC_NPROCESSORS_ONLN) : 1; |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 384 | struct drm_i915_gem_execbuffer2 execbuf; |
| 385 | struct drm_i915_gem_exec_object2 obj[2]; |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 386 | unsigned engines[16]; |
| 387 | unsigned nengine; |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 388 | double *results; |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 389 | double time, sum; |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 390 | unsigned n; |
| 391 | |
| 392 | results = mmap(NULL, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); |
| 393 | igt_assert(results != MAP_FAILED); |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 394 | |
| 395 | nengine = 0; |
| 396 | sum = 0; |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 397 | for_each_engine(fd, n) { |
| 398 | unsigned long count; |
| 399 | |
| 400 | if (ignore_engine(fd, n)) |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 401 | continue; |
| 402 | |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 403 | time = nop_on_ring(fd, handle, n, 1, &count) / count; |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 404 | sum += time; |
| 405 | igt_debug("%s: %.3fus\n", e__->name, 1e6*time); |
| 406 | |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 407 | engines[nengine++] = n; |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 408 | } |
| 409 | igt_require(nengine); |
| 410 | igt_info("Total (individual) execution latency %.3fus per cycle\n", |
| 411 | 1e6*sum); |
| 412 | |
| 413 | memset(obj, 0, sizeof(obj)); |
| 414 | obj[0].handle = gem_create(fd, 4096); |
| 415 | obj[0].flags = EXEC_OBJECT_WRITE; |
| 416 | obj[1].handle = handle; |
| 417 | |
| 418 | memset(&execbuf, 0, sizeof(execbuf)); |
| 419 | execbuf.buffers_ptr = to_user_pointer(obj); |
| 420 | execbuf.buffer_count = 2; |
| 421 | execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; |
| 422 | execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; |
| 423 | igt_require(__gem_execbuf(fd, &execbuf) == 0); |
| 424 | |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 425 | if (flags & CONTEXT) { |
| 426 | uint32_t id; |
| 427 | |
| 428 | igt_require(__gem_context_create(fd, &id) == 0); |
| 429 | execbuf.rsvd1 = id; |
| 430 | } |
| 431 | |
| 432 | for (n = 0; n < nengine; n++) { |
| 433 | execbuf.flags &= ~ENGINE_FLAGS; |
| 434 | execbuf.flags |= engines[n]; |
| 435 | igt_require(__gem_execbuf(fd, &execbuf) == 0); |
| 436 | } |
| 437 | |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 438 | intel_detect_and_clear_missed_interrupts(fd); |
| 439 | |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 440 | igt_fork(child, ncpus) { |
| 441 | struct timespec start, now; |
| 442 | unsigned long count; |
| 443 | |
| 444 | obj[0].handle = gem_create(fd, 4096); |
| 445 | gem_execbuf(fd, &execbuf); |
| 446 | |
| 447 | if (flags & CONTEXT) |
| 448 | execbuf.rsvd1 = gem_context_create(fd); |
| 449 | |
| 450 | hars_petruska_f54_1_random_perturb(child); |
| 451 | |
| 452 | count = 0; |
| 453 | clock_gettime(CLOCK_MONOTONIC, &start); |
| 454 | do { |
| 455 | igt_permute_array(engines, nengine, xchg); |
| 456 | if (flags & CHAINED) { |
| 457 | for (n = 0; n < nengine; n++) { |
| 458 | execbuf.flags &= ~ENGINE_FLAGS; |
| 459 | execbuf.flags |= engines[n]; |
| 460 | for (int loop = 0; loop < 1024; loop++) |
| 461 | gem_execbuf(fd, &execbuf); |
| 462 | } |
| 463 | } else { |
| 464 | for (int loop = 0; loop < 1024; loop++) { |
| 465 | for (n = 0; n < nengine; n++) { |
| 466 | execbuf.flags &= ~ENGINE_FLAGS; |
| 467 | execbuf.flags |= engines[n]; |
| 468 | gem_execbuf(fd, &execbuf); |
| 469 | } |
| 470 | } |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 471 | } |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 472 | count += 1024; |
| 473 | clock_gettime(CLOCK_MONOTONIC, &now); |
| 474 | } while (elapsed(&start, &now) < timeout); /* Hang detection ~120s */ |
Chris Wilson | e7a0d06 | 2017-03-21 13:12:07 +0000 | [diff] [blame] | 475 | |
| 476 | gem_sync(fd, obj[0].handle); |
| 477 | clock_gettime(CLOCK_MONOTONIC, &now); |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 478 | results[child] = elapsed(&start, &now) / count; |
| 479 | |
| 480 | if (flags & CONTEXT) |
| 481 | gem_context_destroy(fd, execbuf.rsvd1); |
| 482 | |
| 483 | gem_close(fd, obj[0].handle); |
| 484 | } |
| 485 | igt_waitchildren(); |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 486 | igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); |
| 487 | |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 488 | results[ncpus] = 0; |
| 489 | for (n = 0; n < ncpus; n++) |
| 490 | results[ncpus] += results[n]; |
| 491 | results[ncpus] /= ncpus; |
| 492 | |
| 493 | igt_info("Sequential (%d engines, %d processes): average %.3fus per cycle [expected %.3fus]\n", |
| 494 | nengine, ncpus, 1e6*results[ncpus], 1e6*sum*ncpus); |
| 495 | |
| 496 | if (flags & CONTEXT) |
| 497 | gem_context_destroy(fd, execbuf.rsvd1); |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 498 | |
| 499 | gem_close(fd, obj[0].handle); |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 500 | munmap(results, 4096); |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 501 | } |
| 502 | |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 503 | #define LOCAL_EXEC_FENCE_OUT (1 << 17) |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 504 | static bool fence_enable_signaling(int fence) |
| 505 | { |
| 506 | return poll(&(struct pollfd){fence, POLLIN}, 1, 0) == 0; |
| 507 | } |
| 508 | |
| 509 | static bool fence_wait(int fence) |
| 510 | { |
| 511 | return poll(&(struct pollfd){fence, POLLIN}, 1, -1) == 1; |
| 512 | } |
| 513 | |
Arkadiusz Hiler | 0989478 | 2017-05-16 12:59:50 +0200 | [diff] [blame] | 514 | static void fence_signal(int fd, uint32_t handle, |
| 515 | unsigned ring_id, const char *ring_name, |
| 516 | int timeout) |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 517 | { |
| 518 | #define NFENCES 512 |
| 519 | struct drm_i915_gem_execbuffer2 execbuf; |
| 520 | struct drm_i915_gem_exec_object2 obj; |
| 521 | struct timespec start, now; |
| 522 | unsigned engines[16]; |
| 523 | unsigned nengine; |
| 524 | int *fences, n; |
| 525 | unsigned long count, signal; |
| 526 | |
| 527 | igt_require(gem_has_exec_fence(fd)); |
| 528 | |
| 529 | nengine = 0; |
| 530 | if (ring_id == -1) { |
| 531 | for_each_engine(fd, n) { |
| 532 | if (ignore_engine(fd, n)) |
| 533 | continue; |
| 534 | |
| 535 | engines[nengine++] = n; |
| 536 | } |
| 537 | } else { |
Chris Wilson | 842e6a4 | 2017-05-13 13:27:52 +0100 | [diff] [blame] | 538 | gem_require_ring(fd, ring_id); |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 539 | engines[nengine++] = ring_id; |
| 540 | } |
| 541 | igt_require(nengine); |
| 542 | |
| 543 | fences = malloc(sizeof(*fences) * NFENCES); |
| 544 | igt_assert(fences); |
| 545 | memset(fences, -1, sizeof(*fences) * NFENCES); |
| 546 | |
| 547 | memset(&obj, 0, sizeof(obj)); |
| 548 | obj.handle = handle; |
| 549 | |
| 550 | memset(&execbuf, 0, sizeof(execbuf)); |
| 551 | execbuf.buffers_ptr = to_user_pointer(&obj); |
| 552 | execbuf.buffer_count = 1; |
| 553 | execbuf.flags = LOCAL_EXEC_FENCE_OUT; |
| 554 | |
| 555 | n = 0; |
| 556 | count = 0; |
| 557 | signal = 0; |
| 558 | |
| 559 | intel_detect_and_clear_missed_interrupts(fd); |
| 560 | clock_gettime(CLOCK_MONOTONIC, &start); |
| 561 | do { |
| 562 | for (int loop = 0; loop < 1024; loop++) { |
| 563 | for (int e = 0; e < nengine; e++) { |
| 564 | if (fences[n] != -1) { |
| 565 | igt_assert(fence_wait(fences[n])); |
| 566 | close(fences[n]); |
| 567 | } |
| 568 | |
| 569 | execbuf.flags &= ~ENGINE_FLAGS; |
| 570 | execbuf.flags |= engines[e]; |
| 571 | gem_execbuf_wr(fd, &execbuf); |
| 572 | |
| 573 | /* Enable signaling by doing a poll() */ |
| 574 | fences[n] = execbuf.rsvd2 >> 32; |
| 575 | signal += fence_enable_signaling(fences[n]); |
| 576 | |
| 577 | n = (n + 1) % NFENCES; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | count += 1024 * nengine; |
| 582 | clock_gettime(CLOCK_MONOTONIC, &now); |
| 583 | } while (elapsed(&start, &now) < timeout); |
| 584 | igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); |
| 585 | |
| 586 | for (n = 0; n < NFENCES; n++) |
| 587 | if (fences[n] != -1) |
| 588 | close(fences[n]); |
| 589 | free(fences); |
| 590 | |
| 591 | igt_info("Signal %s: %'lu cycles (%'lu signals): %.3fus\n", |
| 592 | ring_name, count, signal, elapsed(&start, &now) * 1e6 / count); |
| 593 | } |
Chris Wilson | cf3e683 | 2017-09-28 18:24:26 +0100 | [diff] [blame] | 594 | static int __ctx_set_priority(int fd, uint32_t ctx, int prio) |
| 595 | { |
| 596 | struct local_i915_gem_context_param param; |
| 597 | |
| 598 | memset(¶m, 0, sizeof(param)); |
| 599 | param.context = ctx; |
| 600 | param.size = 0; |
| 601 | param.param = LOCAL_CONTEXT_PARAM_PRIORITY; |
| 602 | param.value = prio; |
| 603 | |
| 604 | return __gem_context_set_param(fd, ¶m); |
| 605 | } |
| 606 | |
| 607 | static void ctx_set_priority(int fd, uint32_t ctx, int prio) |
| 608 | { |
| 609 | igt_assert_eq(__ctx_set_priority(fd, ctx, prio), 0); |
| 610 | } |
| 611 | |
| 612 | static void preempt(int fd, uint32_t handle, |
| 613 | unsigned ring_id, const char *ring_name) |
| 614 | { |
| 615 | struct drm_i915_gem_execbuffer2 execbuf; |
| 616 | struct drm_i915_gem_exec_object2 obj; |
| 617 | struct timespec start, now; |
| 618 | unsigned long count; |
| 619 | uint32_t ctx[2]; |
| 620 | |
| 621 | gem_require_ring(fd, ring_id); |
| 622 | |
| 623 | ctx[0] = gem_context_create(fd); |
| 624 | ctx_set_priority(fd, ctx[0], MIN_PRIO); |
| 625 | |
| 626 | ctx[1] = gem_context_create(fd); |
| 627 | ctx_set_priority(fd, ctx[1], MAX_PRIO); |
| 628 | |
| 629 | memset(&obj, 0, sizeof(obj)); |
| 630 | obj.handle = handle; |
| 631 | |
| 632 | memset(&execbuf, 0, sizeof(execbuf)); |
| 633 | execbuf.buffers_ptr = to_user_pointer(&obj); |
| 634 | execbuf.buffer_count = 1; |
| 635 | execbuf.flags = ring_id; |
| 636 | execbuf.flags |= LOCAL_I915_EXEC_HANDLE_LUT; |
| 637 | execbuf.flags |= LOCAL_I915_EXEC_NO_RELOC; |
| 638 | if (__gem_execbuf(fd, &execbuf)) { |
| 639 | execbuf.flags = ring_id; |
| 640 | gem_execbuf(fd, &execbuf); |
| 641 | } |
| 642 | execbuf.rsvd1 = ctx[1]; |
| 643 | intel_detect_and_clear_missed_interrupts(fd); |
| 644 | |
| 645 | count = 0; |
| 646 | clock_gettime(CLOCK_MONOTONIC, &start); |
| 647 | do { |
| 648 | igt_spin_t *spin = |
| 649 | __igt_spin_batch_new(fd, ctx[0], ring_id, 0); |
| 650 | |
| 651 | for (int loop = 0; loop < 1024; loop++) |
| 652 | gem_execbuf(fd, &execbuf); |
| 653 | |
| 654 | igt_spin_batch_free(fd, spin); |
| 655 | |
| 656 | count += 1024; |
| 657 | clock_gettime(CLOCK_MONOTONIC, &now); |
| 658 | } while (elapsed(&start, &now) < 20); |
| 659 | igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0); |
| 660 | |
| 661 | gem_context_destroy(fd, ctx[1]); |
| 662 | gem_context_destroy(fd, ctx[0]); |
| 663 | |
| 664 | igt_info("%s: %'lu cycles: %.3fus\n", |
| 665 | ring_name, count, elapsed(&start, &now)*1e6 / count); |
| 666 | } |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 667 | |
Chris Wilson | c6e26e4 | 2016-07-22 12:58:54 +0100 | [diff] [blame] | 668 | static void print_welcome(int fd) |
| 669 | { |
| 670 | bool active; |
Chris Wilson | c6e26e4 | 2016-07-22 12:58:54 +0100 | [diff] [blame] | 671 | int dir; |
| 672 | |
| 673 | dir = igt_sysfs_open_parameters(fd); |
| 674 | if (dir < 0) |
| 675 | return; |
| 676 | |
Chris Wilson | b64d10c | 2016-07-22 17:53:51 +0100 | [diff] [blame] | 677 | active = igt_sysfs_get_boolean(dir, "enable_guc_submission"); |
Chris Wilson | c6e26e4 | 2016-07-22 12:58:54 +0100 | [diff] [blame] | 678 | if (active) { |
| 679 | igt_info("Using GuC submission\n"); |
| 680 | goto out; |
| 681 | } |
| 682 | |
Chris Wilson | b64d10c | 2016-07-22 17:53:51 +0100 | [diff] [blame] | 683 | active = igt_sysfs_get_boolean(dir, "enable_execlists"); |
Chris Wilson | c6e26e4 | 2016-07-22 12:58:54 +0100 | [diff] [blame] | 684 | if (active) { |
| 685 | igt_info("Using Execlists submission\n"); |
| 686 | goto out; |
| 687 | } |
| 688 | |
Chris Wilson | b64d10c | 2016-07-22 17:53:51 +0100 | [diff] [blame] | 689 | active = igt_sysfs_get_boolean(dir, "semaphores"); |
Chris Wilson | f565b6c | 2016-09-08 20:59:55 +0100 | [diff] [blame] | 690 | igt_info("Using Legacy submission%s\n", |
Chris Wilson | c6e26e4 | 2016-07-22 12:58:54 +0100 | [diff] [blame] | 691 | active ? ", with semaphores" : ""); |
| 692 | |
| 693 | out: |
| 694 | close(dir); |
| 695 | } |
| 696 | |
Chris Wilson | cf3e683 | 2017-09-28 18:24:26 +0100 | [diff] [blame] | 697 | static unsigned int has_scheduler(int fd) |
| 698 | { |
| 699 | drm_i915_getparam_t gp; |
| 700 | unsigned int caps = 0; |
| 701 | |
| 702 | gp.param = LOCAL_PARAM_HAS_SCHEDULER; |
| 703 | gp.value = (int *)∩︀ |
| 704 | drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); |
| 705 | |
| 706 | if (!caps) |
| 707 | return 0; |
| 708 | |
| 709 | igt_info("Has kernel scheduler\n"); |
| 710 | if (caps & HAS_PRIORITY) |
| 711 | igt_info(" - With priority sorting\n"); |
| 712 | if (caps & HAS_PREEMPTION) |
| 713 | igt_info(" - With preemption enabled\n"); |
| 714 | |
| 715 | return caps; |
| 716 | } |
| 717 | |
Daniel Vetter | 071e9ca | 2013-10-31 16:23:26 +0100 | [diff] [blame] | 718 | igt_main |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 719 | { |
Chris Wilson | 7e0853c | 2016-01-27 14:17:53 +0000 | [diff] [blame] | 720 | const struct intel_execution_engine *e; |
Chris Wilson | cf3e683 | 2017-09-28 18:24:26 +0100 | [diff] [blame] | 721 | unsigned int sched_caps = 0; |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 722 | uint32_t handle = 0; |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 723 | int device = -1; |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 724 | |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 725 | igt_fixture { |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 726 | const uint32_t bbe = MI_BATCH_BUFFER_END; |
| 727 | |
Micah Fedke | c81d293 | 2015-07-22 21:54:02 +0000 | [diff] [blame] | 728 | device = drm_open_driver(DRIVER_INTEL); |
Chris Wilson | 9518cb5 | 2017-02-22 15:24:54 +0000 | [diff] [blame] | 729 | igt_require_gem(device); |
Chris Wilson | c6e26e4 | 2016-07-22 12:58:54 +0100 | [diff] [blame] | 730 | print_welcome(device); |
Chris Wilson | cf3e683 | 2017-09-28 18:24:26 +0100 | [diff] [blame] | 731 | sched_caps = has_scheduler(device); |
Chris Wilson | c6e26e4 | 2016-07-22 12:58:54 +0100 | [diff] [blame] | 732 | |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 733 | handle = gem_create(device, 4096); |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 734 | gem_write(device, handle, 0, &bbe, sizeof(bbe)); |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 735 | |
Daniel Vetter | be21fc0 | 2016-06-17 16:04:09 +0200 | [diff] [blame] | 736 | igt_fork_hang_detector(device); |
| 737 | } |
Chris Wilson | 9d61a68 | 2016-03-25 18:22:54 +0000 | [diff] [blame] | 738 | |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 739 | igt_subtest("basic-series") |
Chris Wilson | 69b29f8 | 2016-10-18 10:23:49 +0100 | [diff] [blame] | 740 | series(device, handle, 5); |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 741 | |
| 742 | igt_subtest("basic-parallel") |
Chris Wilson | 69b29f8 | 2016-10-18 10:23:49 +0100 | [diff] [blame] | 743 | parallel(device, handle, 5); |
Chris Wilson | 772393e | 2016-03-14 14:31:36 +0000 | [diff] [blame] | 744 | |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 745 | igt_subtest("basic-sequential") |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 746 | sequential(device, handle, 0, 5); |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 747 | |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 748 | for (e = intel_execution_engines; e->name; e++) { |
Chris Wilson | 7e0853c | 2016-01-27 14:17:53 +0000 | [diff] [blame] | 749 | igt_subtest_f("%s", e->name) |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 750 | single(device, handle, e->exec_id | e->flags, e->name); |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 751 | igt_subtest_f("signal-%s", e->name) |
Arkadiusz Hiler | 0989478 | 2017-05-16 12:59:50 +0200 | [diff] [blame] | 752 | fence_signal(device, handle, e->exec_id | e->flags, e->name, 5); |
Chris Wilson | e10c48d | 2017-05-12 12:33:32 +0100 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | igt_subtest("signal-all") |
Arkadiusz Hiler | 0989478 | 2017-05-16 12:59:50 +0200 | [diff] [blame] | 756 | fence_signal(device, handle, -1, "all", 150); |
Chris Wilson | 3a7325e | 2016-03-08 11:43:31 +0000 | [diff] [blame] | 757 | |
Chris Wilson | 4cce715 | 2016-09-08 13:43:17 +0100 | [diff] [blame] | 758 | igt_subtest("series") |
| 759 | series(device, handle, 150); |
| 760 | |
| 761 | igt_subtest("parallel") |
| 762 | parallel(device, handle, 150); |
Daniel Vetter | d9d9578 | 2012-12-04 17:13:05 +0100 | [diff] [blame] | 763 | |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 764 | igt_subtest("sequential") |
Chris Wilson | 9fbf72b | 2017-01-22 18:24:37 +0000 | [diff] [blame] | 765 | sequential(device, handle, 0, 150); |
| 766 | |
| 767 | igt_subtest("forked-sequential") |
| 768 | sequential(device, handle, FORKED, 150); |
| 769 | |
| 770 | igt_subtest("chained-sequential") |
| 771 | sequential(device, handle, FORKED | CHAINED, 150); |
| 772 | |
| 773 | igt_subtest("context-sequential") |
| 774 | sequential(device, handle, FORKED | CONTEXT, 150); |
Chris Wilson | 817d57f | 2017-01-20 17:17:42 +0000 | [diff] [blame] | 775 | |
Chris Wilson | cf3e683 | 2017-09-28 18:24:26 +0100 | [diff] [blame] | 776 | igt_subtest_group { |
| 777 | igt_fixture { |
| 778 | igt_require(sched_caps & HAS_PRIORITY); |
| 779 | igt_require(sched_caps & HAS_PREEMPTION); |
| 780 | } |
| 781 | |
| 782 | for (e = intel_execution_engines; e->name; e++) { |
| 783 | igt_subtest_f("preempt-%s", e->name) |
| 784 | preempt(device, handle, e->exec_id | e->flags, e->name); |
| 785 | } |
| 786 | } |
| 787 | |
Arkadiusz Hiler | 21bfc9f | 2017-04-19 12:50:06 +0200 | [diff] [blame] | 788 | #if !defined(ANDROID) || ANDROID_HAS_CAIRO |
Tvrtko Ursulin | 8e4cfb2 | 2017-04-13 14:11:05 +0100 | [diff] [blame] | 789 | igt_subtest("headless") |
| 790 | headless(device, handle); |
Arkadiusz Hiler | 21bfc9f | 2017-04-19 12:50:06 +0200 | [diff] [blame] | 791 | #endif |
Tvrtko Ursulin | 8e4cfb2 | 2017-04-13 14:11:05 +0100 | [diff] [blame] | 792 | |
Daniel Vetter | b3880d3 | 2013-08-14 18:02:46 +0200 | [diff] [blame] | 793 | igt_fixture { |
Daniel Vetter | be21fc0 | 2016-06-17 16:04:09 +0200 | [diff] [blame] | 794 | igt_stop_hang_detector(); |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 795 | gem_close(device, handle); |
Chris Wilson | 2659cbb | 2015-03-26 12:09:57 +0000 | [diff] [blame] | 796 | close(device); |
Daniel Vetter | b3880d3 | 2013-08-14 18:02:46 +0200 | [diff] [blame] | 797 | } |
Chris Wilson | 07d59b3 | 2011-01-20 22:10:10 +0000 | [diff] [blame] | 798 | } |