[PATCH i-g-t 03/19] lib/intel_allocator: Add full control over reloc pseudo-allocator creation

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Thu Apr 22 08:19:25 UTC 2021


Some tests requires working on limited ppgtt set in "round-robin" fashion
(like gem_tiled_fence_blits). For those we need to limit reloc range
to size we want to.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 lib/intel_allocator.c       |  9 ++++++-
 lib/intel_allocator_reloc.c | 54 ++++++++++++++++++++++++++++---------
 2 files changed, 50 insertions(+), 13 deletions(-)

diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c
index 96f839d4b..e141b5c3b 100644
--- a/lib/intel_allocator.c
+++ b/lib/intel_allocator.c
@@ -59,6 +59,9 @@ struct handle_entry {
 };
 
 struct intel_allocator *intel_allocator_reloc_create(int fd);
+struct intel_allocator *
+intel_allocator_reloc_create_full(int fd, uint64_t start, uint64_t end,
+				  enum allocator_strategy strategy);
 struct intel_allocator *intel_allocator_random_create(int fd);
 struct intel_allocator *intel_allocator_simple_create(int fd);
 struct intel_allocator *
@@ -286,7 +289,11 @@ static struct intel_allocator *intel_allocator_create(int fd,
 			     "We cannot use NONE allocator\n");
 		break;
 	case INTEL_ALLOCATOR_RELOC:
-		ial = intel_allocator_reloc_create(fd);
+		if (!start && !end)
+			ial = intel_allocator_reloc_create(fd);
+		else
+			ial = intel_allocator_reloc_create_full(fd, start, end,
+								allocator_strategy);
 		break;
 	case INTEL_ALLOCATOR_RANDOM:
 		ial = intel_allocator_random_create(fd);
diff --git a/lib/intel_allocator_reloc.c b/lib/intel_allocator_reloc.c
index e8af787b0..0b8cacfb3 100644
--- a/lib/intel_allocator_reloc.c
+++ b/lib/intel_allocator_reloc.c
@@ -11,11 +11,14 @@
 #include "intel_allocator.h"
 
 struct intel_allocator *intel_allocator_reloc_create(int fd);
+struct intel_allocator *
+intel_allocator_reloc_create_full(int fd, uint64_t start, uint64_t end,
+				  enum allocator_strategy strategy);
 
 struct intel_allocator_reloc {
+	enum allocator_strategy strategy;
+
 	uint64_t bias;
-	uint32_t prng;
-	uint64_t gtt_size;
 	uint64_t start;
 	uint64_t end;
 	uint64_t offset;
@@ -153,7 +156,10 @@ static bool intel_allocator_reloc_is_empty(struct intel_allocator *ial)
 }
 
 #define RESERVED 4096
-struct intel_allocator *intel_allocator_reloc_create(int fd)
+
+static struct intel_allocator *
+__intel_allocator_reloc_create(int fd, uint64_t start, uint64_t end,
+			       enum allocator_strategy strategy)
 {
 	struct intel_allocator *ial;
 	struct intel_allocator_reloc *ialr;
@@ -176,17 +182,41 @@ 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;
 
+	ialr->strategy = strategy;
+	ialr->offset = ialr->start = start;
+	ialr->end = end;
 	ialr->allocated_objects = 0;
 
 	return ial;
 }
+
+struct intel_allocator *
+intel_allocator_reloc_create(int fd)
+{
+	uint64_t gtt_size = gem_aperture_size(fd);
+
+	if (!gem_uses_full_ppgtt(fd))
+		gtt_size /= 2;
+	else
+		gtt_size -= RESERVED;
+
+	return __intel_allocator_reloc_create(fd, get_bias(fd), gtt_size,
+					      ALLOC_STRATEGY_LOW_TO_HIGH);
+}
+
+struct intel_allocator *
+intel_allocator_reloc_create_full(int fd, uint64_t start, uint64_t end,
+				  enum allocator_strategy strategy)
+{
+	uint64_t gtt_size = gem_aperture_size(fd);
+
+	igt_assert(end <= gtt_size);
+	if (!gem_uses_full_ppgtt(fd))
+		gtt_size /= 2;
+	igt_assert(end - start <= gtt_size);
+
+	return __intel_allocator_reloc_create(fd, max(start, get_bias(fd)),
+					      end, strategy);
+}
+
-- 
2.26.0



More information about the Intel-gfx-trybot mailing list