From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98A9D10E834 for ; Thu, 26 Oct 2023 15:50:47 +0000 (UTC) From: Andrzej Hajda Date: Thu, 26 Oct 2023 17:50:30 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231026-gtt_size_fix-v1-2-882d0e0022ec@intel.com> References: <20231026-gtt_size_fix-v1-0-882d0e0022ec@intel.com> In-Reply-To: <20231026-gtt_size_fix-v1-0-882d0e0022ec@intel.com> To: igt-dev@lists.freedesktop.org Subject: [igt-dev] [PATCH 2/2] lib/intel_batchbuffer: allow GTT size be not power of 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jonathan Cavitt , Nirmoy Das Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: GTT size reported by the driver can be shorter than the actual size due to possible reserved addresses. Rounding it up to power of 2 should give us back actual GTT size. The patch is prerequisite for upcoming driver changes introducing per context batch buffers. Signed-off-by: Andrzej Hajda --- lib/intel_batchbuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index df82ef5f5ca..c32d04302fe 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -1675,7 +1675,7 @@ __intel_bb_add_object(struct intel_bb *ibb, uint32_t handle, uint64_t size, offset = __intel_bb_get_offset(ibb, handle, size, alignment); } else { - offset = offset & (ibb->gtt_size - 1); + offset = offset & (roundup_power_of_two(ibb->gtt_size) - 1); /* * For simple allocator check entry consistency -- 2.34.1