2 * Copyright (c) 2014 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
37 #include <sys/ioctl.h>
41 #include "ioctl_wrappers.h"
44 #include "intel_chipset.h"
47 #define LOCAL_I915_EXEC_VEBOX (4<<0)
49 struct drm_i915_gem_execbuffer2 execbuf;
50 struct drm_i915_gem_exec_object2 gem_exec[1];
51 uint32_t batch[2] = {MI_BATCH_BUFFER_END};
52 uint32_t handle, devid;
60 devid = intel_get_drm_devid(fd);
62 handle = gem_create(fd, 4096);
63 gem_write(fd, handle, 0, batch, sizeof(batch));
65 gem_exec[0].handle = handle;
66 gem_exec[0].relocation_count = 0;
67 gem_exec[0].relocs_ptr = 0;
68 gem_exec[0].alignment = 0;
69 gem_exec[0].offset = 0;
70 gem_exec[0].flags = 0;
71 gem_exec[0].rsvd1 = 0;
72 gem_exec[0].rsvd2 = 0;
74 execbuf.buffers_ptr = (uintptr_t)gem_exec;
75 execbuf.buffer_count = 1;
76 execbuf.batch_start_offset = 0;
77 execbuf.batch_len = 8;
78 execbuf.cliprects_ptr = 0;
79 execbuf.num_cliprects = 0;
83 i915_execbuffer2_set_context_id(execbuf, 0);
87 igt_subtest("control") {
88 igt_assert(drmIoctl(fd,
89 DRM_IOCTL_I915_GEM_EXECBUFFER2,
91 execbuf.flags = I915_EXEC_RENDER;
92 igt_assert(drmIoctl(fd,
93 DRM_IOCTL_I915_GEM_EXECBUFFER2,
97 #define RUN_FAIL(expected_errno) do { \
98 igt_assert(drmIoctl(fd, \
99 DRM_IOCTL_I915_GEM_EXECBUFFER2, \
101 igt_assert_cmpint(errno, ==, expected_errno); \
104 igt_subtest("no-bsd") {
105 igt_require(!gem_has_bsd(fd));
106 execbuf.flags = I915_EXEC_BSD;
109 igt_subtest("no-blt") {
110 igt_require(!gem_has_blt(fd));
111 execbuf.flags = I915_EXEC_BLT;
114 igt_subtest("no-vebox") {
115 igt_require(!gem_has_vebox(fd));
116 execbuf.flags = LOCAL_I915_EXEC_VEBOX;
119 igt_subtest("invalid-ring") {
120 execbuf.flags = I915_EXEC_RING_MASK;
124 igt_subtest("invalid-ring2") {
125 execbuf.flags = LOCAL_I915_EXEC_VEBOX+1;
129 igt_subtest("rel-constants-invalid-ring") {
130 igt_require(gem_has_bsd(fd));
131 execbuf.flags = I915_EXEC_BSD | I915_EXEC_CONSTANTS_ABSOLUTE;
135 igt_subtest("rel-constants-invalid-rel-gen5") {
136 igt_require(intel_gen(devid) > 5);
137 execbuf.flags = I915_EXEC_RENDER | I915_EXEC_CONSTANTS_REL_SURFACE;
141 igt_subtest("rel-constants-invalid") {
142 execbuf.flags = I915_EXEC_RENDER | (I915_EXEC_CONSTANTS_REL_SURFACE+(1<<6));
146 igt_subtest("sol-reset-invalid") {
147 igt_require(gem_has_bsd(fd));
148 execbuf.flags = I915_EXEC_BSD | I915_EXEC_GEN7_SOL_RESET;
152 igt_subtest("sol-reset-not-gen7") {
153 igt_require(intel_gen(devid) != 7);
154 execbuf.flags = I915_EXEC_RENDER | I915_EXEC_GEN7_SOL_RESET;
158 igt_subtest("secure-non-root") {
162 execbuf.flags = I915_EXEC_RENDER | I915_EXEC_SECURE;
169 igt_subtest("secure-non-master") {
170 do_or_die(drmDropMaster(fd));
171 execbuf.flags = I915_EXEC_RENDER | I915_EXEC_SECURE;
173 do_or_die(drmSetMaster(fd));
174 igt_assert(drmIoctl(fd,
175 DRM_IOCTL_I915_GEM_EXECBUFFER2,
179 /* HANDLE_LUT and NO_RELOC are already exercised by gem_exec_lut_handle */
181 igt_subtest("invalid-flag") {
182 execbuf.flags = I915_EXEC_RENDER | (I915_EXEC_HANDLE_LUT << 1);
186 /* rsvd1 aka context id is already exercised by gem_ctx_bad_exec */
188 igt_subtest("cliprects-invalid") {
189 igt_require(intel_gen(devid) >= 5);
191 execbuf.num_cliprects = 1;
193 execbuf.num_cliprects = 0;
197 igt_subtest(#name "-dirt") { \
213 gem_close(fd, handle);