diff options
author | Andrzej Turko <andrzej.turko@linux.intel.com> | 2021-06-17 09:16:43 +0200 |
---|---|---|
committer | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2021-06-18 12:04:02 +0200 |
commit | 138a29e30277b1039e9934fca5c782dc1e7a9f99 (patch) | |
tree | 79e9b31715154f1cfb9bc5e1a2bbc8ec4d5af188 /lib/intel_allocator_reloc.c | |
parent | 00060bc519a7ab3b0ee83ea6e4a7b9096aee2913 (diff) |
lib/intel_allocator: Move ioctl calls to client processes
When allocator is running in multiprocess mode, all queries
are processed in a designated thread in the parent process.
However, a child process may request opening the allocator
for a gpu using a file descriptor absent in the parent process.
Hence, querying available gtt size must be done in the child
instead of the parent process.
As a consequence of this change creating allocators managing
only a given interval of available gtt is now enabled for all
allocator implementations. Additionally, this commit sets a
universal lower bound on alignment to 4096.
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 'lib/intel_allocator_reloc.c')
-rw-r--r-- | lib/intel_allocator_reloc.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/lib/intel_allocator_reloc.c b/lib/intel_allocator_reloc.c index e8af787b0..1790e6c79 100644 --- a/lib/intel_allocator_reloc.c +++ b/lib/intel_allocator_reloc.c @@ -10,12 +10,11 @@ #include "igt_rand.h" #include "intel_allocator.h" -struct intel_allocator *intel_allocator_reloc_create(int fd); +struct intel_allocator * +intel_allocator_reloc_create(int fd, uint64_t start, uint64_t end); struct intel_allocator_reloc { - uint64_t bias; uint32_t prng; - uint64_t gtt_size; uint64_t start; uint64_t end; uint64_t offset; @@ -24,12 +23,8 @@ struct intel_allocator_reloc { uint64_t allocated_objects; }; -static uint64_t get_bias(int fd) -{ - (void) fd; - - return 256 << 10; -} +/* Keep the low 256k clear, for negative deltas */ +#define BIAS (256 << 10) static void intel_allocator_reloc_get_address_range(struct intel_allocator *ial, uint64_t *startp, @@ -55,13 +50,16 @@ static uint64_t intel_allocator_reloc_alloc(struct intel_allocator *ial, (void) handle; (void) strategy; - alignment = max(alignment, 4096); aligned_offset = ALIGN(ialr->offset, alignment); /* Check we won't exceed end */ if (aligned_offset + size > ialr->end) aligned_offset = ALIGN(ialr->start, alignment); + /* Check that the object fits in the address range */ + if (aligned_offset + size > ialr->end) + return ALLOC_INVALID_ADDRESS; + offset = aligned_offset; ialr->offset = offset + size; ialr->allocated_objects++; @@ -152,8 +150,8 @@ static bool intel_allocator_reloc_is_empty(struct intel_allocator *ial) return !ialr->allocated_objects; } -#define RESERVED 4096 -struct intel_allocator *intel_allocator_reloc_create(int fd) +struct intel_allocator * +intel_allocator_reloc_create(int fd, uint64_t start, uint64_t end) { struct intel_allocator *ial; struct intel_allocator_reloc *ialr; @@ -177,14 +175,11 @@ struct intel_allocator *intel_allocator_reloc_create(int fd) ialr = ial->priv = calloc(1, sizeof(*ialr)); igt_assert(ial->priv); ialr->prng = (uint32_t) to_user_pointer(ial); - ialr->gtt_size = gem_aperture_size(fd); - igt_debug("Gtt size: %" PRId64 "\n", ialr->gtt_size); - if (!gem_uses_full_ppgtt(fd)) - ialr->gtt_size /= 2; - - ialr->bias = ialr->offset = get_bias(fd); - ialr->start = ialr->bias; - ialr->end = ialr->gtt_size - RESERVED; + + start = max(start, BIAS); + igt_assert(start < end); + ialr->offset = ialr->start = start; + ialr->end = end; ialr->allocated_objects = 0; |