summaryrefslogtreecommitdiff
path: root/tests/i915/api_intel_allocator.c
diff options
context:
space:
mode:
authorAndrzej Turko <andrzej.turko@linux.intel.com>2021-06-17 09:16:42 +0200
committerZbigniew Kempczyński <zbigniew.kempczynski@intel.com>2021-06-18 12:03:57 +0200
commit00060bc519a7ab3b0ee83ea6e4a7b9096aee2913 (patch)
tree9257150eac1465f2454931a3764aa2961ceaa01f /tests/i915/api_intel_allocator.c
parenta17cc0c5d096fabfd516848c114bc411e11130f4 (diff)
tests/i915/api_intel_allocator: Exercise allocator in multiprocess mode
Test creation and usage of allocators in multiprocess mode for contexts shared with the parent process as well as private for the child. This new test discovers a bug in the allocator implementation: allocator is not correctly initialized if it is opened by a child process using its private file descriptor. Signed-off-by: Andrzej Turko <andrzej.turko@linux.intel.com> Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Diffstat (limited to 'tests/i915/api_intel_allocator.c')
-rw-r--r--tests/i915/api_intel_allocator.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/i915/api_intel_allocator.c b/tests/i915/api_intel_allocator.c
index ea4ba8bb..4b74317e 100644
--- a/tests/i915/api_intel_allocator.c
+++ b/tests/i915/api_intel_allocator.c
@@ -621,6 +621,43 @@ static void execbuf_with_allocator(int fd)
igt_assert(intel_allocator_close(ahnd) == true);
}
+static void fork_reopen_allocator(int fd, uint8_t type)
+{
+ uint64_t p_ahnd, sh_ahnd, fd_ahnd, ctx_ahnd;
+ uint64_t offset;
+
+ intel_allocator_multiprocess_start();
+
+ p_ahnd = intel_allocator_open(fd, 0, type);
+ offset = intel_allocator_alloc(p_ahnd, 1, 123, 0);
+ if (type == INTEL_ALLOCATOR_SIMPLE)
+ igt_assert(intel_allocator_is_allocated(p_ahnd, 1, 123, offset));
+
+ igt_fork(child, 1) {
+ sh_ahnd = intel_allocator_open(fd, 0, type);
+ if (type == INTEL_ALLOCATOR_SIMPLE)
+ igt_assert(intel_allocator_is_allocated(sh_ahnd, 1, 123, offset));
+
+ ctx_ahnd = intel_allocator_open(fd, 1, type);
+ igt_assert(!intel_allocator_is_allocated(ctx_ahnd, 1, 123, offset));
+ intel_allocator_alloc(ctx_ahnd, 2, 123, 0);
+
+ fd = gem_reopen_driver(fd);
+ fd_ahnd = intel_allocator_open(fd, 0, type);
+ igt_assert(!intel_allocator_is_allocated(fd_ahnd, 1, 123, offset));
+ intel_allocator_alloc(fd_ahnd, 2, 123, 0);
+
+ intel_allocator_close(sh_ahnd);
+ intel_allocator_close(ctx_ahnd);
+ intel_allocator_close(fd_ahnd);
+ }
+
+ igt_waitchildren();
+ intel_allocator_close(p_ahnd);
+
+ intel_allocator_multiprocess_stop();
+}
+
struct allocators {
const char *name;
uint8_t type;
@@ -672,6 +709,9 @@ igt_main
igt_dynamic("reserve")
reserve(fd, a->type);
}
+
+ igt_dynamic("fork-reopen-allocator")
+ fork_reopen_allocator(fd, a->type);
}
}