summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-12-15 21:00:30 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2020-12-16 09:41:48 +0000
commit2e5ad6b45c20c5b354325e0c818e25ba6087ecc2 (patch)
tree589df46fae1b5378b0e9e9577e2614b468547144
parent30c8762d568a20ab56daffe293788f1addc5b794 (diff)
i915/gem_softpin: Check full placement control under full-ppgtt
With full-ppgtt, userspace has complete control over their GTT. Verify that we can place an object at the very beginning and the very end of our GTT. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Matthew Auld <matthew.auld@intel.com>
-rw-r--r--tests/i915/gem_softpin.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/i915/gem_softpin.c b/tests/i915/gem_softpin.c
index fcaf8ef3..a3e6dcac 100644
--- a/tests/i915/gem_softpin.c
+++ b/tests/i915/gem_softpin.c
@@ -97,6 +97,65 @@ static void test_invalid(int fd)
}
}
+static uint32_t batch_create(int i915, uint64_t *sz)
+{
+ const uint32_t bbe = MI_BATCH_BUFFER_END;
+ struct drm_i915_gem_create create = {
+ .size = sizeof(bbe),
+ };
+
+ if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_CREATE, &create)) {
+ igt_assert_eq(errno, 0);
+ return 0;
+ }
+
+ gem_write(i915, create.handle, 0, &bbe, sizeof(bbe));
+
+ *sz = create.size;
+ return create.handle;
+}
+
+static void test_zero(int i915)
+{
+ uint64_t sz, gtt = gem_aperture_size(i915);
+ struct drm_i915_gem_exec_object2 object = {
+ .handle = batch_create(i915, &sz),
+ .flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS,
+ };
+ struct drm_i915_gem_execbuffer2 execbuf = {
+ .buffers_ptr = to_user_pointer(&object),
+ .buffer_count = 1,
+ };
+
+ /* Under full-ppgtt, we have complete control of the GTT */
+ igt_info("Object size:%"PRIx64", GTT size:%"PRIx64"\n", sz, gtt);
+
+ object.offset = 0;
+ igt_assert_f(__gem_execbuf(i915, &execbuf) == 0,
+ "execbuff failed with object.offset=%llx\n",
+ object.offset);
+
+ if (gtt >> 32) {
+ object.offset = (1ull << 32) - sz;
+ igt_assert_f(__gem_execbuf(i915, &execbuf) == 0,
+ "execbuff failed with object.offset=%llx\n",
+ object.offset);
+
+ object.offset = 1ull << 32;
+ igt_assert_f(__gem_execbuf(i915, &execbuf) == 0,
+ "execbuff failed with object.offset=%llx\n",
+ object.offset);
+ }
+
+ object.offset = gtt - sz;
+ object.offset = gen8_canonical_addr(object.offset);
+ igt_assert_f(__gem_execbuf(i915, &execbuf) == 0,
+ "execbuff failed with object.offset=%llx\n",
+ object.offset);
+
+ gem_close(i915, object.handle);
+}
+
static void test_softpin(int fd)
{
const uint32_t size = 1024 * 1024;
@@ -559,6 +618,10 @@ igt_main
igt_subtest("invalid")
test_invalid(fd);
+ igt_subtest("zero") {
+ igt_require(gem_uses_full_ppgtt(fd));
+ test_zero(fd);
+ }
igt_subtest("softpin")
test_softpin(fd);
igt_subtest("overlap")