summaryrefslogtreecommitdiff
path: root/tests/i915/gem_exec_parallel.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-08-03 10:23:55 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-09-29 13:41:42 +0100
commitd089599869755e80accd16d3018b5f9ace139588 (patch)
tree4f495a18a04682e78382191c2b8dbee6ef862207 /tests/i915/gem_exec_parallel.c
parent722a3eb9734f04030508d244df9dff55c5ab686c (diff)
i915/gem_exec_parallel: Add basic userptr thrashing
Mix in a modicum of generic userptr thrashing for a quick (1s) BAT pass, as we have currently no coverage of userptr at all in BAT. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Diffstat (limited to 'tests/i915/gem_exec_parallel.c')
-rw-r--r--tests/i915/gem_exec_parallel.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/i915/gem_exec_parallel.c b/tests/i915/gem_exec_parallel.c
index bf94b93d..96feb825 100644
--- a/tests/i915/gem_exec_parallel.c
+++ b/tests/i915/gem_exec_parallel.c
@@ -45,6 +45,7 @@ static inline uint32_t hash32(uint32_t val)
#define CONTEXTS 0x1
#define FDS 0x2
+#define USERPTR 0x4
#define NUMOBJ 16
@@ -164,6 +165,30 @@ static void check_bo(int fd, uint32_t handle, int pass, struct thread *threads)
igt_assert_eq_u32(result, x);
}
+static uint32_t handle_create(int fd, unsigned int flags, void **data)
+{
+ if (flags & USERPTR) {
+ uint32_t handle;
+ void *ptr;
+
+ posix_memalign(&ptr, 4096, 4096);
+ gem_userptr(fd, ptr, 4096, 0, 0, &handle);
+ *data = ptr;
+
+ return handle;
+ }
+
+ return gem_create(fd, 4096);
+}
+
+static void handle_close(int fd, unsigned int flags, uint32_t handle, void *data)
+{
+ if (flags & USERPTR)
+ free(data);
+
+ gem_close(fd, handle);
+}
+
static void all(int fd, struct intel_execution_engine2 *engine, unsigned flags)
{
const int gen = intel_gen(intel_get_drm_devid(fd));
@@ -172,6 +197,7 @@ static void all(int fd, struct intel_execution_engine2 *engine, unsigned flags)
struct thread *threads;
uint32_t scratch[NUMOBJ], handle[NUMOBJ];
unsigned engines[16], nengine;
+ void *arg[NUMOBJ];
int go;
int i;
@@ -196,7 +222,7 @@ static void all(int fd, struct intel_execution_engine2 *engine, unsigned flags)
igt_require(nengine);
for (i = 0; i < NUMOBJ; i++) {
- scratch[i] = handle[i] = gem_create(fd, 4096);
+ scratch[i] = handle[i] = handle_create(fd, flags, &arg[i]);
if (flags & FDS)
scratch[i] = gem_flink(fd, handle[i]);
}
@@ -233,7 +259,7 @@ static void all(int fd, struct intel_execution_engine2 *engine, unsigned flags)
for (i = 0; i < NUMOBJ; i++) {
check_bo(fd, handle[i], i, threads);
- gem_close(fd, handle[i]);
+ handle_close(fd, flags, handle[i], arg[i]);
}
igt_assert_eq(intel_detect_and_clear_missed_interrupts(fd), 0);
@@ -251,6 +277,7 @@ igt_main
{ "basic", 0 },
{ "contexts", CONTEXTS },
{ "fds", FDS },
+ { "userptr", USERPTR },
{ NULL }
};
int fd;