2 * Copyright © 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 * Ben Widawsky <ben@bwidawsk.net>
29 * Negative test cases:
30 * test we can't submit contexts to unsupported rings
42 #include <sys/ioctl.h>
45 #include "ioctl_wrappers.h"
48 /* Copied from gem_exec_nop.c */
49 static int exec(int fd, uint32_t handle, int ring, int ctx_id)
51 struct drm_i915_gem_execbuffer2 execbuf;
52 struct drm_i915_gem_exec_object2 gem_exec;
55 gem_exec.handle = handle;
56 gem_exec.relocation_count = 0;
57 gem_exec.relocs_ptr = 0;
58 gem_exec.alignment = 0;
64 execbuf.buffers_ptr = (uintptr_t)&gem_exec;
65 execbuf.buffer_count = 1;
66 execbuf.batch_start_offset = 0;
67 execbuf.batch_len = 8;
68 execbuf.cliprects_ptr = 0;
69 execbuf.num_cliprects = 0;
73 i915_execbuffer2_set_context_id(execbuf, ctx_id);
76 ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2,
84 uint32_t batch[2] = {MI_BATCH_BUFFER_END};
90 igt_skip_on_simulation();
93 fd = drm_open_any_render();
95 ctx_id = gem_context_create(fd);
97 handle = gem_create(fd, 4096);
98 gem_write(fd, handle, 0, batch, sizeof(batch));
101 igt_subtest("render")
102 igt_assert(exec(fd, handle, I915_EXEC_RENDER, ctx_id) == 0);
104 igt_assert(exec(fd, handle, I915_EXEC_BSD, ctx_id) != 0);
106 igt_assert(exec(fd, handle, I915_EXEC_BLT, ctx_id) != 0);
107 #ifdef I915_EXEC_VEBOX
109 igt_require(gem_has_vebox(fd));
111 igt_assert(exec(fd, handle, I915_EXEC_VEBOX, ctx_id) != 0);