diff options
author | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2021-09-22 20:12:01 +0200 |
---|---|---|
committer | Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> | 2021-10-15 05:54:36 +0200 |
commit | 6967a156777c246e2b147c53fcd51011e337b7fc (patch) | |
tree | 587e8581786225e34279ad8f2aff373884c5fc8d | |
parent | 2360173cce25da5fba5a379d16416803d6228d5d (diff) |
lib/intel_batchbuffer: Detect and use kernel alignment capability
For gens where relocations are supported kernel can set object offset
everywhere it wants but it honours the alignment setting.
For gens where we got no relocations and setting alignment is not
allowed in exec object we want to ensure allocator will still use it
to properly align the offset.
Detect kernel caps in alignment setting and use it for reloc/no-reloc
paths accordingly.
v2: rename to gem_allows_obj_alignment() (Ashutosh)
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
-rw-r--r-- | lib/intel_batchbuffer.c | 9 | ||||
-rw-r--r-- | lib/intel_batchbuffer.h | 1 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index 9c26fe20..6fc81400 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -1335,6 +1335,7 @@ __intel_bb_create(int i915, uint32_t ctx, uint32_t size, bool do_relocs, igt_assert(ibb); + ibb->allows_obj_alignment = gem_allows_obj_alignment(i915); ibb->uses_full_ppgtt = gem_uses_full_ppgtt(i915); ibb->devid = intel_get_drm_devid(i915); ibb->gen = intel_gen(ibb->devid); @@ -1783,6 +1784,7 @@ __add_to_cache(struct intel_bb *ibb, uint32_t handle) igt_assert(object); object->handle = handle; + object->alignment = 0; found = tsearch((void *) object, &ibb->root, __compare_objects); if (*found == object) { @@ -1905,7 +1907,7 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size, || ALIGN(offset, alignment) == offset); object = __add_to_cache(ibb, handle); - object->alignment = alignment ?: 4096; + alignment = alignment ?: 4096; __add_to_objects(ibb, object); /* @@ -1917,7 +1919,7 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size, if (INVALID_ADDR(object->offset)) { if (INVALID_ADDR(offset)) { offset = __intel_bb_get_offset(ibb, handle, size, - object->alignment); + alignment); } else { offset = offset & (ibb->gtt_size - 1); @@ -1962,6 +1964,9 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size, if (ibb->uses_full_ppgtt && !ibb->enforce_relocs) object->flags |= EXEC_OBJECT_PINNED; + if (ibb->allows_obj_alignment) + object->alignment = alignment; + return object; } diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h index 58bddb1a..e7606307 100644 --- a/lib/intel_batchbuffer.h +++ b/lib/intel_batchbuffer.h @@ -476,6 +476,7 @@ struct intel_bb { uint64_t gtt_size; bool supports_48b_address; bool uses_full_ppgtt; + bool allows_obj_alignment; struct igt_pxp pxp; uint32_t ctx; |