From: Siluvery, Arun arun.siluv...@intel.com
This ioctl allows vary the effective size of the gem object.
User can mark certain range in object space as scratch thus
effectively modifying the size used.
v2: modify subtest names and function names as per tooling convention.
Signed-off-by: Siluvery, Arun arun.siluv...@intel.com
---
tests/Makefile.sources | 1 +
tests/gem_bo_falloc.c | 471 +
2 files changed, 472 insertions(+)
create mode 100644 tests/gem_bo_falloc.c
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 88866ac..25c010e 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -120,6 +120,7 @@ TESTS_progs = \
gem_unref_active_buffers \
gem_vmap_blits \
gem_wait_render_timeout \
+ gem_bo_falloc \
gen3_mixed_blits \
gen3_render_linear_blits \
gen3_render_mixed_blits \
diff --git a/tests/gem_bo_falloc.c b/tests/gem_bo_falloc.c
new file mode 100644
index 000..d6b7f10
--- /dev/null
+++ b/tests/gem_bo_falloc.c
@@ -0,0 +1,471 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ *
+ */
+
+#include unistd.h
+#include stdlib.h
+#include stdio.h
+#include string.h
+#include fcntl.h
+#include inttypes.h
+#include errno.h
+#include sys/stat.h
+#include sys/ioctl.h
+#include drm.h
+#include i915_drm.h
+#include drmtest.h
+#include intel_chipset.h
+#include intel_gpu_tools.h
+
+#define OBJECT_SIZE (8 * PAGE_SIZE)
+#define COPY_BLT_CMD (229|0x5322|0x6)
+#define BLT_WRITE_ALPHA(121)
+#define BLT_WRITE_RGB (120)
+#define BLT_SRC_TILED (115)
+#define BLT_DST_TILED (111)
+
+static uint8_t buf[OBJECT_SIZE];
+
+static uint32_t create_bo(int fd)
+{
+ int i;
+ uint32_t page_count;
+ uint32_t handle;
+
+ handle = gem_create(fd, sizeof(buf));
+ page_count = sizeof(buf) / PAGE_SIZE;
+
+ for (i = 0; i page_count; ++i)
+ memset(buf + (i * PAGE_SIZE), i+1, PAGE_SIZE);
+
+ gem_write(fd, handle, 0, buf, sizeof(buf));
+ return handle;
+}
+
+static int gem_linear_blt(int fd,
+ uint32_t *batch,
+ uint32_t src,
+ uint32_t dst,
+ uint32_t length,
+ struct drm_i915_gem_relocation_entry *reloc)
+{
+ uint32_t *b = batch;
+ int height = length / (16 * 1024);
+
+ igt_assert(height = 116);
+
+ if (height) {
+ int i = 0;
+ b[i++] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB;
+ if (intel_gen(intel_get_drm_devid(fd)) = 8)
+ b[i-1]+=2;
+ b[i++] = 0xcc 16 | 1 25 | 1 24 | (16*1024);
+ b[i++] = 0;
+ b[i++] = height 16 | (4*1024);
+ b[i++] = 0;
+ reloc-offset = (b-batch+4) * sizeof(uint32_t);
+ reloc-delta = 0;
+ reloc-target_handle = dst;
+ reloc-read_domains = I915_GEM_DOMAIN_RENDER;
+ reloc-write_domain = I915_GEM_DOMAIN_RENDER;
+ reloc-presumed_offset = 0;
+ reloc++;
+ if (intel_gen(intel_get_drm_devid(fd)) = 8)
+ b[i++] = 0; /* FIXME */
+
+ b[i++] = 0;
+ b[i++] = 16*1024;
+ b[i++] = 0;
+ reloc-offset = (b-batch+7) * sizeof(uint32_t);
+ if (intel_gen(intel_get_drm_devid(fd)) = 8)
+ reloc-offset += sizeof(uint32_t);
+ reloc-delta = 0;
+ reloc-target_handle = src;
+ reloc-read_domains = I915_GEM_DOMAIN_RENDER;
+ reloc-write_domain = 0;
+ reloc-presumed_offset = 0;
+ reloc++;
+ if