[igt-dev] [PATCH i-g-t v33 18/39] lib/intel_batchbuffer: Don't collect relocations for newer gens

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Apr 13 08:42:05 UTC 2021


Preparing universal batches for rendercopy, gpgpu fill and media fill
must take into account does kernel support relocations for specified
gen or not.

In intel-bb we assume relocations are supported so user is calling
intel_bb_emit_reloc() like functions to emit address in the batch
what collects relocation required for execbuf call in intel-bb.
For newer gens kernel will reject such relocations returning
-EINVAL so we should just provide an offset (returned from allocator)
and skip adding relocation entry to intel-bb.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Jason Ekstrand <jason at jlekstrand.net>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 lib/intel_batchbuffer.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 1b234b14d..0b2c5b21e 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -2148,7 +2148,8 @@ intel_bb_object_clear_flag(struct intel_bb *ibb, uint32_t handle, uint64_t flag)
  * @delta: delta value to add to @buffer's gpu address
  * @offset: offset within bb to be patched
  *
- * Function allocates additional relocation slot in reloc array for a handle.
+ * When relocations are requested function allocates additional relocation slot
+ * in reloc array for a handle.
  * Object must be previously added to bb.
  */
 static uint64_t intel_bb_add_reloc(struct intel_bb *ibb,
@@ -2167,6 +2168,10 @@ static uint64_t intel_bb_add_reloc(struct intel_bb *ibb,
 	object = intel_bb_find_object(ibb, handle);
 	igt_assert(object);
 
+	/* In no-reloc mode we just return the previously assigned address */
+	if (!ibb->enforce_relocs)
+		goto out;
+
 	/* For ibb we have relocs allocated in chunks */
 	if (to_handle == ibb->handle) {
 		relocs = ibb->relocs;
@@ -2207,6 +2212,7 @@ static uint64_t intel_bb_add_reloc(struct intel_bb *ibb,
 		  delta, offset,
 		  from_user_pointer(relocs[i].presumed_offset));
 
+out:
 	return object->offset;
 }
 
-- 
2.26.0



More information about the igt-dev mailing list