diff options
author | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2021-03-10 09:27:29 +0100 |
---|---|---|
committer | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2021-04-13 15:44:38 +0200 |
commit | f92db39cf96a31d8371fd0b537b661dd366fa653 (patch) | |
tree | 59e5b8732e751241c9eaa4c3b4201aadabb93080 /tests/i915/api_intel_allocator.c | |
parent | 919f37742e1cdb170b57a3cb256e99397276d7fd (diff) |
tests/api_intel_allocator: Verify child can use its standalone allocator
Sometimes we don't want to use common allocator provided by main IGT
process. Verify it is able to "detach" from it and initialize its own
version of allocator.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'tests/i915/api_intel_allocator.c')
-rw-r--r-- | tests/i915/api_intel_allocator.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/i915/api_intel_allocator.c b/tests/i915/api_intel_allocator.c index 95a5082a..7ff92a17 100644 --- a/tests/i915/api_intel_allocator.c +++ b/tests/i915/api_intel_allocator.c @@ -288,6 +288,45 @@ static void parallel_one(int fd, uint8_t type) igt_assert_eq(intel_allocator_close(ahnd), true); } +static void standalone(int fd) +{ + uint64_t ahnd, offset, size = 4096; + uint32_t handle = 1, child_handle = 2; + uint64_t *shared; + + shared = mmap(0, 4096, PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); + + intel_allocator_multiprocess_start(); + + ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE); + offset = intel_allocator_alloc(ahnd, handle, size, 0); + + igt_fork(child, 2) { + /* + * Use standalone allocator for child 1, detach from parent, + * child 2 use allocator from parent. + */ + if (child == 1) + intel_allocator_init(); + + ahnd = intel_allocator_open(fd, 0, INTEL_ALLOCATOR_SIMPLE); + shared[child] = intel_allocator_alloc(ahnd, child_handle, size, 0); + + intel_allocator_free(ahnd, child_handle); + intel_allocator_close(ahnd); + } + igt_waitchildren(); + igt_assert_eq(offset, shared[1]); + igt_assert_neq(offset, shared[2]); + + intel_allocator_free(ahnd, handle); + igt_assert_eq(intel_allocator_close(ahnd), true); + + intel_allocator_multiprocess_stop(); + + munmap(shared, 4096); +} + #define SIMPLE_GROUP_ALLOCS 8 static void __simple_allocs(int fd) { @@ -626,6 +665,9 @@ igt_main } } + igt_subtest_f("standalone") + standalone(fd); + igt_subtest_f("fork-simple-once") fork_simple_once(fd); |