summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-10-06 11:14:56 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-03-01 11:42:47 +0000
commit915aa3d99fb3d0ebe8bf127504c1643941c42cc5 (patch)
tree580b45417cae3c321c7f505bba9de45c9a4356c7
parente77e5538399bb554841f8f1567587a97d47f0431 (diff)
igt/gem_exec_capture: Exercise readback of userptr
EXEC_OBJECT_CAPTURE extends the type of buffers we may read during error capture. Previously we knew that we would only see batch buffers (which limited the objects to being from gem_create()), but now we need to check that any buffer the user can create can be read. The first alternate buffer type is a userptr. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: MichaƂ Winiarski <michal.winiarski@intel.com>
-rw-r--r--tests/gem_exec_capture.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/gem_exec_capture.c b/tests/gem_exec_capture.c
index 43c443be..2dc06ce4 100644
--- a/tests/gem_exec_capture.c
+++ b/tests/gem_exec_capture.c
@@ -57,7 +57,7 @@ static void check_error_state(int dir, struct drm_i915_gem_exec_object2 *obj)
igt_assert(found);
}
-static void capture(int fd, int dir, unsigned ring)
+static void __capture(int fd, int dir, unsigned ring, uint32_t target)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
struct drm_i915_gem_exec_object2 obj[4];
@@ -72,7 +72,7 @@ static void capture(int fd, int dir, unsigned ring)
memset(obj, 0, sizeof(obj));
obj[SCRATCH].handle = gem_create(fd, 4096);
- obj[CAPTURE].handle = gem_create(fd, 4096);
+ obj[CAPTURE].handle = target;
obj[CAPTURE].flags = LOCAL_OBJECT_CAPTURE;
obj[NOCAPTURE].handle = gem_create(fd, 4096);
@@ -159,10 +159,32 @@ static void capture(int fd, int dir, unsigned ring)
gem_close(fd, obj[BATCH].handle);
gem_close(fd, obj[NOCAPTURE].handle);
- gem_close(fd, obj[CAPTURE].handle);
gem_close(fd, obj[SCRATCH].handle);
}
+static void capture(int fd, int dir, unsigned ring)
+{
+ uint32_t handle;
+
+ handle = gem_create(fd, 4096);
+ __capture(fd, dir, ring, handle);
+ gem_close(fd, handle);
+}
+
+static void userptr(int fd, int dir)
+{
+ uint32_t handle;
+ void *ptr;
+
+ igt_assert(posix_memalign(&ptr, 4096, 4096) == 0);
+ igt_require(__gem_userptr(fd, ptr, 4096, 0, 0, &handle) == 0);
+
+ __capture(fd, dir, 0, handle);
+
+ gem_close(fd, handle);
+ free(ptr);
+}
+
static bool has_capture(int fd)
{
drm_i915_getparam_t gp;
@@ -214,6 +236,13 @@ igt_main
}
}
+ /* And check we can read from different types of objects */
+
+ igt_subtest_f("userptr") {
+ igt_require(gem_can_store_dword(fd, 0));
+ userptr(fd, dir);
+ }
+
igt_fixture {
close(dir);
igt_disallow_hang(fd, hang);