2 * Copyright © 2013 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 * Ville Syrjälä <ville.syrjala@linux.intel.com>
37 #include <sys/ioctl.h>
39 #include "ioctl_wrappers.h"
42 #include "intel_chipset.h"
44 static void do_test_invalid_tiling(int fd, uint32_t handle, int tiling, int stride)
46 igt_assert(__gem_set_tiling(fd, handle, tiling, tiling ? stride : 0) == -EINVAL);
49 static void test_invalid_tiling(int fd, uint32_t handle, int stride)
51 do_test_invalid_tiling(fd, handle, I915_TILING_X, stride);
52 do_test_invalid_tiling(fd, handle, I915_TILING_Y, stride);
56 * Testcase: Check that max fence stride works
74 devid = intel_get_drm_devid(fd);
76 if (intel_gen(devid) >= 7)
78 else if (intel_gen(devid) >= 4)
88 size = stride * tile_height;
93 /* Fill each line with the line number */
94 for (y = 0; y < tile_height; y++) {
95 for (x = 0; x < stride / 4; x++)
99 handle = gem_create(fd, size);
101 ptr = gem_mmap(fd, handle, size, PROT_READ | PROT_WRITE);
104 test_invalid_tiling(fd, handle, 0);
105 test_invalid_tiling(fd, handle, 64);
106 test_invalid_tiling(fd, handle, stride - 1);
107 test_invalid_tiling(fd, handle, stride + 1);
108 test_invalid_tiling(fd, handle, stride + 127);
109 test_invalid_tiling(fd, handle, stride + 128);
110 test_invalid_tiling(fd, handle, stride + tile_width - 1);
111 test_invalid_tiling(fd, handle, stride + tile_width);
112 test_invalid_tiling(fd, handle, stride * 2);
113 test_invalid_tiling(fd, handle, INT_MAX);
114 test_invalid_tiling(fd, handle, UINT_MAX);
116 gem_set_tiling(fd, handle, I915_TILING_X, stride);
118 gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
120 memcpy(ptr, data, size);
122 gem_set_tiling(fd, handle, I915_TILING_NONE, 0);
124 memcpy(data, ptr, size);
126 /* Check that each tile contains the expected pattern */
127 for (i = 0; i < size / 4; ) {
128 for (y = 0; y < tile_height; y++) {
129 for (x = 0; x < tile_width / 4; x++) {
130 igt_assert(y == data[i]);