From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id DA82E10E09F for ; Thu, 27 Apr 2023 20:04:26 +0000 (UTC) From: =?UTF-8?q?Zbigniew=20Kempczy=C5=84ski?= To: igt-dev@lists.freedesktop.org Date: Thu, 27 Apr 2023 22:03:06 +0200 Message-Id: <20230427200307.240349-16-zbigniew.kempczynski@intel.com> In-Reply-To: <20230427200307.240349-1-zbigniew.kempczynski@intel.com> References: <20230427200307.240349-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 v7 15/16] lib/igt_draw: Pass region while building intel_buf from flink List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: For i915 region doesn't matter but for xe we need to be more strict and region aware. This is related to size and alignment constraints. As we don't have information about flink buffer origin let's assume region is vram if possible, otherwise choose system region. Signed-off-by: Zbigniew KempczyƄski Reviewed-by: Bhanuprakash Modem --- lib/igt_draw.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/igt_draw.c b/lib/igt_draw.c index ac512fac5a..c5f2fdfe2b 100644 --- a/lib/igt_draw.c +++ b/lib/igt_draw.c @@ -37,6 +37,7 @@ #include "i915/gem_create.h" #include "i915/gem_mman.h" #include "i915/intel_mocs.h" +#include "xe/xe_query.h" #ifndef PAGE_ALIGN #ifndef PAGE_SIZE @@ -634,17 +635,24 @@ static struct intel_buf *create_buf(int fd, struct buf_ops *bops, struct buf_data *from, uint32_t tiling) { struct intel_buf *buf; + enum intel_driver driver = buf_ops_get_driver(bops); uint32_t handle, name, width, height; + uint64_t region = driver == INTEL_DRIVER_XE ? vram_if_possible(fd, 0) : -1; + uint64_t size = from->size; width = from->stride / (from->bpp / 8); height = from->size / from->stride; + if (driver == INTEL_DRIVER_XE) + size = ALIGN(size, xe_get_default_alignment(fd)); name = gem_flink(fd, from->handle); handle = gem_open(fd, name); - buf = intel_buf_create_using_handle(bops, handle, - width, height, from->bpp, 0, - tiling, 0); + buf = intel_buf_create_full(bops, handle, + width, height, from->bpp, 0, + tiling, 0, + size, 0, + region); /* Make sure we close handle on destroy path */ intel_buf_set_ownership(buf, true); -- 2.34.1