blob: 88e379d20fe9fe67300f5d1dac6b7858af6b5eb7 [file] [log] [blame]
Daniel Vetter3dba47e2013-08-06 22:27:37 +02001/*
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 Vetter43779e32013-08-14 14:50:50 +020030/** @file gem_concurrent_blit.c
Daniel Vetter3dba47e2013-08-06 22:27:37 +020031 *
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 Vetter3dba47e2013-08-06 22:27:37 +020041#include <fcntl.h>
42#include <inttypes.h>
43#include <errno.h>
44#include <sys/stat.h>
45#include <sys/time.h>
Chris Wilson99431a42013-08-14 11:03:34 +010046#include <sys/wait.h>
Daniel Vetterf5daeec2014-03-23 13:35:09 +010047
48#include <drm.h>
49
Daniel Vettere49ceb82014-03-22 21:07:37 +010050#include "ioctl_wrappers.h"
Daniel Vetter3dba47e2013-08-06 22:27:37 +020051#include "drmtest.h"
52#include "intel_bufmgr.h"
53#include "intel_batchbuffer.h"
Daniel Vetterc03c6ce2014-03-22 21:34:29 +010054#include "intel_io.h"
Daniel Vettere49ceb82014-03-22 21:07:37 +010055#include "intel_chipset.h"
Daniel Vetterf5daeec2014-03-23 13:35:09 +010056#include "igt_aux.h"
Daniel Vetter3dba47e2013-08-06 22:27:37 +020057
Chris Wilson6c428a62014-08-29 13:11:37 +010058int fd, devid, gen;
59struct intel_batchbuffer *batch;
60
Daniel Vetter3dba47e2013-08-06 22:27:37 +020061static void
Daniel Vetter43779e32013-08-14 14:50:50 +020062prw_set_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
Daniel Vetter3dba47e2013-08-06 22:27:37 +020063{
Chris Wilson0b4c33f2014-01-26 14:36:32 +000064 int size = width * height, i;
65 uint32_t *tmp;
Daniel Vetter3dba47e2013-08-06 22:27:37 +020066
Chris Wilson0b4c33f2014-01-26 14:36:32 +000067 tmp = malloc(4*size);
68 if (tmp) {
69 for (i = 0; i < size; i++)
70 tmp[i] = val;
71 drm_intel_bo_subdata(bo, 0, 4*size, tmp);
72 free(tmp);
73 } else {
74 for (i = 0; i < size; i++)
75 drm_intel_bo_subdata(bo, 4*i, 4, &val);
76 }
Daniel Vetter3dba47e2013-08-06 22:27:37 +020077}
78
79static void
Daniel Vetter43779e32013-08-14 14:50:50 +020080prw_cmp_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
Daniel Vetter3dba47e2013-08-06 22:27:37 +020081{
Chris Wilson0b4c33f2014-01-26 14:36:32 +000082 int size = width * height, i;
83 uint32_t *tmp;
Daniel Vetter3dba47e2013-08-06 22:27:37 +020084
Chris Wilson0b4c33f2014-01-26 14:36:32 +000085 tmp = malloc(4*size);
86 if (tmp) {
87 memset(tmp, 0, 4*size);
88 do_or_die(drm_intel_bo_get_subdata(bo, 0, 4*size, tmp));
89 for (i = 0; i < size; i++)
Chris Wilson6c428a62014-08-29 13:11:37 +010090 igt_assert_eq_u32(tmp[i], val);
Chris Wilson0b4c33f2014-01-26 14:36:32 +000091 free(tmp);
92 } else {
93 uint32_t t;
94 for (i = 0; i < size; i++) {
95 t = 0;
96 do_or_die(drm_intel_bo_get_subdata(bo, 4*i, 4, &t));
Chris Wilson6c428a62014-08-29 13:11:37 +010097 igt_assert_eq_u32(t, val);
Chris Wilson0b4c33f2014-01-26 14:36:32 +000098 }
99 }
Daniel Vetter3dba47e2013-08-06 22:27:37 +0200100}
101
102static drm_intel_bo *
Daniel Vetter43779e32013-08-14 14:50:50 +0200103unmapped_create_bo(drm_intel_bufmgr *bufmgr, uint32_t val, int width, int height)
Daniel Vetter3dba47e2013-08-06 22:27:37 +0200104{
105 drm_intel_bo *bo;
106
107 bo = drm_intel_bo_alloc(bufmgr, "bo", 4*width*height, 0);
Daniel Vetter83440952013-08-13 12:35:58 +0200108 igt_assert(bo);
Daniel Vetter3dba47e2013-08-06 22:27:37 +0200109
110 return bo;
111}
112
Daniel Vetter43779e32013-08-14 14:50:50 +0200113static void
114gtt_set_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
Daniel Vetter3dba47e2013-08-06 22:27:37 +0200115{
Daniel Vetter43779e32013-08-14 14:50:50 +0200116 int size = width * height;
117 uint32_t *vaddr;
118
119 drm_intel_gem_bo_start_gtt_access(bo, true);
120 vaddr = bo->virtual;
121 while (size--)
122 *vaddr++ = val;
123}
124
125static void
126gtt_cmp_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
127{
128 int size = width * height;
129 uint32_t *vaddr;
130
131 drm_intel_gem_bo_start_gtt_access(bo, false);
132 vaddr = bo->virtual;
133 while (size--)
Chris Wilson6c428a62014-08-29 13:11:37 +0100134 igt_assert_eq_u32(*vaddr++, val);
Daniel Vetter43779e32013-08-14 14:50:50 +0200135}
136
137static drm_intel_bo *
138gtt_create_bo(drm_intel_bufmgr *bufmgr, uint32_t val, int width, int height)
139{
140 drm_intel_bo *bo;
141
142 bo = drm_intel_bo_alloc(bufmgr, "bo", 4*width*height, 0);
143 igt_assert(bo);
144
145 /* gtt map doesn't have a write parameter, so just keep the mapping
146 * around (to avoid the set_domain with the gtt write domain set) and
147 * manually tell the kernel when we start access the gtt. */
148 do_or_die(drm_intel_gem_bo_map_gtt(bo));
149
150 return bo;
151}
152
153static void
154cpu_set_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
155{
156 int size = width * height;
157 uint32_t *vaddr;
158
159 do_or_die(drm_intel_bo_map(bo, true));
160 vaddr = bo->virtual;
161 while (size--)
162 *vaddr++ = val;
163 drm_intel_bo_unmap(bo);
164}
165
166static void
167cpu_cmp_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
168{
169 int size = width * height;
170 uint32_t *vaddr;
171
172 do_or_die(drm_intel_bo_map(bo, false));
173 vaddr = bo->virtual;
174 while (size--)
Chris Wilson6c428a62014-08-29 13:11:37 +0100175 igt_assert_eq_u32(*vaddr++, val);
Daniel Vetter43779e32013-08-14 14:50:50 +0200176 drm_intel_bo_unmap(bo);
177}
178
Chris Wilson6c428a62014-08-29 13:11:37 +0100179static void
180gpu_set_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
181{
182 struct drm_i915_gem_relocation_entry reloc[1];
183 struct drm_i915_gem_exec_object2 gem_exec[2];
184 struct drm_i915_gem_execbuffer2 execbuf;
185 struct drm_i915_gem_pwrite gem_pwrite;
186 struct drm_i915_gem_create create;
187 uint32_t buf[10], *b;
188
189 memset(reloc, 0, sizeof(reloc));
190 memset(gem_exec, 0, sizeof(gem_exec));
191 memset(&execbuf, 0, sizeof(execbuf));
192
193 b = buf;
194 *b++ = XY_COLOR_BLT_CMD_NOLEN |
195 ((gen >= 8) ? 5 : 4) |
196 COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB;
197 *b++ = 0xf0 << 16 | 1 << 25 | 1 << 24 | width << 2;
198 *b++ = 0;
199 *b++ = height << 16 | width;
200 reloc[0].offset = (b - buf) * sizeof(uint32_t);
201 reloc[0].target_handle = bo->handle;
202 reloc[0].read_domains = I915_GEM_DOMAIN_RENDER;
203 reloc[0].write_domain = I915_GEM_DOMAIN_RENDER;
204 *b++ = 0;
205 if (gen >= 8)
206 *b++ = 0;
207 *b++ = val;
208 *b++ = MI_BATCH_BUFFER_END;
209 if ((b - buf) & 1)
210 *b++ = 0;
211
212 gem_exec[0].handle = bo->handle;
213 gem_exec[0].flags = EXEC_OBJECT_NEEDS_FENCE;
214
215 create.handle = 0;
216 create.size = 4096;
217 drmIoctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create);
218 gem_exec[1].handle = create.handle;
219 gem_exec[1].relocation_count = 1;
220 gem_exec[1].relocs_ptr = (uintptr_t)reloc;
221
222 execbuf.buffers_ptr = (uintptr_t)gem_exec;
223 execbuf.buffer_count = 2;
224 execbuf.batch_len = (b - buf) * sizeof(buf[0]);
225 execbuf.flags = 1 << 11;
226 if (HAS_BLT_RING(devid))
227 execbuf.flags |= I915_EXEC_BLT;
228
229 gem_pwrite.handle = gem_exec[1].handle;
230 gem_pwrite.offset = 0;
231 gem_pwrite.size = execbuf.batch_len;
232 gem_pwrite.data_ptr = (uintptr_t)buf;
233 if (drmIoctl(fd, DRM_IOCTL_I915_GEM_PWRITE, &gem_pwrite) == 0)
234 drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
235
236 drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &create.handle);
237}
238
239static void
240gpu_cmp_bo(drm_intel_bo *bo, uint32_t val, int width, int height)
241{
242 dri_bo *tmp = drm_intel_bo_alloc(bo->bufmgr, "tmp", 4*width*height, 0);
243 intel_copy_bo(batch, tmp, bo, width*height*4);
244 cpu_cmp_bo(tmp, val, width, height);
245 drm_intel_bo_unreference(tmp);
246}
247
Daniel Vetter43779e32013-08-14 14:50:50 +0200248struct access_mode {
249 void (*set_bo)(drm_intel_bo *bo, uint32_t val, int w, int h);
250 void (*cmp_bo)(drm_intel_bo *bo, uint32_t val, int w, int h);
251 drm_intel_bo *(*create_bo)(drm_intel_bufmgr *bufmgr,
252 uint32_t val, int width, int height);
253 const char *name;
254};
255
256struct access_mode access_modes[] = {
257 { .set_bo = prw_set_bo, .cmp_bo = prw_cmp_bo,
258 .create_bo = unmapped_create_bo, .name = "prw" },
259 { .set_bo = cpu_set_bo, .cmp_bo = cpu_cmp_bo,
260 .create_bo = unmapped_create_bo, .name = "cpu" },
261 { .set_bo = gtt_set_bo, .cmp_bo = gtt_cmp_bo,
262 .create_bo = gtt_create_bo, .name = "gtt" },
Chris Wilson6c428a62014-08-29 13:11:37 +0100263 { .set_bo = gpu_set_bo, .cmp_bo = gpu_cmp_bo,
264 .create_bo = unmapped_create_bo, .name = "gpu" },
Daniel Vetter43779e32013-08-14 14:50:50 +0200265};
266
Chris Wilson1ca607b2013-08-16 09:44:13 +0100267#define MAX_NUM_BUFFERS 1024
Chris Wilson6c428a62014-08-29 13:11:37 +0100268int num_buffers = MAX_NUM_BUFFERS;
Daniel Vetter43779e32013-08-14 14:50:50 +0200269drm_intel_bufmgr *bufmgr;
Daniel Vetter5a598c92013-08-14 15:08:05 +0200270int width = 512, height = 512;
271
272static void do_overwrite_source(struct access_mode *mode,
273 drm_intel_bo **src, drm_intel_bo **dst,
274 drm_intel_bo *dummy)
275{
276 int i;
277
278 gem_quiescent_gpu(fd);
279 for (i = 0; i < num_buffers; i++) {
280 mode->set_bo(src[i], i, width, height);
281 mode->set_bo(dst[i], i, width, height);
282 }
283 for (i = 0; i < num_buffers; i++)
Daniel Vettereaccd442014-03-13 03:35:02 +0100284 intel_copy_bo(batch, dst[i], src[i], width*height*4);
Daniel Vetter5a598c92013-08-14 15:08:05 +0200285 for (i = num_buffers; i--; )
286 mode->set_bo(src[i], 0xdeadbeef, width, height);
287 for (i = 0; i < num_buffers; i++)
288 mode->cmp_bo(dst[i], i, width, height);
289}
290
291static void do_early_read(struct access_mode *mode,
292 drm_intel_bo **src, drm_intel_bo **dst,
293 drm_intel_bo *dummy)
294{
295 int i;
296
297 gem_quiescent_gpu(fd);
298 for (i = num_buffers; i--; )
299 mode->set_bo(src[i], 0xdeadbeef, width, height);
300 for (i = 0; i < num_buffers; i++)
Daniel Vettereaccd442014-03-13 03:35:02 +0100301 intel_copy_bo(batch, dst[i], src[i], width*height*4);
Daniel Vetter5a598c92013-08-14 15:08:05 +0200302 for (i = num_buffers; i--; )
303 mode->cmp_bo(dst[i], 0xdeadbeef, width, height);
304}
305
306static void do_gpu_read_after_write(struct access_mode *mode,
307 drm_intel_bo **src, drm_intel_bo **dst,
308 drm_intel_bo *dummy)
309{
310 int i;
311
312 gem_quiescent_gpu(fd);
313 for (i = num_buffers; i--; )
314 mode->set_bo(src[i], 0xabcdabcd, width, height);
315 for (i = 0; i < num_buffers; i++)
Daniel Vettereaccd442014-03-13 03:35:02 +0100316 intel_copy_bo(batch, dst[i], src[i], width*height*4);
Daniel Vetter5a598c92013-08-14 15:08:05 +0200317 for (i = num_buffers; i--; )
Daniel Vettereaccd442014-03-13 03:35:02 +0100318 intel_copy_bo(batch, dummy, dst[i], width*height*4);
Daniel Vetter5a598c92013-08-14 15:08:05 +0200319 for (i = num_buffers; i--; )
320 mode->cmp_bo(dst[i], 0xabcdabcd, width, height);
321}
322
Daniel Vetterec283d62013-08-14 15:18:37 +0200323typedef void (*do_test)(struct access_mode *mode,
324 drm_intel_bo **src, drm_intel_bo **dst,
325 drm_intel_bo *dummy);
326
327typedef void (*run_wrap)(struct access_mode *mode,
328 drm_intel_bo **src, drm_intel_bo **dst,
329 drm_intel_bo *dummy,
330 do_test do_test_func);
331
332static void run_single(struct access_mode *mode,
333 drm_intel_bo **src, drm_intel_bo **dst,
334 drm_intel_bo *dummy,
335 do_test do_test_func)
336{
337 do_test_func(mode, src, dst, dummy);
338}
339
340
Chris Wilson1ca607b2013-08-16 09:44:13 +0100341static void run_interruptible(struct access_mode *mode,
342 drm_intel_bo **src, drm_intel_bo **dst,
343 drm_intel_bo *dummy,
344 do_test do_test_func)
Daniel Vetterec283d62013-08-14 15:18:37 +0200345{
346 int loop;
347
348 for (loop = 0; loop < 10; loop++)
349 do_test_func(mode, src, dst, dummy);
350}
351
352static void run_forked(struct access_mode *mode,
353 drm_intel_bo **src, drm_intel_bo **dst,
354 drm_intel_bo *dummy,
355 do_test do_test_func)
356{
Chris Wilson1ca607b2013-08-16 09:44:13 +0100357 const int old_num_buffers = num_buffers;
Daniel Vetterec283d62013-08-14 15:18:37 +0200358
Daniel Vettercd1f2202013-08-29 10:06:51 +0200359 num_buffers /= 16;
Chris Wilson1ca607b2013-08-16 09:44:13 +0100360 num_buffers += 2;
361
Daniel Vettercd1f2202013-08-29 10:06:51 +0200362 igt_fork(child, 16) {
Daniel Vettercd1f2202013-08-29 10:06:51 +0200363 /* recreate process local variables */
364 bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
365 drm_intel_bufmgr_gem_enable_reuse(bufmgr);
366 batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
367 for (int i = 0; i < num_buffers; i++) {
368 src[i] = mode->create_bo(bufmgr, i, width, height);
369 dst[i] = mode->create_bo(bufmgr, ~i, width, height);
Daniel Vetterec283d62013-08-14 15:18:37 +0200370 }
Daniel Vettercd1f2202013-08-29 10:06:51 +0200371 dummy = mode->create_bo(bufmgr, 0, width, height);
372 for (int loop = 0; loop < 10; loop++)
373 do_test_func(mode, src, dst, dummy);
374 /* as we borrow the fd, we need to reap our bo */
375 for (int i = 0; i < num_buffers; i++) {
376 drm_intel_bo_unreference(src[i]);
377 drm_intel_bo_unreference(dst[i]);
378 }
379 drm_intel_bo_unreference(dummy);
380 intel_batchbuffer_free(batch);
381 drm_intel_bufmgr_destroy(bufmgr);
Daniel Vetterec283d62013-08-14 15:18:37 +0200382 }
Daniel Vettercd1f2202013-08-29 10:06:51 +0200383
384 igt_waitchildren();
Chris Wilson1ca607b2013-08-16 09:44:13 +0100385
Chris Wilson1ca607b2013-08-16 09:44:13 +0100386 num_buffers = old_num_buffers;
Daniel Vetterec283d62013-08-14 15:18:37 +0200387}
Daniel Vetter5a598c92013-08-14 15:08:05 +0200388
389static void
390run_basic_modes(struct access_mode *mode,
391 drm_intel_bo **src, drm_intel_bo **dst,
Daniel Vetterec283d62013-08-14 15:18:37 +0200392 drm_intel_bo *dummy, const char *suffix,
393 run_wrap run_wrap_func)
Daniel Vetter5a598c92013-08-14 15:08:05 +0200394{
Daniel Vetter5a598c92013-08-14 15:08:05 +0200395 /* try to overwrite the source values */
Daniel Vetterec283d62013-08-14 15:18:37 +0200396 igt_subtest_f("%s-overwrite-source%s", mode->name, suffix)
397 run_wrap_func(mode, src, dst, dummy, do_overwrite_source);
Daniel Vetter5a598c92013-08-14 15:08:05 +0200398
399 /* try to read the results before the copy completes */
Daniel Vetterec283d62013-08-14 15:18:37 +0200400 igt_subtest_f("%s-early-read%s", mode->name, suffix)
401 run_wrap_func(mode, src, dst, dummy, do_early_read);
Daniel Vetter5a598c92013-08-14 15:08:05 +0200402
403 /* and finally try to trick the kernel into loosing the pending write */
Daniel Vetterec283d62013-08-14 15:18:37 +0200404 igt_subtest_f("%s-gpu-read-after-write%s", mode->name, suffix)
405 run_wrap_func(mode, src, dst, dummy, do_gpu_read_after_write);
Daniel Vetter5a598c92013-08-14 15:08:05 +0200406}
Daniel Vetter43779e32013-08-14 14:50:50 +0200407
408static void
409run_modes(struct access_mode *mode)
410{
Daniel Vetterad0f0812013-08-26 20:41:00 +0200411 drm_intel_bo *src[MAX_NUM_BUFFERS], *dst[MAX_NUM_BUFFERS], *dummy = NULL;
412
Daniel Vetter2dbd9982013-08-14 15:48:54 +0200413 igt_fixture {
Chris Wilson0d320fd2013-08-16 12:07:56 +0100414 bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
415 drm_intel_bufmgr_gem_enable_reuse(bufmgr);
416 batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
417
Chris Wilson1ca607b2013-08-16 09:44:13 +0100418 for (int i = 0; i < num_buffers; i++) {
Daniel Vetter43779e32013-08-14 14:50:50 +0200419 src[i] = mode->create_bo(bufmgr, i, width, height);
420 dst[i] = mode->create_bo(bufmgr, ~i, width, height);
Daniel Vetter3dba47e2013-08-06 22:27:37 +0200421 }
Daniel Vetter43779e32013-08-14 14:50:50 +0200422 dummy = mode->create_bo(bufmgr, 0, width, height);
Daniel Vetter3dba47e2013-08-06 22:27:37 +0200423 }
424
Daniel Vetterec283d62013-08-14 15:18:37 +0200425 run_basic_modes(mode, src, dst, dummy, "", run_single);
Chris Wilson6c428a62014-08-29 13:11:37 +0100426
427 igt_fork_signal_helper();
Chris Wilson1ca607b2013-08-16 09:44:13 +0100428 run_basic_modes(mode, src, dst, dummy, "-interruptible", run_interruptible);
Chris Wilson6c428a62014-08-29 13:11:37 +0100429 igt_stop_signal_helper();
Daniel Vetter3dba47e2013-08-06 22:27:37 +0200430
Daniel Vetter2dbd9982013-08-14 15:48:54 +0200431 igt_fixture {
Chris Wilson1ca607b2013-08-16 09:44:13 +0100432 for (int i = 0; i < num_buffers; i++) {
Daniel Vetter43779e32013-08-14 14:50:50 +0200433 drm_intel_bo_unreference(src[i]);
434 drm_intel_bo_unreference(dst[i]);
435 }
436 drm_intel_bo_unreference(dummy);
Chris Wilson0d320fd2013-08-16 12:07:56 +0100437 intel_batchbuffer_free(batch);
438 drm_intel_bufmgr_destroy(bufmgr);
Daniel Vetter43779e32013-08-14 14:50:50 +0200439 }
Chris Wilson1ca607b2013-08-16 09:44:13 +0100440
Chris Wilson6c428a62014-08-29 13:11:37 +0100441 igt_fork_signal_helper();
Chris Wilson1ca607b2013-08-16 09:44:13 +0100442 run_basic_modes(mode, src, dst, dummy, "-forked", run_forked);
Chris Wilson6c428a62014-08-29 13:11:37 +0100443 igt_stop_signal_helper();
Daniel Vetter43779e32013-08-14 14:50:50 +0200444}
445
Daniel Vetter071e9ca2013-10-31 16:23:26 +0100446igt_main
Daniel Vetter43779e32013-08-14 14:50:50 +0200447{
448 int max, i;
449
Daniel Vetter43779e32013-08-14 14:50:50 +0200450 igt_skip_on_simulation();
451
Daniel Vetter2dbd9982013-08-14 15:48:54 +0200452 igt_fixture {
453 fd = drm_open_any();
Chris Wilson6c428a62014-08-29 13:11:37 +0100454 devid = intel_get_drm_devid(fd);
455 gen = intel_gen(devid);
Daniel Vetter43779e32013-08-14 14:50:50 +0200456
Daniel Vetter2dbd9982013-08-14 15:48:54 +0200457 max = gem_aperture_size (fd) / (1024 * 1024) / 2;
458 if (num_buffers > max)
459 num_buffers = max;
Daniel Vetteraee0dcb2013-12-03 16:32:52 +0100460
461 max = intel_get_total_ram_mb() * 3 / 4;
462 if (num_buffers > max)
463 num_buffers = max;
Chris Wilson0b4c33f2014-01-26 14:36:32 +0000464 num_buffers /= 2;
Daniel Vettere624fa82014-05-14 00:36:04 +0200465 igt_info("using 2x%d buffers, each 1MiB\n", num_buffers);
Daniel Vetter2dbd9982013-08-14 15:48:54 +0200466 }
Daniel Vetter43779e32013-08-14 14:50:50 +0200467
468 for (i = 0; i < ARRAY_SIZE(access_modes); i++)
469 run_modes(&access_modes[i]);
Daniel Vetter3dba47e2013-08-06 22:27:37 +0200470}