2 * Copyright © 2011,2012 Intel Corporation
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:
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
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
24 * Chris Wilson <chris@chris-wilson.co.uk>
25 * Daniel Vetter <daniel.vetter@ffwll.ch>
30 * Testcase: run a nop batch which is really big
32 * Mostly useful to stress-test the error-capture code
44 #include <sys/ioctl.h>
47 #include "ioctl_wrappers.h"
50 #define BATCH_SIZE (1024*1024)
52 static void exec(int fd, uint32_t handle, uint32_t reloc_ofs)
54 struct drm_i915_gem_execbuffer2 execbuf;
55 struct drm_i915_gem_exec_object2 gem_exec[1];
56 struct drm_i915_gem_relocation_entry gem_reloc[1];
59 gem_reloc[0].offset = reloc_ofs;
60 gem_reloc[0].delta = 0;
61 gem_reloc[0].target_handle = handle;
62 gem_reloc[0].read_domains = I915_GEM_DOMAIN_RENDER;
63 gem_reloc[0].write_domain = 0;
64 gem_reloc[0].presumed_offset = 0;
66 gem_exec[0].handle = handle;
67 gem_exec[0].relocation_count = 1;
68 gem_exec[0].relocs_ptr = (uintptr_t) gem_reloc;
69 gem_exec[0].alignment = 0;
70 gem_exec[0].offset = 0;
71 gem_exec[0].flags = 0;
72 gem_exec[0].rsvd1 = 0;
73 gem_exec[0].rsvd2 = 0;
75 execbuf.buffers_ptr = (uintptr_t)gem_exec;
76 execbuf.buffer_count = 1;
77 execbuf.batch_start_offset = 0;
78 execbuf.batch_len = 8;
79 execbuf.cliprects_ptr = 0;
80 execbuf.num_cliprects = 0;
84 i915_execbuffer2_set_context_id(execbuf, 0);
87 /* Avoid hitting slowpaths in the reloc processing which might yield a
88 * presumed_offset of -1. Happens when the batch is still busy from the
92 gem_execbuf(fd, &execbuf);
94 igt_warn_on(gem_reloc[0].presumed_offset == -1);
96 gem_read(fd, handle, reloc_ofs, &tmp, 4);
97 igt_assert_eq(tmp, gem_reloc[0].presumed_offset);
102 uint32_t batch[2] = {MI_BATCH_BUFFER_END};
108 igt_skip_on_simulation();
112 for (batch_size = BATCH_SIZE/4; batch_size <= BATCH_SIZE; batch_size += 4096) {
113 handle = gem_create(fd, batch_size);
114 gem_write(fd, handle, 0, batch, sizeof(batch));
116 for (reloc_ofs = 4096; reloc_ofs < batch_size; reloc_ofs += 4096) {
117 igt_debug("batch_size %u, reloc_ofs %u\n",
118 batch_size, reloc_ofs);
119 exec(fd, handle, reloc_ofs);
123 gem_close(fd, handle);