Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2009,2012,2013 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 | * Eric Anholt <eric@anholt.net> |
| 25 | * Chris Wilson <chris@chris-wilson.co.uk> |
| 26 | * Daniel Vetter <daniel.vetter@ffwll.ch> |
| 27 | * |
| 28 | */ |
| 29 | |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 30 | /** @file gem_concurrent_blit.c |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 31 | * |
| 32 | * This is a test of pread/pwrite behavior when writing to active |
| 33 | * buffers. |
| 34 | * |
| 35 | * Based on gem_gtt_concurrent_blt. |
| 36 | */ |
| 37 | |
| 38 | #include <stdlib.h> |
| 39 | #include <stdio.h> |
| 40 | #include <string.h> |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 41 | #include <fcntl.h> |
| 42 | #include <inttypes.h> |
| 43 | #include <errno.h> |
| 44 | #include <sys/stat.h> |
| 45 | #include <sys/time.h> |
Chris Wilson | 99431a4 | 2013-08-14 11:03:34 +0100 | [diff] [blame] | 46 | #include <sys/wait.h> |
Daniel Vetter | f5daeec | 2014-03-23 13:35:09 +0100 | [diff] [blame] | 47 | |
| 48 | #include <drm.h> |
| 49 | |
Daniel Vetter | e49ceb8 | 2014-03-22 21:07:37 +0100 | [diff] [blame] | 50 | #include "ioctl_wrappers.h" |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 51 | #include "drmtest.h" |
| 52 | #include "intel_bufmgr.h" |
| 53 | #include "intel_batchbuffer.h" |
Daniel Vetter | c03c6ce | 2014-03-22 21:34:29 +0100 | [diff] [blame] | 54 | #include "intel_io.h" |
Daniel Vetter | e49ceb8 | 2014-03-22 21:07:37 +0100 | [diff] [blame] | 55 | #include "intel_chipset.h" |
Daniel Vetter | f5daeec | 2014-03-23 13:35:09 +0100 | [diff] [blame] | 56 | #include "igt_aux.h" |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 57 | |
| 58 | static void |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 59 | prw_set_bo(drm_intel_bo *bo, uint32_t val, int width, int height) |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 60 | { |
Chris Wilson | 0b4c33f | 2014-01-26 14:36:32 +0000 | [diff] [blame] | 61 | int size = width * height, i; |
| 62 | uint32_t *tmp; |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 63 | |
Chris Wilson | 0b4c33f | 2014-01-26 14:36:32 +0000 | [diff] [blame] | 64 | tmp = malloc(4*size); |
| 65 | if (tmp) { |
| 66 | for (i = 0; i < size; i++) |
| 67 | tmp[i] = val; |
| 68 | drm_intel_bo_subdata(bo, 0, 4*size, tmp); |
| 69 | free(tmp); |
| 70 | } else { |
| 71 | for (i = 0; i < size; i++) |
| 72 | drm_intel_bo_subdata(bo, 4*i, 4, &val); |
| 73 | } |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | static void |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 77 | prw_cmp_bo(drm_intel_bo *bo, uint32_t val, int width, int height) |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 78 | { |
Chris Wilson | 0b4c33f | 2014-01-26 14:36:32 +0000 | [diff] [blame] | 79 | int size = width * height, i; |
| 80 | uint32_t *tmp; |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 81 | |
Chris Wilson | 0b4c33f | 2014-01-26 14:36:32 +0000 | [diff] [blame] | 82 | tmp = malloc(4*size); |
| 83 | if (tmp) { |
| 84 | memset(tmp, 0, 4*size); |
| 85 | do_or_die(drm_intel_bo_get_subdata(bo, 0, 4*size, tmp)); |
| 86 | for (i = 0; i < size; i++) |
| 87 | igt_assert(tmp[i] == val); |
| 88 | free(tmp); |
| 89 | } else { |
| 90 | uint32_t t; |
| 91 | for (i = 0; i < size; i++) { |
| 92 | t = 0; |
| 93 | do_or_die(drm_intel_bo_get_subdata(bo, 4*i, 4, &t)); |
| 94 | igt_assert(t == val); |
| 95 | } |
| 96 | } |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | static drm_intel_bo * |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 100 | unmapped_create_bo(drm_intel_bufmgr *bufmgr, uint32_t val, int width, int height) |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 101 | { |
| 102 | drm_intel_bo *bo; |
| 103 | |
| 104 | bo = drm_intel_bo_alloc(bufmgr, "bo", 4*width*height, 0); |
Daniel Vetter | 8344095 | 2013-08-13 12:35:58 +0200 | [diff] [blame] | 105 | igt_assert(bo); |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 106 | |
| 107 | return bo; |
| 108 | } |
| 109 | |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 110 | static void |
| 111 | gtt_set_bo(drm_intel_bo *bo, uint32_t val, int width, int height) |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 112 | { |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 113 | int size = width * height; |
| 114 | uint32_t *vaddr; |
| 115 | |
| 116 | drm_intel_gem_bo_start_gtt_access(bo, true); |
| 117 | vaddr = bo->virtual; |
| 118 | while (size--) |
| 119 | *vaddr++ = val; |
| 120 | } |
| 121 | |
| 122 | static void |
| 123 | gtt_cmp_bo(drm_intel_bo *bo, uint32_t val, int width, int height) |
| 124 | { |
| 125 | int size = width * height; |
| 126 | uint32_t *vaddr; |
| 127 | |
| 128 | drm_intel_gem_bo_start_gtt_access(bo, false); |
| 129 | vaddr = bo->virtual; |
| 130 | while (size--) |
| 131 | igt_assert(*vaddr++ == val); |
| 132 | } |
| 133 | |
| 134 | static drm_intel_bo * |
| 135 | gtt_create_bo(drm_intel_bufmgr *bufmgr, uint32_t val, int width, int height) |
| 136 | { |
| 137 | drm_intel_bo *bo; |
| 138 | |
| 139 | bo = drm_intel_bo_alloc(bufmgr, "bo", 4*width*height, 0); |
| 140 | igt_assert(bo); |
| 141 | |
| 142 | /* gtt map doesn't have a write parameter, so just keep the mapping |
| 143 | * around (to avoid the set_domain with the gtt write domain set) and |
| 144 | * manually tell the kernel when we start access the gtt. */ |
| 145 | do_or_die(drm_intel_gem_bo_map_gtt(bo)); |
| 146 | |
| 147 | return bo; |
| 148 | } |
| 149 | |
| 150 | static void |
| 151 | cpu_set_bo(drm_intel_bo *bo, uint32_t val, int width, int height) |
| 152 | { |
| 153 | int size = width * height; |
| 154 | uint32_t *vaddr; |
| 155 | |
| 156 | do_or_die(drm_intel_bo_map(bo, true)); |
| 157 | vaddr = bo->virtual; |
| 158 | while (size--) |
| 159 | *vaddr++ = val; |
| 160 | drm_intel_bo_unmap(bo); |
| 161 | } |
| 162 | |
| 163 | static void |
| 164 | cpu_cmp_bo(drm_intel_bo *bo, uint32_t val, int width, int height) |
| 165 | { |
| 166 | int size = width * height; |
| 167 | uint32_t *vaddr; |
| 168 | |
| 169 | do_or_die(drm_intel_bo_map(bo, false)); |
| 170 | vaddr = bo->virtual; |
| 171 | while (size--) |
| 172 | igt_assert(*vaddr++ == val); |
| 173 | drm_intel_bo_unmap(bo); |
| 174 | } |
| 175 | |
| 176 | struct access_mode { |
| 177 | void (*set_bo)(drm_intel_bo *bo, uint32_t val, int w, int h); |
| 178 | void (*cmp_bo)(drm_intel_bo *bo, uint32_t val, int w, int h); |
| 179 | drm_intel_bo *(*create_bo)(drm_intel_bufmgr *bufmgr, |
| 180 | uint32_t val, int width, int height); |
| 181 | const char *name; |
| 182 | }; |
| 183 | |
| 184 | struct access_mode access_modes[] = { |
| 185 | { .set_bo = prw_set_bo, .cmp_bo = prw_cmp_bo, |
| 186 | .create_bo = unmapped_create_bo, .name = "prw" }, |
| 187 | { .set_bo = cpu_set_bo, .cmp_bo = cpu_cmp_bo, |
| 188 | .create_bo = unmapped_create_bo, .name = "cpu" }, |
| 189 | { .set_bo = gtt_set_bo, .cmp_bo = gtt_cmp_bo, |
| 190 | .create_bo = gtt_create_bo, .name = "gtt" }, |
| 191 | }; |
| 192 | |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 193 | #define MAX_NUM_BUFFERS 1024 |
| 194 | int num_buffers = MAX_NUM_BUFFERS, fd; |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 195 | drm_intel_bufmgr *bufmgr; |
| 196 | struct intel_batchbuffer *batch; |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 197 | int width = 512, height = 512; |
| 198 | |
| 199 | static void do_overwrite_source(struct access_mode *mode, |
| 200 | drm_intel_bo **src, drm_intel_bo **dst, |
| 201 | drm_intel_bo *dummy) |
| 202 | { |
| 203 | int i; |
| 204 | |
| 205 | gem_quiescent_gpu(fd); |
| 206 | for (i = 0; i < num_buffers; i++) { |
| 207 | mode->set_bo(src[i], i, width, height); |
| 208 | mode->set_bo(dst[i], i, width, height); |
| 209 | } |
| 210 | for (i = 0; i < num_buffers; i++) |
Daniel Vetter | eaccd44 | 2014-03-13 03:35:02 +0100 | [diff] [blame] | 211 | intel_copy_bo(batch, dst[i], src[i], width*height*4); |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 212 | for (i = num_buffers; i--; ) |
| 213 | mode->set_bo(src[i], 0xdeadbeef, width, height); |
| 214 | for (i = 0; i < num_buffers; i++) |
| 215 | mode->cmp_bo(dst[i], i, width, height); |
| 216 | } |
| 217 | |
| 218 | static void do_early_read(struct access_mode *mode, |
| 219 | drm_intel_bo **src, drm_intel_bo **dst, |
| 220 | drm_intel_bo *dummy) |
| 221 | { |
| 222 | int i; |
| 223 | |
| 224 | gem_quiescent_gpu(fd); |
| 225 | for (i = num_buffers; i--; ) |
| 226 | mode->set_bo(src[i], 0xdeadbeef, width, height); |
| 227 | for (i = 0; i < num_buffers; i++) |
Daniel Vetter | eaccd44 | 2014-03-13 03:35:02 +0100 | [diff] [blame] | 228 | intel_copy_bo(batch, dst[i], src[i], width*height*4); |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 229 | for (i = num_buffers; i--; ) |
| 230 | mode->cmp_bo(dst[i], 0xdeadbeef, width, height); |
| 231 | } |
| 232 | |
| 233 | static void do_gpu_read_after_write(struct access_mode *mode, |
| 234 | drm_intel_bo **src, drm_intel_bo **dst, |
| 235 | drm_intel_bo *dummy) |
| 236 | { |
| 237 | int i; |
| 238 | |
| 239 | gem_quiescent_gpu(fd); |
| 240 | for (i = num_buffers; i--; ) |
| 241 | mode->set_bo(src[i], 0xabcdabcd, width, height); |
| 242 | for (i = 0; i < num_buffers; i++) |
Daniel Vetter | eaccd44 | 2014-03-13 03:35:02 +0100 | [diff] [blame] | 243 | intel_copy_bo(batch, dst[i], src[i], width*height*4); |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 244 | for (i = num_buffers; i--; ) |
Daniel Vetter | eaccd44 | 2014-03-13 03:35:02 +0100 | [diff] [blame] | 245 | intel_copy_bo(batch, dummy, dst[i], width*height*4); |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 246 | for (i = num_buffers; i--; ) |
| 247 | mode->cmp_bo(dst[i], 0xabcdabcd, width, height); |
| 248 | } |
| 249 | |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 250 | typedef void (*do_test)(struct access_mode *mode, |
| 251 | drm_intel_bo **src, drm_intel_bo **dst, |
| 252 | drm_intel_bo *dummy); |
| 253 | |
| 254 | typedef void (*run_wrap)(struct access_mode *mode, |
| 255 | drm_intel_bo **src, drm_intel_bo **dst, |
| 256 | drm_intel_bo *dummy, |
| 257 | do_test do_test_func); |
| 258 | |
| 259 | static void run_single(struct access_mode *mode, |
| 260 | drm_intel_bo **src, drm_intel_bo **dst, |
| 261 | drm_intel_bo *dummy, |
| 262 | do_test do_test_func) |
| 263 | { |
| 264 | do_test_func(mode, src, dst, dummy); |
| 265 | } |
| 266 | |
| 267 | |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 268 | static void run_interruptible(struct access_mode *mode, |
| 269 | drm_intel_bo **src, drm_intel_bo **dst, |
| 270 | drm_intel_bo *dummy, |
| 271 | do_test do_test_func) |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 272 | { |
| 273 | int loop; |
| 274 | |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 275 | igt_fork_signal_helper(); |
| 276 | |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 277 | for (loop = 0; loop < 10; loop++) |
| 278 | do_test_func(mode, src, dst, dummy); |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 279 | |
| 280 | igt_stop_signal_helper(); |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | static void run_forked(struct access_mode *mode, |
| 284 | drm_intel_bo **src, drm_intel_bo **dst, |
| 285 | drm_intel_bo *dummy, |
| 286 | do_test do_test_func) |
| 287 | { |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 288 | const int old_num_buffers = num_buffers; |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 289 | |
Daniel Vetter | cd1f220 | 2013-08-29 10:06:51 +0200 | [diff] [blame] | 290 | num_buffers /= 16; |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 291 | num_buffers += 2; |
| 292 | |
| 293 | igt_fork_signal_helper(); |
| 294 | |
Daniel Vetter | cd1f220 | 2013-08-29 10:06:51 +0200 | [diff] [blame] | 295 | igt_fork(child, 16) { |
Daniel Vetter | cd1f220 | 2013-08-29 10:06:51 +0200 | [diff] [blame] | 296 | /* recreate process local variables */ |
| 297 | bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); |
| 298 | drm_intel_bufmgr_gem_enable_reuse(bufmgr); |
| 299 | batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); |
| 300 | for (int i = 0; i < num_buffers; i++) { |
| 301 | src[i] = mode->create_bo(bufmgr, i, width, height); |
| 302 | dst[i] = mode->create_bo(bufmgr, ~i, width, height); |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 303 | } |
Daniel Vetter | cd1f220 | 2013-08-29 10:06:51 +0200 | [diff] [blame] | 304 | dummy = mode->create_bo(bufmgr, 0, width, height); |
| 305 | for (int loop = 0; loop < 10; loop++) |
| 306 | do_test_func(mode, src, dst, dummy); |
| 307 | /* as we borrow the fd, we need to reap our bo */ |
| 308 | for (int i = 0; i < num_buffers; i++) { |
| 309 | drm_intel_bo_unreference(src[i]); |
| 310 | drm_intel_bo_unreference(dst[i]); |
| 311 | } |
| 312 | drm_intel_bo_unreference(dummy); |
| 313 | intel_batchbuffer_free(batch); |
| 314 | drm_intel_bufmgr_destroy(bufmgr); |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 315 | } |
Daniel Vetter | cd1f220 | 2013-08-29 10:06:51 +0200 | [diff] [blame] | 316 | |
| 317 | igt_waitchildren(); |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 318 | |
| 319 | igt_stop_signal_helper(); |
| 320 | |
| 321 | num_buffers = old_num_buffers; |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 322 | } |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 323 | |
| 324 | static void |
| 325 | run_basic_modes(struct access_mode *mode, |
| 326 | drm_intel_bo **src, drm_intel_bo **dst, |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 327 | drm_intel_bo *dummy, const char *suffix, |
| 328 | run_wrap run_wrap_func) |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 329 | { |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 330 | /* try to overwrite the source values */ |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 331 | igt_subtest_f("%s-overwrite-source%s", mode->name, suffix) |
| 332 | run_wrap_func(mode, src, dst, dummy, do_overwrite_source); |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 333 | |
| 334 | /* try to read the results before the copy completes */ |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 335 | igt_subtest_f("%s-early-read%s", mode->name, suffix) |
| 336 | run_wrap_func(mode, src, dst, dummy, do_early_read); |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 337 | |
| 338 | /* and finally try to trick the kernel into loosing the pending write */ |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 339 | igt_subtest_f("%s-gpu-read-after-write%s", mode->name, suffix) |
| 340 | run_wrap_func(mode, src, dst, dummy, do_gpu_read_after_write); |
Daniel Vetter | 5a598c9 | 2013-08-14 15:08:05 +0200 | [diff] [blame] | 341 | } |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 342 | |
| 343 | static void |
| 344 | run_modes(struct access_mode *mode) |
| 345 | { |
Daniel Vetter | ad0f081 | 2013-08-26 20:41:00 +0200 | [diff] [blame] | 346 | drm_intel_bo *src[MAX_NUM_BUFFERS], *dst[MAX_NUM_BUFFERS], *dummy = NULL; |
| 347 | |
Daniel Vetter | 2dbd998 | 2013-08-14 15:48:54 +0200 | [diff] [blame] | 348 | igt_fixture { |
Chris Wilson | 0d320fd | 2013-08-16 12:07:56 +0100 | [diff] [blame] | 349 | bufmgr = drm_intel_bufmgr_gem_init(fd, 4096); |
| 350 | drm_intel_bufmgr_gem_enable_reuse(bufmgr); |
| 351 | batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd)); |
| 352 | |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 353 | for (int i = 0; i < num_buffers; i++) { |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 354 | src[i] = mode->create_bo(bufmgr, i, width, height); |
| 355 | dst[i] = mode->create_bo(bufmgr, ~i, width, height); |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 356 | } |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 357 | dummy = mode->create_bo(bufmgr, 0, width, height); |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 358 | } |
| 359 | |
Daniel Vetter | ec283d6 | 2013-08-14 15:18:37 +0200 | [diff] [blame] | 360 | run_basic_modes(mode, src, dst, dummy, "", run_single); |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 361 | run_basic_modes(mode, src, dst, dummy, "-interruptible", run_interruptible); |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 362 | |
Daniel Vetter | 2dbd998 | 2013-08-14 15:48:54 +0200 | [diff] [blame] | 363 | igt_fixture { |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 364 | for (int i = 0; i < num_buffers; i++) { |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 365 | drm_intel_bo_unreference(src[i]); |
| 366 | drm_intel_bo_unreference(dst[i]); |
| 367 | } |
| 368 | drm_intel_bo_unreference(dummy); |
Chris Wilson | 0d320fd | 2013-08-16 12:07:56 +0100 | [diff] [blame] | 369 | intel_batchbuffer_free(batch); |
| 370 | drm_intel_bufmgr_destroy(bufmgr); |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 371 | } |
Chris Wilson | 1ca607b | 2013-08-16 09:44:13 +0100 | [diff] [blame] | 372 | |
| 373 | run_basic_modes(mode, src, dst, dummy, "-forked", run_forked); |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 374 | } |
| 375 | |
Daniel Vetter | 071e9ca | 2013-10-31 16:23:26 +0100 | [diff] [blame] | 376 | igt_main |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 377 | { |
| 378 | int max, i; |
| 379 | |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 380 | igt_skip_on_simulation(); |
| 381 | |
Daniel Vetter | 2dbd998 | 2013-08-14 15:48:54 +0200 | [diff] [blame] | 382 | igt_fixture { |
| 383 | fd = drm_open_any(); |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 384 | |
Daniel Vetter | 2dbd998 | 2013-08-14 15:48:54 +0200 | [diff] [blame] | 385 | max = gem_aperture_size (fd) / (1024 * 1024) / 2; |
| 386 | if (num_buffers > max) |
| 387 | num_buffers = max; |
Daniel Vetter | aee0dcb | 2013-12-03 16:32:52 +0100 | [diff] [blame] | 388 | |
| 389 | max = intel_get_total_ram_mb() * 3 / 4; |
| 390 | if (num_buffers > max) |
| 391 | num_buffers = max; |
Chris Wilson | 0b4c33f | 2014-01-26 14:36:32 +0000 | [diff] [blame] | 392 | num_buffers /= 2; |
Daniel Vetter | e624fa8 | 2014-05-14 00:36:04 +0200 | [diff] [blame^] | 393 | igt_info("using 2x%d buffers, each 1MiB\n", num_buffers); |
Daniel Vetter | 2dbd998 | 2013-08-14 15:48:54 +0200 | [diff] [blame] | 394 | } |
Daniel Vetter | 43779e3 | 2013-08-14 14:50:50 +0200 | [diff] [blame] | 395 | |
| 396 | for (i = 0; i < ARRAY_SIZE(access_modes); i++) |
| 397 | run_modes(&access_modes[i]); |
Daniel Vetter | 3dba47e | 2013-08-06 22:27:37 +0200 | [diff] [blame] | 398 | } |