The goal is compare the speed of copying to and from a LLC bo using
either the CPU or GPU.
Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk
---
lib/drmtest.c| 14 +++
lib/drmtest.h|1 +
tests/.gitignore |1 +
tests/Makefile.am|1 +
tests/llc_exec_blt.c | 278 ++
5 files changed, 295 insertions(+)
create mode 100644 tests/llc_exec_blt.c
diff --git a/lib/drmtest.c b/lib/drmtest.c
index cdf46aa..feab1cb 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -74,6 +74,20 @@ bool gem_uses_aliasing_ppgtt(int fd)
return val;
}
+bool gem_has_llc(int fd)
+{
+ struct drm_i915_getparam gp;
+ int val;
+
+ gp.param = 17; /* HAS_LLC */
+ gp.value = val;
+
+ if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, gp, sizeof(gp)))
+ return false;
+
+ return val != 0;
+}
+
int gem_available_fences(int fd)
{
struct drm_i915_getparam gp;
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 4021104..fcc875d 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -63,6 +63,7 @@ int gem_madvise(int fd, uint32_t handle, int state);
/* feature test helpers */
bool gem_uses_aliasing_ppgtt(int fd);
+bool gem_has_llc(int fd);
int gem_available_fences(int fd);
/* generally useful helpers */
diff --git a/tests/.gitignore b/tests/.gitignore
index f486a87..fce1497 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -14,6 +14,7 @@ gem_double_irq_loop
gem_dummy_reloc_loop
gem_exec_bad_domains
gem_exec_blt
+llc_exec_blt
gem_exec_faulting_reloc
gem_exec_nop
gem_fenced_exec_thrash
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5a64660..dcaa1d4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -13,6 +13,7 @@ TESTS_progs = \
gem_gtt_concurrent_blit \
gem_exec_nop \
gem_exec_blt \
+ llc_exec_blt \
gem_exec_bad_domains \
gem_exec_faulting_reloc \
gem_flink \
diff --git a/tests/llc_exec_blt.c b/tests/llc_exec_blt.c
new file mode 100644
index 000..9a18b46
--- /dev/null
+++ b/tests/llc_exec_blt.c
@@ -0,0 +1,278 @@
+/*
+ * Copyright © 2011 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.
+ *
+ * Authors:
+ *Chris Wilson ch...@chris-wilson.co.uk
+ *
+ */
+
+#include unistd.h
+#include stdlib.h
+#include stdint.h
+#include stdio.h
+#include string.h
+#include assert.h
+#include fcntl.h
+#include inttypes.h
+#include errno.h
+#include sys/stat.h
+#include sys/ioctl.h
+#include sys/mman.h
+#include sys/time.h
+#include drm.h
+#include i915_drm.h
+#include drmtest.h
+#include intel_chipset.h
+#include intel_gpu_tools.h
+
+#define OBJECT_SIZE 16384
+#define PITCH 4096
+
+#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 int gem_tiled_blt(uint32_t *b,
+uint32_t src,
+uint32_t dst,
+uint32_t tiling,
+uint32_t length,
+struct drm_i915_gem_relocation_entry *reloc)
+{
+ int height = length / PITCH;
+ int pitch;
+
+ assert(height (116));
+
+ pitch = PITCH;
+ if (tiling BLT_DST_TILED)
+ pitch /= 4;
+
+ b[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB | tiling;
+ b[1] = 0xcc 16 | 1 25 | 1 24 | pitch;
+ b[2] = 0;
+ b[3] = height 16 | PITCH 2;
+ b[4] = 0;
+
+ reloc-offset = 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++;
+
+ pitch = PITCH;
+ if (tiling BLT_SRC_TILED)
+ pitch