Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 588A410F016 for ; Fri, 4 Mar 2022 09:02:11 +0000 (UTC) From: =?UTF-8?q?Zbigniew=20Kempczy=C5=84ski?= To: igt-dev@lists.freedesktop.org Date: Fri, 4 Mar 2022 10:02:00 +0100 Message-Id: <20220304090202.32164-2-zbigniew.kempczynski@intel.com> In-Reply-To: <20220304090202.32164-1-zbigniew.kempczynski@intel.com> References: <20220304090202.32164-1-zbigniew.kempczynski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t 1/3] lib/intel_batchbuffer: Use safe alignment for intel-bb List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: Discrete cards can have different memory alignment requirements when objects used in execbuffer comes from different memory regions. Lets use safe alignment which should be fine regardless objects location. v2: ensure passed alignment is power of two (Kamil) Signed-off-by: Zbigniew KempczyƄski Cc: Ashutosh Dixit Cc: Kamil Konieczny --- lib/intel_batchbuffer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index ddb8d8c1fd..460f5f2bb3 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -1370,7 +1370,7 @@ __intel_bb_create(int i915, uint32_t ctx, uint32_t size, bool do_relocs, ibb->enforce_relocs = do_relocs; ibb->handle = gem_create(i915, size); ibb->size = size; - ibb->alignment = 4096; + ibb->alignment = gem_detect_safe_alignment(i915); ibb->ctx = ctx; ibb->vm_id = 0; ibb->batch = calloc(1, size); @@ -1925,9 +1925,10 @@ intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size, igt_assert(INVALID_ADDR(offset) || alignment == 0 || ALIGN(offset, alignment) == offset); + igt_assert(is_power_of_two(alignment)); object = __add_to_cache(ibb, handle); - alignment = alignment ?: 4096; + alignment = max_t(uint64_t, alignment, gem_detect_safe_alignment(ibb->i915)); __add_to_objects(ibb, object); /* -- 2.32.0