[igt-dev] [PATCH i-g-t v5 25/26] lib/intel_batchbuffer: Use relocations in intel-bb up to gen12

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Mon Nov 2 05:39:19 UTC 2020


We want to use relocations as long as we can so change intel-bb
strategy to use it as default up to gen12. For gen12 we have
to use softpinning in ccs aux tables so there we enforce using
allocator instead of relocations.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/intel_batchbuffer.c | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index da52014c..8df422be 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -1270,25 +1270,25 @@ __intel_bb_create(int i915, uint32_t ctx, uint32_t size, bool do_relocs,
 	igt_assert(ibb);
 
 	ibb->uses_full_ppgtt = gem_uses_full_ppgtt(i915);
+	ibb->devid = intel_get_drm_devid(i915);
+	ibb->gen = intel_gen(ibb->devid);
 
 	/*
 	 * If we don't have full ppgtt driver can change our addresses
 	 * so allocator is useless in this case. Just enforce relocations
 	 * for such gens and don't use allocator at all.
 	 */
-	if (!ibb->uses_full_ppgtt) {
+	if (!ibb->uses_full_ppgtt)
 		do_relocs = true;
-		allocator_type = INTEL_ALLOCATOR_NONE;
-	}
 
-	if (!do_relocs)
-		ibb->allocator_handle = intel_allocator_open(i915, ctx, allocator_type);
+	/* if relocs are set we won't use an allocator */
+	if (do_relocs)
+		allocator_type = INTEL_ALLOCATOR_NONE;
 	else
-		igt_assert(allocator_type == INTEL_ALLOCATOR_NONE);
+		ibb->allocator_handle = intel_allocator_open(i915, ctx, allocator_type);
+
 	ibb->allocator_type = allocator_type;
 	ibb->i915 = i915;
-	ibb->devid = intel_get_drm_devid(i915);
-	ibb->gen = intel_gen(ibb->devid);
 	ibb->enforce_relocs = do_relocs;
 	ibb->handle = gem_create(i915, size);
 	ibb->size = size;
@@ -1324,7 +1324,7 @@ __intel_bb_create(int i915, uint32_t ctx, uint32_t size, bool do_relocs,
  *
  * Creates bb with context passed in @ctx, size in @size and allocator type
  * in @allocator_type. Relocations are set to false because IGT allocator
- * is not used in that case.
+ * is used in that case.
  *
  * Returns:
  *
@@ -1349,7 +1349,11 @@ struct intel_bb *intel_bb_create_full(int i915, uint32_t ctx, uint32_t size,
  */
 struct intel_bb *intel_bb_create(int i915, uint32_t size)
 {
-	return __intel_bb_create(i915, 0, size, false, INTEL_ALLOCATOR_SIMPLE);
+	bool relocs = gem_has_relocations(i915);
+	unsigned int gen = intel_gen(intel_get_drm_devid(i915));
+
+	return __intel_bb_create(i915, 0, size, relocs && gen < 12,
+				 INTEL_ALLOCATOR_SIMPLE);
 }
 
 /**
@@ -1367,7 +1371,11 @@ struct intel_bb *intel_bb_create(int i915, uint32_t size)
 struct intel_bb *
 intel_bb_create_with_context(int i915, uint32_t ctx, uint32_t size)
 {
-	return __intel_bb_create(i915, ctx, size, false, INTEL_ALLOCATOR_SIMPLE);
+	bool relocs = gem_has_relocations(i915);
+	unsigned int gen = intel_gen(intel_get_drm_devid(i915));
+
+	return __intel_bb_create(i915, ctx, size, relocs && gen < 12,
+				 INTEL_ALLOCATOR_SIMPLE);
 }
 
 /**
@@ -1384,6 +1392,8 @@ intel_bb_create_with_context(int i915, uint32_t ctx, uint32_t size)
  */
 struct intel_bb *intel_bb_create_with_relocs(int i915, uint32_t size)
 {
+	igt_require(gem_has_relocations(i915));
+
 	return __intel_bb_create(i915, 0, size, true, INTEL_ALLOCATOR_NONE);
 }
 
@@ -1403,6 +1413,8 @@ struct intel_bb *intel_bb_create_with_relocs(int i915, uint32_t size)
 struct intel_bb *
 intel_bb_create_with_relocs_and_context(int i915, uint32_t ctx, uint32_t size)
 {
+	igt_require(gem_has_relocations(i915));
+
 	return __intel_bb_create(i915, ctx, size, true, INTEL_ALLOCATOR_NONE);
 }
 
-- 
2.26.0



More information about the igt-dev mailing list