From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85B5D10E1D9 for ; Wed, 26 Apr 2023 11:52:13 +0000 (UTC) From: Bhanuprakash Modem To: igt-dev@lists.freedesktop.org Date: Wed, 26 Apr 2023 17:16:44 +0530 Message-Id: <20230426114725.2244653-5-bhanuprakash.modem@intel.com> In-Reply-To: <20230426114725.2244653-1-bhanuprakash.modem@intel.com> References: <20230426114725.2244653-1-bhanuprakash.modem@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [i-g-t V3 04/45] lib/intel_allocator: Add allocator support for Xe List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: From: Zbigniew Kempczyński Start supporting va range configuration for xe allocator. During opening allocator has to be aware of vm range (start and end). i915 driver doesn't expose vm range information so those variables have to be detected. In xe driver we get information of va size from the kernel query so va end can be directly configured. At the moment there's no autodetection of va start for xe what might need to be address in the future if for some reason lower offsets might not be in use. Signed-off-by: Zbigniew Kempczyński Signed-off-by: Bhanuprakash Modem Cc: Kamil Konieczny Reviewed-by: Kamil Konieczny --- lib/intel_allocator.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/intel_allocator.c b/lib/intel_allocator.c index 2b08dd599..45c1168ab 100644 --- a/lib/intel_allocator.c +++ b/lib/intel_allocator.c @@ -16,6 +16,7 @@ #include "igt_map.h" #include "intel_allocator.h" #include "intel_allocator_msgchannel.h" +#include "xe/xe_query.h" //#define ALLOCDBG #ifdef ALLOCDBG @@ -910,24 +911,33 @@ static uint64_t __intel_allocator_open_full(int fd, uint32_t ctx, struct alloc_resp resp; uint64_t gtt_size; - if (!start) - req.open.start = gem_detect_safe_start_offset(fd); + if (is_i915_device(fd)) { + if (!start) + req.open.start = gem_detect_safe_start_offset(fd); - if (!end) { - igt_assert_f(can_report_gtt_size(fd), "Invalid fd\n"); - gtt_size = gem_aperture_size(fd); - if (!gem_uses_full_ppgtt(fd)) - gtt_size /= 2; - else - gtt_size -= RESERVED; + if (!end) { + igt_assert_f(can_report_gtt_size(fd), "Invalid fd\n"); + gtt_size = gem_aperture_size(fd); + if (!gem_uses_full_ppgtt(fd)) + gtt_size /= 2; + else + gtt_size -= RESERVED; - req.open.end = gtt_size; - } + req.open.end = gtt_size; + } - if (!default_alignment) - req.open.default_alignment = gem_detect_safe_alignment(fd); + if (!default_alignment) + req.open.default_alignment = gem_detect_safe_alignment(fd); + + req.open.start = ALIGN(req.open.start, req.open.default_alignment); + } else { + struct xe_device *xe_dev = xe_device_get(fd); - req.open.start = ALIGN(req.open.start, req.open.default_alignment); + igt_assert(xe_dev); + + if (!end) + req.open.end = 1ull << xe_dev->va_bits; + } /* Get child_tid only once at open() */ if (child_tid == -1) @@ -998,7 +1008,7 @@ uint64_t intel_allocator_open_vm_full(int fd, uint32_t vm, /** * intel_allocator_open: - * @fd: i915 descriptor + * @fd: i915 or xe descriptor * @ctx: context * @allocator_type: one of INTEL_ALLOCATOR_* define * -- 2.40.0